Analyze any project → derive optimal grouping → generate complete Markdown documentation system → self-check completeness.
Detect existing docs: Check for docs/, doc/, documentation/, or any .md files at project root
Detect entry file: Check for AGENTS.md, CLAUDE.md, GEMINI.md, README.md
Decision point:
Existing docs found → present two equal options to user (no default):
No existing docs → proceed directly to Phase 1
Deploy tool: Copy scripts/md-sections.sh to project's scripts/ directory (create if needed)
Detect explicit boundaries (🤖 automatic):
Identify architecture pattern (🤖👤 semi-automatic):
Identify cross-cutting concerns (🤖👤 semi-automatic):
Optional field research: If unfamiliar project type or user requests, search for industry documentation practices for this tech stack/domain. Use results as hints only, not mandates.
→ Output: Project Profile (JSON) containing: techStack, modules, architecture, concerns. Show Phase 1 reasoning to user before proceeding.
For detailed signal tables and detection methods, see grouping-detection.md.
Derive grouping dimensions from Phase 1 results:
Quality check (以职责为核心):
Key principle: Three-track system is the foundation. Read three-track-philosophy.md for full philosophy.
Classify each document group into tracks:
Determine template flexibility for each group: text
Documents answer same class of questions?
├── No → Flexibility 1: Fully Independent
└── Yes → Reader expectations identical?
├── Yes → Flexibility 3: Fully Unified
└── No → Shared core but unique needs?
├── Yes → Flexibility 4: Mixed (unified shell + free core)
└── No → Flexibility 2: Shell Unified
Generate fixed shell (three tiers):
Derive core chapters:
Present templates to user: Show derived templates per group. User confirms or adjusts.
For detailed template derivation methods, see template-derivation.md.
Generate entry file (AGENTS.md or equivalent):
Generate meta-system doc (docs/README.md):
Generate group README for each group directory:
Generate all documents per derived templates:
Write layered disclosure rule into entry file: markdown
## ⛔ Documentation Loading Rules (Highest Priority)
For documents exceeding 200 lines:
Step 1: Run `scripts/md-sections.sh <file>` for JSON structure
Step 2: Run `scripts/md-sections.sh <file> "Section Name"` to extract specific content
PROHIBITED: Reading full document content in one operation
Run structural checks (S1-S7, 🤖 automatic):
Run content checks (C1-C6, 🤖👤 semi-automatic):
Run system health checks (H1-H5, 👤 human judgment):
Output self-check report using fixed template (see completeness-checklist.md for full template).
LevelMarkerTriggerExample🤖 DeterministicDirect fix1:1 mappable from codeAPI signature change → update API reference🤖👤 Semi-deterministic[pending confirmation]Requires intent understandingBusiness logic change → update description👤 CreativeSkip, reportRequires original thinkingNew module → create new document
→ 1. Phase 0: No existing docs → proceed directly
→ 2. Phase 1: Detect Maven modules (common, client-cache, client-oss, app), identify layered architecture, find concerns (auth, caching, storage, testing)
→ 3. Phase 2: Derive 3 groups: architecture/ (by question), conventions/ (by concern), modules/ (by module)
→ 4. Phase 3: architecture=Flexibility 1, conventions=Flexibility 2, modules=Flexibility 3. Intent track in openspec/specs/, Contract in docs/modules/ + docs/architecture/, Constraint in docs/conventions/ + AGENTS.md
→ 5. Phase 4: Generate 22 documents + AGENTS.md + docs/README.md + group READMEs
→ 6. Phase 5: S1-S7 all pass. C2-C5 use Java-specific detection (annotations, pom.xml). H5: compare against Spring Boot doc conventions
→ 7. Phase 6: User confirms
→ 1. Phase 0: Existing docs/ with disorganized files → present two options → user chooses "Full redesign"
→ 2. Phase 1: Detect npm workspaces, identify component structure, find concerns (styling, accessibility, testing, i18n)
→ 3. Phase 2: Derive groups: components/ (by component), guides/ (by concern), architecture/ (by question)
→ 4. Phase 3: components=Flexibility 3 (all need Overview/Props/Events/Examples), guides=Flexibility 2, architecture=Flexibility 4
→ 5. Phase 4: Generate documents. Field research reveals Storybook conventions → incorporate Props/Events/Accessibility chapters
→ 6. Phase 5: S4 finds entry file missing 3 new docs → fix. H5: accessibility docs missing → flag
→ 7. Phase 6: User adds accessibility concern → regenerate
→ 1. Phase 0: No existing docs
→ 2. Phase 1: Detect CMake/workspace modules, identify ECS + Game Loop pattern, find concerns (performance, memory, scripting, asset pipeline)
→ 3. Phase 2: Derive 4 groups: systems/ (AI, rendering, physics, audio), pipelines/ (asset, build, CI), guides/ (scripting, performance, debugging), architecture/ (overview, patterns, memory model)
→ 4. Phase 3: systems=Flexibility 4 (unified shell: Overview/Integration/Performance, but unique chapters: AI has Behavior Tree, Rendering has Shader Pipeline)
→ 5. Phase 4: Generate. Field research: Unreal docs commonly cover Blueprints, C++ API, Performance budgets → incorporate
→ 6. Phase 5: H1 finds 2 subsystems without docs → flag for user
→ 7. Phase 6: User confirms
After completing the workflow:
ls -la docs/ recursively)scripts/md-sections.sh <each-file> → verify TOC sections existIf any check fails → diagnose, fix, re-verify. If user disagrees with grouping/templates → iterate from corresponding Phase.
FileWhen to Readthree-track-philosophy.mdPhase 3 — Need to explain track classification or writing philosophy to usergrouping-detection.mdPhase 1-2 — Need detailed signal tables, architecture patterns, or quality criteriatemplate-derivation.mdPhase 3 — Need detailed flexibility judgment, fixed shell definition, or chapter derivation methodscompleteness-checklist.mdPhase 5-6 — Need 18-dimension checklist details, dependency order, or report template
ScriptPurposescripts/md-sections.shMarkdown chapter parser with three operations: (1) md-sections.sh <file> → JSON structure tree, (2) md-sections.sh <file> "Section" → extract section content, (3) md-sections.sh <file> --line <N> → locate section by line number. Deploy to project's scripts/ in Phase 0
SkillRelationshipcontract-doc-syncMaintenance partner: This skill = architect (one-time generation), contract-doc-sync = property manager (ongoing drift detection + sync). This skill's generated detection configs can be reused by contract-doc-sync