Project foundation document management (`/doc init`). Centrally manages Steering Documents and Project Documents, ensuring consistency through drift detection and normalization (`/doc sync` for bidirectional normalization, `/doc add`/`/doc project` for adding documents, `/doc translate {lang}` for generating multi-language translations).
Parse ARGUMENTS and route to the appropriate command.
If ARGUMENTS contains --help, Read ${CLAUDE_PLUGIN_ROOT}/modules/skill-help.md and follow the "Processing Steps" section to output help, then stop.
init → init wizardproduct / tech / structure → individual create/updatesync → bidirectional normalization (reverse-generate if Steering Documents don't exist; normalize content and detect drift if they do)sync --deep → extended reverse-generation combining codebase analysis + existing .md file integrated scan (4-pattern classification + absorption target determination)sync {doc} → individual reverse-generation (doc = product / tech / structure)init --deep → auto-generate draft by running codebase analysis + .md integration inline, skipping the question flowproduct --deep / tech --deep / → auto-generate draft with inline execution equivalent to (codebase analysis + .md integration)structure --deep--deepadd {path} → register an existing document as a project documentproject → interactive creation of a new project documenttranslate {lang} → generate multi-language translations for English documentation (commit and push included)Read ${CLAUDE_PLUGIN_ROOT}/modules/detect-config-markers.md and follow the "Processing Steps" section. Retain SPEC_PATH and STEERING_DOCS_PATH for use in subsequent steps.
If ARGUMENTS is empty: execute status display (see "Status Display" section below) and exit.
If ARGUMENTS is init: execute the "init wizard" section and exit.
If ARGUMENTS is init --deep: enable --deep flag and execute the "init wizard" section and exit.
If ARGUMENTS is product, tech, or structure:
/doc product → create/update $STEERING_DOCS_PATH/product.md/doc tech → create/update $STEERING_DOCS_PATH/tech.md/doc structure → create/update $STEERING_DOCS_PATH/structure.mdExecute the "Individual Create/Update" section and exit.
If ARGUMENTS is product --deep, tech --deep, or structure --deep: enable --deep flag and execute the "Individual Create/Update" section and exit. When --deep flag is enabled, skip the question flow for new file creation and auto-generate a draft by running codebase analysis + existing .md file integration scan inline.
If ARGUMENTS is sync: execute the "sync Bidirectional Normalization" section and exit.
If ARGUMENTS is sync --deep: enable --deep flag and execute the "sync Bidirectional Normalization" section and exit. In the reverse-generation flow (Steps 2–5), --deep mode adds codebase analysis and existing .md file integrated scan (4-pattern classification + absorption target determination).
If ARGUMENTS is sync product, sync tech, or sync structure: execute the "sync Individual Reverse-Generation" section and exit.
If ARGUMENTS starts with add (format: add {path}): execute the "add — Register Existing Document" section and exit. If {path} is not specified, display "Usage: /doc add {path}" and exit.
If ARGUMENTS is project: execute the "project — Create New Project Document" section and exit.
If ARGUMENTS starts with translate (format: translate {lang}): extract {lang} from ARGUMENTS. If {lang} is empty (ARGUMENTS is exactly translate), display "Usage: /doc translate {lang}" and exit. Otherwise, execute the "translate — Translation Generation" section and exit.
For any other ARGUMENTS: display "Usage: /doc [init|init --deep|product|tech|structure|product --deep|tech --deep|structure --deep|sync|sync --deep|sync {doc}|add {path}|project|translate {lang}]" and exit.
Each steering document's template is defined in the following individual files.
Read them when templates are needed within the workflow.
The type and ssot_for values here are the SSoT for frontmatter (type: steering + ssot_for block) prepended when writing to $STEERING_DOCS_PATH/{doc}.md.
| Document | Template file | type | ssot_for |
|---|---|---|---|
| product.md | skills/doc/product-template.md | steering | vision, non-goals, terminology |
| tech.md | skills/doc/tech-template.md | steering | tech-stack, coding-conventions, forbidden-expressions |
| structure.md | skills/doc/structure-template.md | steering | directory-layout, agent-includes-catalog |
Common frontmatter-based document traversal procedure used in status display and sync flows. Instead of fixed traversal via docs/*.md Glob, search the entire repository for .md files with a type field.
type: project\|type: steering pattern limited to *.md files, getting a list of candidate file paths$SPEC_PATH/ (specification documents)node_modules/ (external dependencies).git/ (Git management files).tmp/ (temporary files)type field valuetype: steering or type: project as traversal targetsSearch the entire repository for files with a type field in frontmatter and display their existence status in table format.
Follow the "Document Traversal (common procedure)" section to collect target files from the entire repository using frontmatter-based traversal. Get the last modified date of each collected file with ls -l.
Display in the following format:
| Document | type | Status | Last Updated |
|----------|------|--------|-------------|
| product.md | steering | ✓ exists | 2024-01-15 |
| tech.md | steering | ✓ exists | 2024-01-14 |
| workflow.md | project | ✓ exists | 2024-01-13 |
The type column shows the value of the frontmatter type field (steering or project).
If any documents with type: steering are missing from the ones that the individual create/update command supports (product / tech / structure), display:
Some documents are not yet created.
- `/doc product` to create product.md
- `/doc tech` to create tech.md
- `/doc structure` to create structure.md
- `/doc init` to start the sequential creation wizard
Create or update the {doc} (product / tech / structure) document specified in ARGUMENTS.
Check for the existence of $STEERING_DOCS_PATH/{doc}.md with Glob.
If it exists, proceed to "update flow". If not, proceed to "new creation flow".
If --deep flag is enabled, skip the AskUserQuestion flow. If analysis results are already available (e.g., called from init --deep), use them; otherwise run the --deep mode processing from "sync Bidirectional Normalization" Step 2 (codebase analysis + existing .md file integrated scan) inline. Reference entry points, dependency relations, and existing .md content to embed appropriate content in each section for auto-generated draft. Skip Step 3 (Optional section confirmation) and leave Optional section headings and descriptions wrapped in HTML comments (<!-- ... -->), so subsequent sync commands can stably recognize section structure.
If --deep flag is disabled, collect Required section information step by step with AskUserQuestion (non-interactive mode: auto-resolve — infer content from codebase analysis; proceed as if --deep flag were enabled).
For product.md:
Question 1: What is the Vision (project purpose/goals)?
Question 2: Who are the Target Users?
Question 3: What are the Non-Goals (out of scope)?
Question 4: Are there any Terms (project-specific term definitions)? Enter "none" if not.
For tech.md:
Question 1: What is the Language and Runtime (languages/runtime used)?
Question 2: What are the Key Dependencies (major dependency packages)?
Question 3: What are the Architecture Decisions (important technical decisions)?
For structure.md:
Question 1: What is the Directory Layout (directory structure and each directory's role)?
Question 2: What are the Key Files (description of important files)?
Ask with AskUserQuestion whether to add Optional sections (non-interactive mode: skip — wrap Optional section headings and descriptions in HTML comments; this is a High-Stakes Decision since optional section preference is user-specific).
If adding, collect the content and include it. If skipping, wrap the Optional section headings and descriptions from the template in HTML comments (<!-- ... -->). This allows subsequent sync commands and other skills to identify the section structure.
Example (skipped format):
<!-- ## Success Metrics (Optional)
Describe success metrics. -->
Read skills/doc/{doc}-template.md to check the template structure.
If the file is not found, display the following error and abort:
Error: template file `skills/doc/{doc}-template.md` not found.
wholework is not correctly installed. Reinstall the wholework plugin via `/plugin install wholework@saitoco-wholework`.
Look up the type and ssot_for values for {doc} from the Template Definitions table and prepend the following frontmatter block before writing with Write:
---