knowledge-base-builder
Turn the repetitive task of "building a knowledge base" into a stable workflow: first confirm the state of the target directory, then generate a deterministic structure with a script, and finally get user confirmation. Do not force a build without a clear goal, and do not overwrite existing structures.
In the following, <python> represents a confirmed available Python interpreter with version 3.10 or higher (on macOS/Linux it is usually python3, on Windows usually py -3).
Before You Begin: Check Existing Structure
Use the script to detect the target directory structure silently, reporting if found:
<python> scripts/scaffold_kb.py check <target_directory>
- No structure detected → go to "Create" flow.
- Structure already exists → ask the user whether to "supplement the existing" or "rebuild from scratch"; do not overwrite directly. Rebuilding must obtain authorization first.
Create Flow
Step 1: Collect Information (Non-Blocking)
Ask questions one by one, each with a default value. If the user does not answer, use the default:
| Question | Default |
|---|---|
| Your nickname/name? | me |
| Your profession/role? | knowledge worker |
| Which areas do you want to go deep into? | work skills, personal growth, hobbies |
| Your core goal? | Build a second brain so that knowledge can be deposited and reused |
If the answer is "whatever/anything" or incomplete, use the default value directly and let the user confirm all changes at once—don't repeat questions.
Step 2: Design Area Classification
Generate areas under 10-Areas/ based on profession and domains. Use plain names for area folders (e.g., Data Analysis), without numeric prefixes. Each area can optionally have sub-areas; sub-areas use numeric prefixes (e.g., 1-Business Understanding).
- One folder per area, areas should not overlap, 3–5 is recommended.
- Sub-areas are optional: ask the user "which sub-areas do you want under each area? Default is empty"; if not provided, leave them blank.
- Under
00-Inbox/Pending/, mirror the same area folders (without sub-areas), one-to-one with Areas, to facilitate alignment when promoting.
Step 3: Generate Skeleton
Use the script to generate deterministically, do not create directories manually one by one:
<python> scripts/scaffold_kb.py build <target_directory> \
--name <nickname> --occupation <profession> \
--areas "AreaA:sub1,sub2;AreaB" --goal <goal>
--areas uses commas to separate areas; add sub-areas for an area using Area:sub1,sub2; separate multiple areas with sub-areas using semicolons. The script creates the fixed directory structure and 8 files (root README + 40-Skills hub + 6 brain description files). If the target directory already contains a structure with the same name, it refuses to overwrite. If the host cannot run Python, create the same structure manually following references/file-templates.md.
Step 4: Verify Core Files
Ensure the following files are generated with user information; content templates are at references/file-templates.md:
README.md— knowledge base overview and flow instructions40-Skills/README.md— execution toolkit hub90-<nickname>'s Brain Guide/README.md— brain guide (highest priority entry)90-<nickname>'s Brain Guide/profile.md— user profile90-<nickname>'s Brain Guide/agents.md— AI operation constraints90-<nickname>'s Brain Guide/initialization_prompt.md— complete recovery prompt for new sessions90-<nickname>'s Brain Guide/file_tracking.md— link update mechanism for file moves90-<nickname>'s Brain Guide/backup_plan.md— backup plan
Step 5: Deliver and Confirm
Report the generated directory tree and usage, and ask if the user needs to adjust area classification or structure.
Resource Navigation
| What you need | Where to read |
|---|---|
| Design principles of the 4-tier flow | references/design-principles.md |
| Directory structure and file templates | references/file-templates.md |
| A complete example | examples/data-analyst-example.md |
Stability and Recovery
- Idempotent: running the script multiple times does not create duplicates or conflicts; it refuses to overwrite when the structure exists.
- Recoverable: if any step fails, keep the intermediate artifacts generated so far, and explain at which step it stopped and how to continue.
- No overwrite: overwriting, deleting, or rebuilding must obtain user authorization first.
Completion Criteria
- Skeleton fully generated, script or manual creation matches references/file-templates.md;
- 8 files customized with user information;
- User has confirmed area classification and structure (or uses default values).