Doc Init — Bootstrap Documentation from Existing Code
Analyze an existing codebase and generate a comprehensive documentation set as
drafts for human review. Every generated document is clearly marked as a draft.
Key principle: Generated docs are starting points, not finished artifacts.
The goal is 80% there so the developer only needs to review and refine,
not write from scratch.
Path Resolution
- Read
workflow.json in the project root
- If it exists and
docsRepo is ".": this IS the docs repo — output and templates use local paths
- If it exists and
docsRepo is a repo name: resolve via pwsh .claude/skills/tool-worktree/scripts/resolve-repo.ps1 <docsRepo> to get the docs root path. Output to <resolved>/, templates from <resolved>/templates/
- If no
workflow.json: output to docs/, templates from templates/
Phase 1: Codebase Analysis (always runs first)
Before generating anything, build a mental model of the project.
1.1 Project Structure Scan
- Read the project's top-level directory structure
- Identify the tech stack:
- Language/framework (package.json, *.csproj, go.mod, Cargo.toml, etc.)
- Build system and tooling
- Infrastructure files (Dockerfile, Bicep, Terraform, k8s manifests)
- Read the main entry point files (Program.cs, main.ts, app.py, etc.)
- Read existing CLAUDE.md, README.md, AGENTS.md for documented context
- Note existing documentation (anything in docs/, guides/, adr/)
1.2 Dependency Analysis
- Read dependency files (*.csproj PackageReferences, package.json, go.mod, etc.)
- Identify key architectural dependencies:
- Databases (EF Core, Prisma, SQLAlchemy, etc.)
- Message queues (RabbitMQ, Kafka, Azure Service Bus)
- External services (HTTP clients, SDKs)
- Frameworks that imply architecture (event sourcing, CQRS, MediatR)
- Map external system integrations
1.3 Architecture Discovery
- Identify deployable units (containers, services, workers, jobs)
- Identify data stores and their relationships
- Map API surface:
- REST endpoints (route definitions, controllers)
- gRPC services
- Message handlers / event consumers
- Identify domain model:
- Core entities / aggregates
- Domain events
- Value objects / specifications
1.4 Git Archaeology — Project Evolution Timeline
Reconstruct the project's history by mining git for architectural milestones,
dependency changes, structural shifts, and key decisions over time.
13. Build the project timeline:
Run these commands to gather raw history:
# First commit — project birth
git log --reverse --format="%ai %s" | head -1
# Full commit history with dates, condensed
git log --format="%ai %s" --all
# File creation timeline — when were key files/directories first added?
git log --diff-filter=A --format="%ai %H" --name-only -- \
"*.csproj" "*.sln" "package.json" "go.mod" "Cargo.toml" \
"Dockerfile" "docker-compose*" "*.bicep" "*.tf" \
"*.proto" ".github/workflows/*" "infra/*"
# Dependency evolution — track package additions and removals over time
git log --all -p -- "*.csproj" "package.json" "go.mod" "requirements.txt" \
| grep -E "^\+.*PackageReference|^\+.*\"dependencies\"|^\-.*PackageReference"
# Directory structure evolution — when did major directories appear?
git log --diff-filter=A --format="%ai" --name-only -- "*/" | head -200
# Contributors over time
git shortlog -sn --all
14. Identify evolutionary phases:
Group the timeline into phases based on what changed:
| Phase |
Signals to look for |
| Genesis |
First commit, initial project structure, core framework choices |
| Foundation |
Database setup, auth added, CI/CD pipeline created |
| Feature growth |
New domains/aggregates/endpoints added, dependency expansion |
| Refactors |
Renamed directories, moved files, replaced libraries |
| Infrastructure shifts |
New deployment targets, added monitoring, scaling changes |
| Migrations |
Framework upgrades, database migrations, API versioning |
For each phase, note:
- When it happened (date range)
- What changed (key commits, files added/removed)
- Why it likely happened (infer from commit messages, PR titles)
- Architectural impact (did the system's shape change?)
15. Detect specific architectural events:
# When were new projects/services added? (new .csproj = new deployable unit)
git log --diff-filter=A --format="%ai %s" --name-only -- "*.csproj"
# When did infrastructure change? (Bicep, Terraform, Docker)
git log --format="%ai %s" -- "infra/*" "Dockerfile" "docker-compose*" "*.bicep" "*.tf"
# When were major libraries swapped? (removed + added in same commit range)
git log --all -p -- "*.csproj" | grep -E "^[\+\-].*PackageReference"
# When did the API surface change significantly?
git log --format="%ai %s" -- "**/Endpoints/**" "**/Controllers/**" "**/routes/**"
# When were test projects added?
git log --diff-filter=A --format="%ai %s" --name-only -- "*.Tests.csproj" "*.test.*" "jest.config*"
# When did monitoring/observability arrive?
git log --format="%ai %s" -- "**/dashboard*" "**/workbook*" "**/monitoring*" "appsettings*.json"
16. Build the evolution summary:
### Project Evolution Timeline
**Created:** YYYY-MM-DD
**Age:** N months
**Commits:** N total, N contributors
#### Phase 1: Genesis (YYYY-MM — YYYY-MM)
- Initial project setup with [framework]
- Core domain: [aggregates/entities created]
- Key decision: [e.g., chose event sourcing over traditional CRUD]
#### Phase 2: Foundation (YYYY-MM — YYYY-MM)
- Added [auth, database, CI/CD]
- Key decision: [e.g., Azure Container Apps over AKS]
#### Phase 3: Growth (YYYY-MM — YYYY-MM)
- Added [N] new features: [list]
- Introduced [workers, background jobs, etc.]
- Key decision: [e.g., added video processing pipeline]
#### Phase 4: Maturation (YYYY-MM — present)
- Refactored [what]
- Replaced [old] with [new]
- Added monitoring and observability
#### Inferred Architectural Decisions
| # | Decision | Detected from | Date | Confidence |
|---|---------|--------------|------|-----------|
| 1 | Use event sourcing | EventSourcing in .csproj | YYYY-MM | High |
| 2 | Azure Container Apps | Bicep modules | YYYY-MM | High |
| 3 | Replaced library X with Y | Package diff | YYYY-MM | Medium |
| 4 | Added video processing | New project + pipeline | YYYY-MM | High |
17. Run git shortlog -sn --all | head -10 — who are the main contributors?
1.5 Present Analysis
- Present a summary of findings to the user, including the evolution timeline:
### Codebase Analysis
**Project:** [name]
**Tech stack:** [languages, frameworks]
**Architecture:** [monolith/microservices/modular monolith]
**Deployable units:** [list]
**External systems:** [list]
**Data stores:** [list]
**Domain model:** [N aggregates, N events, etc.]
**History:** [created YYYY-MM, N commits, N contributors]
### Documentation Plan
Based on analysis, I'll generate:
- [ ] C4 System Context diagram (Level 1)
- [ ] C4 Container diagram (Level 2)
- [ ] C4 Component diagrams (Level 3) for [complex containers]
- [ ] Project evolution timeline
- [ ] ADRs for [N] inferred architectural decisions
- [ ] Domain model reference
- [ ] API endpoint reference
- [ ] Developer onboarding guide
- [ ] [Other docs based on what was found]
Estimated docs: [N] files
- Wait for user approval before generating
Phase 2: Architecture Diagrams
Generate C4 diagrams using the viz-c4-diagram skill's Mermaid syntax.
2.1 System Context (Level 1)
- Generate the C4 Context diagram showing:
- The system as a single box
- All users/personas (infer from auth, roles, UI routes)
- All external systems (from dependency analysis)
- Relationship labels with protocols
- Save to
<output>/architecture/system-context.md
2.2 Container Diagram (Level 2)
- Generate the C4 Container diagram showing:
- Each deployable unit (API, frontend, workers, jobs)
- Each data store
- Message queues / event buses
- Technology annotations on each container
- Save to
<output>/architecture/containers.md
2.3 Component Diagrams (Level 3)
- For each complex container (typically the main API), generate a component diagram:
- Endpoint groups / controllers
- Domain services
- Repositories / data access
- Event handlers
- External service clients
- Save to
<output>/architecture/components-[container].md
Phase 3: Architecture Decision Records
Mine ADRs from the codebase and git history.
3.1 Infer Decisions
For each major architectural choice found, draft an ADR:
Always detectable:
- Primary language/framework choice
- Database technology choice
- Hosting platform (from infra files)
- Authentication approach (from auth middleware/config)
Often detectable:
- Architecture pattern (event sourcing, CQRS, clean architecture)
- API style (REST, gRPC, GraphQL)
- Testing strategy (from test projects/frameworks)
- CI/CD approach (from pipeline files)
- Messaging/eventing choices
Sometimes detectable (from git history):
- Migration from one approach to another
- Library replacements
- Infrastructure changes
For each inferred ADR:
- Read the template from
<templates>/adr.md
- Fill in context based on what was found in code
- List the considered options as "inferred" (we can see what was chosen, but alternatives are educated guesses)
- Mark status as
Inferred — needs review
- Number sequentially:
0001-[slug].md
Save to <output>/adr/
3.2 ADR Quality Rules
- Be honest about uncertainty: "Based on the codebase, this appears to be the decision. The alternatives listed are inferred, not confirmed."
- Don't invent rationale: If you can't tell WHY a decision was made, say so. "Rationale unknown — confirm with the team."
- Focus on significant decisions: Don't create an ADR for every library choice. Only for architectural-level decisions.
Phase 3b: Project Evolution Timeline
Save the evolution timeline from Phase 1.4 as a standalone document.
- Generate
<output>/architecture/project-evolution.md containing:
- Project birth date and age
- Phased timeline with dates, key changes, and architectural impact
- Inferred decisions table with confidence levels
- Dependency evolution (what was added, removed, replaced, and when)
- Contributor summary
- A Mermaid timeline diagram:
timeline
title Project Evolution
section Genesis
YYYY-MM : Initial project setup
: Core framework chosen
section Foundation
YYYY-MM : Auth added
: CI/CD pipeline
: Database setup
section Growth
YYYY-MM : Feature A
YYYY-MM : Feature B
: New service added
section Maturation
YYYY-MM : Monitoring added
: Library X replaced with Y
This document serves as the "story of the project" — useful for onboarding,
understanding why things are the way they are, and deciding what to change next.
Phase 4: Domain Reference
- Generate a domain model reference document:
- List all aggregates/entities with their properties
- List all domain events (grouped by aggregate)
- List all specifications/validators
- List all value objects / strongly typed IDs
- Include a class diagram (Mermaid) for the domain model
- Save to
<output>/reference/domain-model.md
Phase 5: API Reference
- Generate an API endpoint reference:
- Group endpoints by feature/resource
- List method, route, auth requirements
- Include request/response shapes if detectable
- Note which endpoints are public vs. authenticated
- Save to
<output>/reference/api-endpoints.md
Phase 6: Developer Onboarding
- Generate a getting-started guide:
- Prerequisites (SDKs, tools, runtimes)
- How to clone and set up
- How to run locally (infer from project files, docker-compose, etc.)
- How to run tests
- Project structure overview
- Key conventions (from CLAUDE.md, code patterns)
- Save to
<output>/guides/getting-started.md
Phase 7: Index & Summary
- Create or update
<output>/index.md with links to all generated docs
- Create an ADR index at
<output>/adr/index.md
- Present the final summary:
### Documentation Init Complete
Generated [N] documents:
#### Architecture ([N] files)
- system-context.md — C4 Level 1
- containers.md — C4 Level 2
- components-api.md — C4 Level 3
- project-evolution.md — Timeline of how the project evolved
#### ADRs ([N] files)
- 0001-[decision].md
- 0002-[decision].md
- ...
#### Reference ([N] files)
- domain-model.md
- api-endpoints.md
#### Guides ([N] files)
- getting-started.md
### Review Required
All documents are marked as drafts. Review each one for:
- [ ] Accuracy — correct any wrong assumptions
- [ ] Completeness — add missing context you know
- [ ] ADR rationale — fill in "why" for inferred decisions
- [ ] Remove draft markers once reviewed
Flags
| Flag |
Behavior |
--full |
Run all phases (default) |
--phase N |
Run only phase N (e.g., --phase 2 for just architecture diagrams) |
--dry-run |
Run phase 1 analysis only, show what would be generated |
--skip-existing |
Don't regenerate docs that already exist |
Draft Markers
Every generated document gets this banner at the top:
> **DRAFT** — Auto-generated from codebase analysis on [date].
> Review for accuracy before removing this banner.
Anti-Pattern Guards
- Don't over-document the obvious: Skip generating doc comments for self-explanatory code
- Don't invent rationale: If you can't determine WHY, mark it as "needs team input"
- Don't generate once and forget: This skill generates drafts; the doc-* skills maintain them
- Don't skip the review step: Always present the analysis (Phase 1) before generating
- Don't duplicate existing docs: Check for existing documentation first and note it
1---2name: doc-init3description: Bootstrap documentation for an existing codebase by analyzing code, git history, dependencies, and project structure. Generates C4 diagrams, ADRs, domain model reference, API docs, and onboarding guide as drafts for review. Use when the user says "init docs", "generate documentation", "bootstrap docs for this project", "document this codebase", or "create initial documentation".4---5
6# Doc Init — Bootstrap Documentation from Existing Code
7
8Analyze an existing codebase and generate a comprehensive documentation set as
9**drafts for human review**. Every generated document is clearly marked as a draft.
10
11> **Key principle:** Generated docs are starting points, not finished artifacts.
12> The goal is 80% there so the developer only needs to review and refine,
13> not write from scratch.
14
15## Path Resolution
16
171. Read `workflow.json` in the project root
182. If it exists and `docsRepo` is `"."`: this IS the docs repo — output and templates use local paths
193. If it exists and `docsRepo` is a repo name: resolve via `pwsh .claude/skills/tool-worktree/scripts/resolve-repo.ps1 <docsRepo>` to get the docs root path. Output to `<resolved>/`, templates from `<resolved>/templates/`
204. If no `workflow.json`: output to `docs/`, templates from `templates/`
21
22## Phase 1: Codebase Analysis (always runs first)
23
24Before generating anything, build a mental model of the project.
25
26### 1.1 Project Structure Scan
27
281. Read the project's top-level directory structure
292. Identify the tech stack:
30 - Language/framework (package.json, *.csproj, go.mod, Cargo.toml, etc.)
31 - Build system and tooling
32 - Infrastructure files (Dockerfile, Bicep, Terraform, k8s manifests)
333. Read the main entry point files (Program.cs, main.ts, app.py, etc.)
344. Read existing CLAUDE.md, README.md, AGENTS.md for documented context
355. Note existing documentation (anything in docs/, guides/, adr/)
36
37### 1.2 Dependency Analysis
38
396. Read dependency files (*.csproj PackageReferences, package.json, go.mod, etc.)
407. Identify key architectural dependencies:
41 - Databases (EF Core, Prisma, SQLAlchemy, etc.)
42 - Message queues (RabbitMQ, Kafka, Azure Service Bus)
43 - External services (HTTP clients, SDKs)
44 - Frameworks that imply architecture (event sourcing, CQRS, MediatR)
458. Map external system integrations
46
47### 1.3 Architecture Discovery
48
499. Identify deployable units (containers, services, workers, jobs)
5010. Identify data stores and their relationships
5111. Map API surface:
52 - REST endpoints (route definitions, controllers)
53 - gRPC services
54 - Message handlers / event consumers
5512. Identify domain model:
56 - Core entities / aggregates
57 - Domain events
58 - Value objects / specifications
59
60### 1.4 Git Archaeology — Project Evolution Timeline
61
62Reconstruct the project's history by mining git for architectural milestones,
63dependency changes, structural shifts, and key decisions over time.
64
65**13. Build the project timeline:**
66
67Run these commands to gather raw history:
68
69```bash
70# First commit — project birth
71git log --reverse --format="%ai %s" | head -1
72
73# Full commit history with dates, condensed
74git log --format="%ai %s" --all
75
76# File creation timeline — when were key files/directories first added?
77git log --diff-filter=A --format="%ai %H" --name-only -- \
78 "*.csproj" "*.sln" "package.json" "go.mod" "Cargo.toml" \
79 "Dockerfile" "docker-compose*" "*.bicep" "*.tf" \
80 "*.proto" ".github/workflows/*" "infra/*"
81
82# Dependency evolution — track package additions and removals over time
83git log --all -p -- "*.csproj" "package.json" "go.mod" "requirements.txt" \
84 | grep -E "^\+.*PackageReference|^\+.*\"dependencies\"|^\-.*PackageReference"
85
86# Directory structure evolution — when did major directories appear?
87git log --diff-filter=A --format="%ai" --name-only -- "*/" | head -200
88
89# Contributors over time
90git shortlog -sn --all
91```
92
93**14. Identify evolutionary phases:**
94
95Group the timeline into phases based on what changed:
96
97| Phase | Signals to look for |
98|-------|-------------------|
99| **Genesis** | First commit, initial project structure, core framework choices |
100| **Foundation** | Database setup, auth added, CI/CD pipeline created |
101| **Feature growth** | New domains/aggregates/endpoints added, dependency expansion |
102| **Refactors** | Renamed directories, moved files, replaced libraries |
103| **Infrastructure shifts** | New deployment targets, added monitoring, scaling changes |
104| **Migrations** | Framework upgrades, database migrations, API versioning |
105
106For each phase, note:
107- **When** it happened (date range)
108- **What** changed (key commits, files added/removed)
109- **Why** it likely happened (infer from commit messages, PR titles)
110- **Architectural impact** (did the system's shape change?)
111
112**15. Detect specific architectural events:**
113
114```bash
115# When were new projects/services added? (new .csproj = new deployable unit)
116git log --diff-filter=A --format="%ai %s" --name-only -- "*.csproj"
117
118# When did infrastructure change? (Bicep, Terraform, Docker)
119git log --format="%ai %s" -- "infra/*" "Dockerfile" "docker-compose*" "*.bicep" "*.tf"
120
121# When were major libraries swapped? (removed + added in same commit range)
122git log --all -p -- "*.csproj" | grep -E "^[\+\-].*PackageReference"
123
124# When did the API surface change significantly?
125git log --format="%ai %s" -- "**/Endpoints/**" "**/Controllers/**" "**/routes/**"
126
127# When were test projects added?
128git log --diff-filter=A --format="%ai %s" --name-only -- "*.Tests.csproj" "*.test.*" "jest.config*"
129
130# When did monitoring/observability arrive?
131git log --format="%ai %s" -- "**/dashboard*" "**/workbook*" "**/monitoring*" "appsettings*.json"
132```
133
134**16. Build the evolution summary:**
135
136```
137### Project Evolution Timeline
138
139**Created:** YYYY-MM-DD
140**Age:** N months
141**Commits:** N total, N contributors
142
143#### Phase 1: Genesis (YYYY-MM — YYYY-MM)
144- Initial project setup with [framework]
145- Core domain: [aggregates/entities created]
146- Key decision: [e.g., chose event sourcing over traditional CRUD]
147
148#### Phase 2: Foundation (YYYY-MM — YYYY-MM)
149- Added [auth, database, CI/CD]
150- Key decision: [e.g., Azure Container Apps over AKS]
151
152#### Phase 3: Growth (YYYY-MM — YYYY-MM)
153- Added [N] new features: [list]
154- Introduced [workers, background jobs, etc.]
155- Key decision: [e.g., added video processing pipeline]
156
157#### Phase 4: Maturation (YYYY-MM — present)
158- Refactored [what]
159- Replaced [old] with [new]
160- Added monitoring and observability
161
162#### Inferred Architectural Decisions
163| # | Decision | Detected from | Date | Confidence |
164|---|---------|--------------|------|-----------|
165| 1 | Use event sourcing | EventSourcing in .csproj | YYYY-MM | High |
166| 2 | Azure Container Apps | Bicep modules | YYYY-MM | High |
167| 3 | Replaced library X with Y | Package diff | YYYY-MM | Medium |
168| 4 | Added video processing | New project + pipeline | YYYY-MM | High |
169```
170
171**17. Run `git shortlog -sn --all | head -10`** — who are the main contributors?
172
173### 1.5 Present Analysis
174
17518. Present a summary of findings to the user, including the evolution timeline:
176
177```
178### Codebase Analysis
179
180**Project:** [name]
181**Tech stack:** [languages, frameworks]
182**Architecture:** [monolith/microservices/modular monolith]
183**Deployable units:** [list]
184**External systems:** [list]
185**Data stores:** [list]
186**Domain model:** [N aggregates, N events, etc.]
187**History:** [created YYYY-MM, N commits, N contributors]
188
189### Documentation Plan
190Based on analysis, I'll generate:
191- [ ] C4 System Context diagram (Level 1)
192- [ ] C4 Container diagram (Level 2)
193- [ ] C4 Component diagrams (Level 3) for [complex containers]
194- [ ] Project evolution timeline
195- [ ] ADRs for [N] inferred architectural decisions
196- [ ] Domain model reference
197- [ ] API endpoint reference
198- [ ] Developer onboarding guide
199- [ ] [Other docs based on what was found]
200
201Estimated docs: [N] files
202```
203
20418. **Wait for user approval** before generating
205
206## Phase 2: Architecture Diagrams
207
208Generate C4 diagrams using the viz-c4-diagram skill's Mermaid syntax.
209
210### 2.1 System Context (Level 1)
211
21219. Generate the C4 Context diagram showing:
213 - The system as a single box
214 - All users/personas (infer from auth, roles, UI routes)
215 - All external systems (from dependency analysis)
216 - Relationship labels with protocols
21720. Save to `<output>/architecture/system-context.md`
218
219### 2.2 Container Diagram (Level 2)
220
22121. Generate the C4 Container diagram showing:
222 - Each deployable unit (API, frontend, workers, jobs)
223 - Each data store
224 - Message queues / event buses
225 - Technology annotations on each container
22622. Save to `<output>/architecture/containers.md`
227
228### 2.3 Component Diagrams (Level 3)
229
23023. For each complex container (typically the main API), generate a component diagram:
231 - Endpoint groups / controllers
232 - Domain services
233 - Repositories / data access
234 - Event handlers
235 - External service clients
23624. Save to `<output>/architecture/components-[container].md`
237
238## Phase 3: Architecture Decision Records
239
240Mine ADRs from the codebase and git history.
241
242### 3.1 Infer Decisions
243
24425. For each major architectural choice found, draft an ADR:
245
246 **Always detectable:**
247 - Primary language/framework choice
248 - Database technology choice
249 - Hosting platform (from infra files)
250 - Authentication approach (from auth middleware/config)
251
252 **Often detectable:**
253 - Architecture pattern (event sourcing, CQRS, clean architecture)
254 - API style (REST, gRPC, GraphQL)
255 - Testing strategy (from test projects/frameworks)
256 - CI/CD approach (from pipeline files)
257 - Messaging/eventing choices
258
259 **Sometimes detectable (from git history):**
260 - Migration from one approach to another
261 - Library replacements
262 - Infrastructure changes
263
26426. For each inferred ADR:
265 - Read the template from `<templates>/adr.md`
266 - Fill in context based on what was found in code
267 - List the considered options as "inferred" (we can see what was chosen, but alternatives are educated guesses)
268 - Mark status as `Inferred — needs review`
269 - Number sequentially: `0001-[slug].md`
27027. Save to `<output>/adr/`
271
272### 3.2 ADR Quality Rules
273
274- **Be honest about uncertainty:** "Based on the codebase, this appears to be the decision. The alternatives listed are inferred, not confirmed."
275- **Don't invent rationale:** If you can't tell WHY a decision was made, say so. "Rationale unknown — confirm with the team."
276- **Focus on significant decisions:** Don't create an ADR for every library choice. Only for architectural-level decisions.
277
278## Phase 3b: Project Evolution Timeline
279
280Save the evolution timeline from Phase 1.4 as a standalone document.
281
28228. Generate `<output>/architecture/project-evolution.md` containing:
283 - Project birth date and age
284 - Phased timeline with dates, key changes, and architectural impact
285 - Inferred decisions table with confidence levels
286 - Dependency evolution (what was added, removed, replaced, and when)
287 - Contributor summary
288 - A Mermaid timeline diagram:
289
290```mermaid
291timeline
292 title Project Evolution
293 section Genesis
294 YYYY-MM : Initial project setup
295 : Core framework chosen
296 section Foundation
297 YYYY-MM : Auth added
298 : CI/CD pipeline
299 : Database setup
300 section Growth
301 YYYY-MM : Feature A
302 YYYY-MM : Feature B
303 : New service added
304 section Maturation
305 YYYY-MM : Monitoring added
306 : Library X replaced with Y
307```
308
309This document serves as the "story of the project" — useful for onboarding,
310understanding why things are the way they are, and deciding what to change next.
311
312## Phase 4: Domain Reference
313
31428. Generate a domain model reference document:
315 - List all aggregates/entities with their properties
316 - List all domain events (grouped by aggregate)
317 - List all specifications/validators
318 - List all value objects / strongly typed IDs
319 - Include a class diagram (Mermaid) for the domain model
32029. Save to `<output>/reference/domain-model.md`
321
322## Phase 5: API Reference
323
32430. Generate an API endpoint reference:
325 - Group endpoints by feature/resource
326 - List method, route, auth requirements
327 - Include request/response shapes if detectable
328 - Note which endpoints are public vs. authenticated
32931. Save to `<output>/reference/api-endpoints.md`
330
331## Phase 6: Developer Onboarding
332
33332. Generate a getting-started guide:
334 - Prerequisites (SDKs, tools, runtimes)
335 - How to clone and set up
336 - How to run locally (infer from project files, docker-compose, etc.)
337 - How to run tests
338 - Project structure overview
339 - Key conventions (from CLAUDE.md, code patterns)
34033. Save to `<output>/guides/getting-started.md`
341
342## Phase 7: Index & Summary
343
34434. Create or update `<output>/index.md` with links to all generated docs
34535. Create an ADR index at `<output>/adr/index.md`
34636. Present the final summary:
347
348```
349### Documentation Init Complete
350
351Generated [N] documents:
352
353#### Architecture ([N] files)
354- system-context.md — C4 Level 1
355- containers.md — C4 Level 2
356- components-api.md — C4 Level 3
357- project-evolution.md — Timeline of how the project evolved
358
359#### ADRs ([N] files)
360- 0001-[decision].md
361- 0002-[decision].md
362- ...
363
364#### Reference ([N] files)
365- domain-model.md
366- api-endpoints.md
367
368#### Guides ([N] files)
369- getting-started.md
370
371### Review Required
372All documents are marked as drafts. Review each one for:
373- [ ] Accuracy — correct any wrong assumptions
374- [ ] Completeness — add missing context you know
375- [ ] ADR rationale — fill in "why" for inferred decisions
376- [ ] Remove draft markers once reviewed
377```
378
379## Flags
380
381| Flag | Behavior |
382|------|----------|
383| `--full` | Run all phases (default) |
384| `--phase N` | Run only phase N (e.g., `--phase 2` for just architecture diagrams) |
385| `--dry-run` | Run phase 1 analysis only, show what would be generated |
386| `--skip-existing` | Don't regenerate docs that already exist |
387
388## Draft Markers
389
390Every generated document gets this banner at the top:
391
392```markdown
393> **DRAFT** — Auto-generated from codebase analysis on [date].
394> Review for accuracy before removing this banner.
395```
396
397## Anti-Pattern Guards
398
399- **Don't over-document the obvious**: Skip generating doc comments for self-explanatory code
400- **Don't invent rationale**: If you can't determine WHY, mark it as "needs team input"
401- **Don't generate once and forget**: This skill generates drafts; the doc-* skills maintain them
402- **Don't skip the review step**: Always present the analysis (Phase 1) before generating
403- **Don't duplicate existing docs**: Check for existing documentation first and note it