@vpxa/aikit 0.1.65 → 0.1.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/package.json +1 -1
  2. package/packages/cli/dist/constants-D93JHBiN.js +1 -0
  3. package/packages/cli/dist/index.js +3 -3
  4. package/packages/cli/dist/{init-DBo2fDoM.js → init-DANkCO2c.js} +1 -1
  5. package/packages/cli/dist/{user-CXIL0rVI.js → user-Bb99C6xW.js} +1 -1
  6. package/scaffold/flows/_epilogue/steps/docs-sync/README.md +119 -119
  7. package/scaffold/flows/aikit-advanced/steps/design/README.md +16 -2
  8. package/scaffold/flows/aikit-advanced/steps/execute/README.md +3 -1
  9. package/scaffold/flows/aikit-advanced/steps/plan/README.md +3 -1
  10. package/scaffold/flows/aikit-advanced/steps/spec/README.md +3 -1
  11. package/scaffold/flows/aikit-advanced/steps/task/README.md +3 -1
  12. package/scaffold/flows/aikit-advanced/steps/verify/README.md +3 -1
  13. package/scaffold/flows/aikit-basic/steps/assess/README.md +3 -1
  14. package/scaffold/flows/aikit-basic/steps/design/README.md +12 -3
  15. package/scaffold/flows/aikit-basic/steps/implement/README.md +3 -1
  16. package/scaffold/flows/aikit-basic/steps/verify/README.md +3 -1
  17. package/scaffold/general/skills/docs/SKILL.md +508 -508
  18. package/scaffold/general/skills/docs/references/diataxis-anti-patterns.md +146 -146
  19. package/scaffold/general/skills/docs/references/diataxis-compass.md +122 -122
  20. package/scaffold/general/skills/docs/references/diataxis-quadrants.md +191 -191
  21. package/scaffold/general/skills/docs/references/diataxis-quality.md +75 -75
  22. package/scaffold/general/skills/docs/references/diataxis-templates.md +119 -119
  23. package/scaffold/general/skills/docs/references/flow-artifacts-guide.md +69 -69
  24. package/scaffold/general/skills/docs/references/project-knowledge-gotchas.md +31 -31
  25. package/scaffold/general/skills/docs/references/project-knowledge-templates.md +280 -280
  26. package/scaffold/general/skills/docs/references/project-knowledge-workflow.md +79 -79
  27. package/packages/cli/dist/constants-BjDyZo-l.js +0 -1
@@ -1,509 +1,509 @@
1
- ---
2
- name: docs
3
- description: "Living documentation management — Diátaxis framework, docs/ convention, create/update rules, staleness detection, integration with adr-skill and c4-architecture."
4
- metadata:
5
- category: cross-cutting
6
- domain: general
7
- applicability: on-demand
8
- inputs: [code-changes, flow-artifacts, architecture]
9
- outputs: [documentation]
10
- relatedSkills: [adr-skill, c4-architecture]
11
- internal: true
12
- ---
13
-
14
- # Docs — Living Documentation Skill
15
-
16
- Manage the `docs/` folder as a single source of truth for project documentation. This skill runs during the mandatory `_docs-sync` epilogue step of every flow, ensuring documentation stays in sync with code changes.
17
-
18
- ## Principles
19
-
20
- 1. **Living, not legacy** — Documentation is updated as code changes, never as a separate "docs sprint"
21
- 2. **One source of truth** — Never duplicate what's in code comments, READMEs, or inline JSDoc
22
- 3. **Diátaxis framework** — Organize docs into four categories using the two-question compass:
23
- - **Q1**: Is the reader trying to **do** something (action) or **understand** something (cognition)?
24
- - **Q2**: Is the reader **learning** (study) or **working** (work)?
25
- - Action+Study → Tutorial · Action+Work → How-to · Cognition+Work → Reference · Cognition+Study → Explanation
26
- - See [references/diataxis-compass.md](references/diataxis-compass.md) for the full classification system
27
- 4. **Minimal but complete** — Create docs only when they add value beyond what code communicates
28
- 5. **Delegate to specialists** — Architecture diagrams → `c4-architecture` skill. Decision records → `adr-skill`
29
-
30
- ## Documentation Modes
31
-
32
- This skill operates in two modes, often combined:
33
-
34
- ### Source-Only Mode
35
- Generate documentation from code analysis alone. Used when:
36
- - Bootstrapping `docs/` for the first time (`produce_knowledge`, `analyze_*` tools)
37
- - Running outside a flow context (manual documentation refresh)
38
- - Flow produced no artifacts (auto-skipped design step)
39
-
40
- ### Flow-Aware Mode (Primary)
41
- Generate documentation from code changes **plus** flow artifacts. This is the primary mode during `_docs-sync` because every completed flow produces structured artifacts containing design decisions, requirements, and verification results.
42
-
43
- Flow artifacts are the most valuable documentation input — they capture the *why* behind changes (decisions, constraints, trade-offs, risks) while code only shows the *what*.
44
-
45
- **Artifact reading sequence:**
46
- ```
47
- flow_status() # Get artifactsPath
48
- find({ pattern: "*.md", path: "<artifactsPath>" }) # Discover all artifacts
49
- digest({ sources: [ # Compress into working context
50
- { path: "<found-artifact-1>" },
51
- { path: "<found-artifact-2>" },
52
- ...
53
- ]})
54
- ```
55
-
56
- See [references/flow-artifacts-guide.md](references/flow-artifacts-guide.md) for the artifact catalog and artifact-to-documentation mapping.
57
-
58
- ## AI Kit Tools for Documentation
59
-
60
- Use these existing AI Kit tools to generate documentation content — never write docs from scratch when a tool can provide the foundation:
61
-
62
- | Documentation Task | AI Kit Tool | What It Provides |
63
- |---|---|---|
64
- | Project overview | `produce_knowledge({ path: "." })` | Comprehensive analysis: structure, patterns, dependencies → `docs/README.md` |
65
- | Architecture overview | `analyze_structure({ path: "." })` | File tree, package layout, layer organization → `docs/architecture/overview.md` |
66
- | Architecture diagrams | `analyze_diagram({ path: "." })` | Mermaid diagrams of component relationships → `docs/architecture/` |
67
- | Dependency map | `analyze_dependencies({ path: "." })` | Import graph, cross-package edges → `docs/architecture/overview.md` dependencies section |
68
- | Component analysis | `analyze_symbols({ path: "src/component" })` | Exports, classes, interfaces → `docs/architecture/components/{name}.md` |
69
- | Entry points / API surface | `analyze_entry_points({ path: "." })` | CLI bins, route handlers, main exports → `docs/reference/api.md` |
70
- | Code patterns | `analyze_patterns({ path: "." })` | Design patterns, conventions → `docs/architecture/overview.md` patterns section |
71
- | Impact analysis | `blast_radius({ changed_files: [...] })` | What's affected by changes → targeted doc updates |
72
- | Change detection | `git_context({})` | Recent changes, diff summary → determine which docs need updating |
73
- | Module graph | `graph({ action: 'neighbors', node_id })` | Who-imports-whom, cross-package dependencies → architecture diagrams |
74
- | Full audit | `audit({ path: "." })` | Structure + deps + patterns + health + dead symbols → comprehensive docs refresh |
75
-
76
- ### Tool-First Workflow
77
-
78
- When creating documentation, always start with tool output, then enhance with human context:
79
-
80
- ```
81
- 1. Run the relevant analysis tool(s)
82
- 2. Use the output as the doc's foundation
83
- 3. Add: purpose/motivation (why, not just what)
84
- 4. Add: decision context (link to ADRs)
85
- 5. Add: cross-references to related docs
86
- 6. Remove: implementation details visible in code
87
- ```
88
-
89
- ## `docs/` Convention
90
-
91
- ```
92
- docs/
93
- ├── README.md ← Project overview + docs index (always exists)
94
- ├── architecture/
95
- │ ├── overview.md ← C4 context + container diagrams (c4-architecture skill)
96
- │ ├── stack.md ← Language, runtime, frameworks, all dependencies
97
- │ ├── structure.md ← Directory layout, entry points, key files
98
- │ ├── design.md ← Layers, patterns, data flow
99
- │ ├── conventions.md ← Naming, formatting, error handling, imports
100
- │ ├── integrations.md ← External APIs, databases, auth, monitoring
101
- │ ├── testing.md ← Frameworks, file organization, mocking strategy
102
- │ ├── concerns.md ← Tech debt, bugs, security risks, perf bottlenecks
103
- │ └── components/
104
- │ └── {component-name}.md ← Per-component technical docs
105
- ├── decisions/ ← Architecture Decision Records (adr-skill)
106
- │ ├── index.md ← ADR log / table of contents
107
- │ └── NNN-{title}.md ← Individual ADRs
108
- ├── guides/
109
- │ ├── tutorials/ ← Learning-oriented lessons (Diátaxis: Tutorial)
110
- │ │ └── {topic}.md
111
- │ └── {topic}.md ← How-to guides for common tasks (Diátaxis: How-To)
112
- └── reference/
113
- ├── api.md ← API reference (endpoints, schemas, auth)
114
- └── configuration.md ← Configuration options and environment variables
115
- ```
116
-
117
- ### Directory Purposes
118
-
119
- | Directory | Diátaxis Quadrant | What Goes Here | When to Create/Update |
120
- |-----------|-------------------|----------------|----------------------|
121
- | `architecture/` | Explanation + Reference | C4 diagrams, project knowledge (stack, structure, design, conventions, integrations, testing, concerns), component docs | Initial onboarding, new component, structural change, architecture decision |
122
- | `decisions/` | Explanation | ADRs — why decisions were made | Non-trivial technical decision (see adr-skill triggers) |
123
- | `guides/` | How-To | Step-by-step instructions for tasks | New workflow, complex setup, common operations |
124
- | `guides/tutorials/` | Tutorial | Learning-oriented guided lessons with concrete outcomes | New technology/feature adoption, onboarding new developers |
125
- | `reference/` | Reference | API docs, config options, data schemas | API change, new config option, schema modification |
126
-
127
- ## Change-to-Doc Mapping
128
-
129
- Use this decision tree to determine what documentation action to take after a flow completes:
130
-
131
- ```
132
- What changed?
133
- ├── New component/module/package
134
- │ ├── Creates public API? → Create docs/architecture/components/{name}.md + update reference/api.md
135
- │ └── Internal only? → Update docs/architecture/overview.md (component list)
136
- ├── API change (new endpoint, changed contract, new config)
137
- │ └── Update docs/reference/api.md or docs/reference/configuration.md
138
- ├── Architecture/infrastructure decision
139
- │ └── Delegate to adr-skill → creates/updates docs/decisions/NNN-{title}.md
140
- ├── Structural/architecture change
141
- │ └── Delegate to c4-architecture skill → updates docs/architecture/overview.md
142
- ├── New developer workflow (build, deploy, test pattern)
143
- │ └── Create or update docs/guides/{topic}.md
144
- ├── Bug fix
145
- │ ├── Reveals missing docs? → Create the missing doc
146
- │ └── Straightforward fix? → No docs update needed
147
- └── Dependency update / refactor / cleanup
148
- └── No docs update needed (unless public API changed)
149
- ```
150
-
151
- ### Classify by Diátaxis Quadrant
152
-
153
- After determining the documentation action, classify the target document's quadrant:
154
-
155
- | Action → Cognition? | Study → Work? | Quadrant | Target Directory |
156
- |---------------------|---------------|----------|------------------|
157
- | Action (doing) | Study (learning) | **Tutorial** | `guides/tutorials/` |
158
- | Action (doing) | Work (applying) | **How-To** | `guides/` |
159
- | Cognition (understanding) | Work (using) | **Reference** | `reference/` |
160
- | Cognition (understanding) | Study (grasping) | **Explanation** | `architecture/`, `decisions/` |
161
-
162
- Use the [Diátaxis Compass](references/diataxis-compass.md) for edge cases and ambiguous content.
163
-
164
- ## Templates
165
-
166
- ### Component Doc Template (`docs/architecture/components/{name}.md`)
167
-
168
- ```markdown
169
- # {Component Name}
170
-
171
- ## Purpose
172
- One-paragraph description of what this component does and why it exists.
173
-
174
- ## Architecture
175
- - **Location**: `src/{path}/`
176
- - **Entry point**: `{file}`
177
- - **Key dependencies**: {list}
178
-
179
- ## Public API
180
- Brief description of the component's public interface.
181
-
182
- ## Design Decisions
183
- - Link to relevant ADRs: [ADR-NNN](../../decisions/NNN-{title}.md)
184
-
185
- ## Data Flow
186
- How data enters, transforms through, and exits this component.
187
- ```
188
-
189
- ### Guide Template (`docs/guides/{topic}.md`)
190
-
191
- ```markdown
192
- # How to {Task}
193
-
194
- ## Prerequisites
195
- What you need before starting.
196
-
197
- ## Steps
198
- 1. Step one
199
- 2. Step two
200
- 3. Step three
201
-
202
- ## Verification
203
- How to confirm it worked.
204
-
205
- ## Troubleshooting
206
- Common issues and solutions.
207
- ```
208
-
209
- ### Reference Template (`docs/reference/{topic}.md`)
210
-
211
- ```markdown
212
- # {Topic} Reference
213
-
214
- ## Overview
215
- Brief description of what this reference covers.
216
-
217
- ## {Section}
218
-
219
- | Item | Type | Default | Description |
220
- |------|------|---------|-------------|
221
- | ... | ... | ... | ... |
222
- ```
223
-
224
- > **Tutorial and Explanation templates**: For the remaining two Diátaxis quadrants, see [references/diataxis-templates.md](references/diataxis-templates.md).
225
-
226
- ## Integration with Other Skills
227
-
228
- ### `adr-skill` Integration
229
- - All ADRs live in `docs/decisions/`
230
- - When the docs-sync step detects an architecture decision was made during the flow, delegate to `adr-skill`
231
- - After `adr-skill` creates/updates an ADR, update `docs/decisions/index.md`
232
- - Cross-reference ADRs from component docs where relevant
233
-
234
- ### `c4-architecture` Integration
235
- - Architecture diagrams live in `docs/architecture/`
236
- - When the docs-sync step detects structural changes (new packages, changed boundaries), delegate to `c4-architecture`
237
- - Use Mermaid format for docs files (not HTML) — markdown renders in GitHub
238
- - Reference diagrams from component docs
239
-
240
- ## Project Knowledge Acquisition
241
-
242
- Produces seven populated documents in `docs/architecture/` covering everything needed to work effectively on the project — stack, structure, design, conventions, integrations, testing, and concerns.
243
-
244
- **Only document what is verifiable from files or tool output — never infer or assume.**
245
-
246
- ### Output Contract
247
-
248
- All of the following must be true before finishing:
249
-
250
- 1. All seven files exist in `docs/architecture/`: `stack.md`, `structure.md`, `design.md`, `conventions.md`, `integrations.md`, `testing.md`, `concerns.md`
251
- 2. Every claim is traceable to source files, config, or AI Kit tool output
252
- 3. Unknowns are marked `[TODO]`; intent-dependent decisions are marked `[ASK USER]`
253
- 4. Every document includes a short "Evidence" section with file paths or tool receipts
254
- 5. Final response includes numbered `[ASK USER]` questions and intent-vs-reality divergences
255
-
256
- ### Documents
257
-
258
- | Document | Covers | Primary Tools |
259
- |----------|--------|---------------|
260
- | `stack.md` | Language, runtime, frameworks, dependencies, dev tooling | `analyze_dependencies`, `analyze_structure` |
261
- | `structure.md` | Directory layout, entry points, key files, packages | `analyze_structure`, `analyze_entry_points` |
262
- | `design.md` | Layers, patterns, data flow, component boundaries | `analyze_structure`, `analyze_patterns`, `analyze_diagram` |
263
- | `conventions.md` | Naming, formatting, error handling, import conventions | `analyze_patterns`, `search("conventions")` |
264
- | `integrations.md` | External APIs, databases, auth, monitoring, CI/CD | `analyze_dependencies`, `search("API\|database\|auth")` |
265
- | `testing.md` | Test frameworks, file organization, mocking, coverage | `analyze_patterns`, `test_run({})`, `search("test")` |
266
- | `concerns.md` | Tech debt, bugs, security risks, perf, high-churn files | `audit()`, `dead_symbols()`, `git_context()` |
267
-
268
- Use [references/project-knowledge-templates.md](references/project-knowledge-templates.md) for the standard template of each document.
269
-
270
- ### Workflow & References
271
-
272
- Follow the four-phase workflow: **Scan → Investigate → Populate → Validate**.
273
-
274
- - [references/project-knowledge-workflow.md](references/project-knowledge-workflow.md) — Full 4-phase workflow, investigation tools per document, population rules, focus area mode
275
- - [references/project-knowledge-gotchas.md](references/project-knowledge-gotchas.md) — Environment gotchas and anti-pattern table
276
-
277
- ## Architecture Blueprint Generation
278
-
279
- When bootstrapping `docs/` for the first time or refreshing architecture documentation, generate a comprehensive architecture blueprint. This replaces manual documentation with tool-driven analysis.
280
-
281
- ### Blueprint Workflow
282
-
283
- ```
284
- Step 1: Detect & Analyze
285
- analyze_structure({ path: "." }) → project layout, packages, layers
286
- analyze_patterns({ path: "." }) → conventions, design patterns
287
- analyze_entry_points({ path: "." }) → API surface, CLI entry points
288
-
289
- Step 2: Map Dependencies
290
- analyze_dependencies({ path: "." }) → import graph, cross-package edges
291
- graph({ action: 'find_nodes', name_pattern: '*' }) → module graph nodes
292
- graph({ action: 'neighbors', node_id: '...' }) → dependency directions
293
-
294
- Step 3: Visualize
295
- analyze_diagram({ path: "." }) → Mermaid architecture diagrams
296
- Delegate to c4-architecture skill → C4 context/container/component views
297
-
298
- Step 4: Synthesize
299
- produce_knowledge({ path: "." }) → comprehensive analysis
300
- Combine outputs into docs/ structure
301
- ```
302
-
303
- ### Blueprint Sections
304
-
305
- The architecture blueprint should cover these areas (adapted from the Architecture Blueprint Generator pattern):
306
-
307
- #### 1. Architecture Detection & Analysis
308
- - **Auto-detect**: Project type, framework, architectural pattern (Clean Architecture, Microservices, Layered, etc.)
309
- - **Tools**: `analyze_structure` → folder organization, `analyze_patterns` → framework detection, `analyze_dependencies` → dependency flow
310
- - **Output**: `docs/architecture/overview.md` header section
311
-
312
- #### 2. Architectural Overview
313
- - Guiding principles from code structure
314
- - Architectural boundaries and enforcement mechanisms
315
- - Hybrid patterns or adaptations
316
- - **Tools**: `produce_knowledge` + `analyze_structure`
317
- - **Output**: `docs/architecture/overview.md` main body
318
-
319
- #### 3. Architecture Visualization
320
- - High-level subsystem diagram
321
- - Component interaction diagrams
322
- - Data flow diagrams
323
- - **Tools**: `analyze_diagram` + `c4-architecture` skill
324
- - **Output**: `docs/architecture/overview.md` diagrams + `docs/architecture/diagrams/`
325
-
326
- #### 4. Core Architectural Components
327
- For each major component:
328
- - Purpose and responsibility
329
- - Internal structure
330
- - Key abstractions
331
- - Interaction patterns
332
- - **Tools**: `analyze_symbols({ path: "component/" })` + `compact({ path, query: "exports" })`
333
- - **Output**: `docs/architecture/components/{name}.md`
334
-
335
- #### 5. Layers & Dependencies
336
- - Layer structure as implemented
337
- - Dependency rules between layers
338
- - Abstraction mechanisms for separation
339
- - Circular dependencies or violations
340
- - **Tools**: `analyze_dependencies` + `graph({ action: 'neighbors' })`
341
- - **Output**: `docs/architecture/overview.md` layers section
342
-
343
- #### 6. Cross-Cutting Concerns
344
- Document implementation patterns for:
345
- - Error handling & resilience
346
- - Logging & observability
347
- - Validation patterns
348
- - Configuration management
349
- - **Tools**: `analyze_patterns` + `search({ query: "error handling" })`
350
- - **Output**: `docs/architecture/overview.md` cross-cutting section
351
-
352
- #### 7. Testing Architecture
353
- - Test framework and strategy
354
- - Test boundary patterns (unit, integration, e2e)
355
- - Test file conventions
356
- - **Tools**: `analyze_patterns` + `search({ query: "test" })`
357
- - **Output**: `docs/guides/testing.md`
358
-
359
- #### 8. Extension & Evolution
360
- - How to add features while preserving architecture
361
- - Component creation patterns
362
- - Integration patterns for external systems
363
- - **Tools**: `analyze_entry_points` + `analyze_patterns`
364
- - **Output**: `docs/guides/contributing.md` or `docs/architecture/overview.md` extension section
365
-
366
- ## Rules for the `_docs-sync` Epilogue Step
367
-
368
- When this skill is loaded during the `_docs-sync` epilogue:
369
-
370
- ### 0. Gather Flow Artifacts
371
-
372
- Read all available artifacts from the completed flow before assessing code changes:
373
-
374
- ```
375
- flow_status() # Get artifactsPath, topic, phase
376
- find({ pattern: "*.md", path: "<artifactsPath>" }) # Discover all flow artifacts
377
- digest({ sources: [ # Compress artifacts for context
378
- { path: "<found-artifact-1>" },
379
- { path: "<found-artifact-2>" },
380
- ...
381
- ]})
382
- ```
383
-
384
- Map each discovered artifact to documentation actions using [references/flow-artifacts-guide.md](references/flow-artifacts-guide.md).
385
-
386
- Read every artifact `find()` returns — different flows produce different files. Focus on artifacts that contain decisions, requirements, and verification results; skip artifacts that only repeat completed work.
387
-
388
- If `flow_status()` returns no active flow or no artifacts directory exists, skip this step (source-only mode).
389
-
390
- ### 1. Assess Changes (tool-driven)
391
-
392
- ```
393
- git_context({}) # What changed in this flow
394
- blast_radius({ changed_files: ["changed-files"] }) # Impact analysis
395
- ```
396
-
397
- Use the output to classify changes against the Change-to-Doc Mapping decision tree.
398
-
399
- ### 1b. Classify Target Quadrant
400
-
401
- For each doc action identified in Step 1, determine the Diátaxis quadrant:
402
-
403
- 1. Ask: **Action or Cognition?** Is the reader doing something or understanding something?
404
- 2. Ask: **Study or Work?** Is the reader learning or applying?
405
- 3. Match the answer pair to a quadrant → pick the target directory
406
- 4. If ambiguous → consult [references/diataxis-compass.md](references/diataxis-compass.md) for edge cases
407
-
408
- Run the [quality checklist](references/diataxis-quality.md) against any doc created or substantially modified.
409
-
410
- ### 2. Apply the Mapping
411
-
412
- Follow the Change-to-Doc Mapping decision tree above to determine required documentation actions.
413
-
414
- ### 3. Bootstrap `docs/` If Needed (tool-driven)
415
-
416
- If `docs/` doesn't exist, run the full Architecture Blueprint workflow:
417
-
418
- ```
419
- # Generate content with tools
420
- produce_knowledge({ path: "." }) # → docs/README.md foundation
421
- analyze_structure({ path: "." }) # → docs/architecture/overview.md structure section
422
- analyze_diagram({ path: "." }) # → docs/architecture/ Mermaid diagrams
423
- analyze_dependencies({ path: "." }) # → docs/architecture/overview.md dependency section
424
- analyze_entry_points({ path: "." }) # → docs/reference/api.md foundation
425
- analyze_patterns({ path: "." }) # → docs/architecture/overview.md patterns section
426
-
427
- # Create the docs/ tree
428
- docs/
429
- ├── README.md ← From produce_knowledge output + project context
430
- ├── architecture/
431
- │ ├── overview.md ← From analyze_structure + analyze_dependencies + analyze_diagram
432
- │ └── components/ ← From analyze_symbols per major component
433
- ├── decisions/
434
- │ └── index.md ← ADR log (delegate to adr-skill)
435
- ├── guides/
436
- │ └── testing.md ← From analyze_patterns test info
437
- └── reference/
438
- └── api.md ← From analyze_entry_points
439
- ```
440
-
441
- ### 4. Update Existing Docs (tool-assisted)
442
-
443
- - Use `compact({ path: "docs/existing.md", query: "section to update" })` to read the current section
444
- - Use `blast_radius` output to identify which sections need updating
445
- - **Don't rewrite** — update relevant sections, preserve existing content
446
- - **Don't duplicate** — reference code comments/READMEs instead of copying
447
-
448
- ### 5. Delegate When Appropriate
449
-
450
- - Architecture decisions → `adr-skill` → `docs/decisions/`
451
- - Architecture diagrams → `c4-architecture` skill → `docs/architecture/`
452
- - Blueprint refresh → Run Blueprint Workflow above
453
-
454
- ### 6. Update the Index
455
-
456
- If docs were added/removed, update `docs/README.md` index.
457
-
458
- ### 7. Skip If Nothing Changed
459
-
460
- If the flow's changes don't warrant doc updates (e.g., pure bug fix with no revelations), report "No documentation updates needed" and move on.
461
-
462
- ## Writing Style
463
-
464
- Follow these rules when generating documentation content. Adapted from *The Elements of Agent Style* (CC BY 4.0, Yue Zhao) and classic writing authorities.
465
-
466
- ### Clarity and Precision
467
- - **Concrete over abstract** — Use specific terms, not vague language ("the retry handler" not "the relevant component")
468
- - **No needless words** — Cut filler; every sentence earns its place
469
- - **Active voice when the agent matters** — "The scheduler retries failed jobs" not "Failed jobs are retried"
470
- - **Affirmative form** — State what something does, not what it does not do (unless a warning)
471
- - **Claims match evidence** — Do not overstate or understate; back factual claims with file paths or tool output
472
-
473
- ### Structure
474
- - **Parallel structure** — Express coordinate ideas in similar form (consistent table columns, consistent list grammar)
475
- - **Stress position** — Place the important information at the end of the sentence
476
- - **Sentence variety** — Break sentences over 30 words; vary length to maintain rhythm
477
- - **Bullets only for genuine lists** — Do not convert flowing prose into bullet points; two items or a sentence do not need bullets
478
-
479
- ### AI-Tell Avoidance
480
- - **No dying metaphors** — Avoid "cutting-edge", "leverages", "streamlines", "robust", "seamless"
481
- - **No transition-word openers** — Do not start paragraphs with "Additionally", "Furthermore", "Moreover"
482
- - **No em-dash overuse** — Use commas, semicolons, or separate sentences instead
483
- - **No summary closers** — Do not end every paragraph by restating what it just said
484
- - **Consistent terminology** — Pick one term and use it throughout; do not alternate synonyms for variety
485
-
486
- ## Anti-Patterns
487
-
488
- ### Documentation Maintenance
489
- - ❌ Documenting implementation details that are obvious from code
490
- - ❌ Creating docs for every small change (use the mapping tree)
491
- - ❌ Duplicating information already in code comments or README files
492
- - ❌ Writing docs that will be immediately outdated (e.g., exact version numbers)
493
- - ❌ Creating empty placeholder docs "for later"
494
- - ❌ Rewriting existing docs from scratch instead of updating sections
495
-
496
- ### Quadrant Mixing (Diátaxis)
497
- - ❌ **Tutorial with Explanation** — conceptual paragraphs between steps → extract "why" to Explanation doc, link from tutorial
498
- - ❌ **How-To that Teaches** — "Let's learn..." framing in a task guide → assume competence, link prerequisites
499
- - ❌ **Reference with Narrative** — opinions in API tables ("I recommend...") → strip opinions to Explanation doc
500
- - ❌ **Explanation with Procedures** — numbered steps in a conceptual doc → move procedures to How-To
501
- - ❌ **Mixed-Mode Document** — one doc serving multiple quadrants → split into separate documents per quadrant
502
- - See [references/diataxis-anti-patterns.md](references/diataxis-anti-patterns.md) for detection signals, counterexamples, and blur zones
503
-
504
- ### Project Knowledge
505
- - See [references/project-knowledge-gotchas.md](references/project-knowledge-gotchas.md) for environment gotchas and anti-pattern table
506
-
507
- ---
508
-
1
+ ---
2
+ name: docs
3
+ description: "Living documentation management — Diátaxis framework, docs/ convention, create/update rules, staleness detection, integration with adr-skill and c4-architecture."
4
+ metadata:
5
+ category: cross-cutting
6
+ domain: general
7
+ applicability: on-demand
8
+ inputs: [code-changes, flow-artifacts, architecture]
9
+ outputs: [documentation]
10
+ relatedSkills: [adr-skill, c4-architecture]
11
+ internal: true
12
+ ---
13
+
14
+ # Docs — Living Documentation Skill
15
+
16
+ Manage the `docs/` folder as a single source of truth for project documentation. This skill runs during the mandatory `_docs-sync` epilogue step of every flow, ensuring documentation stays in sync with code changes.
17
+
18
+ ## Principles
19
+
20
+ 1. **Living, not legacy** — Documentation is updated as code changes, never as a separate "docs sprint"
21
+ 2. **One source of truth** — Never duplicate what's in code comments, READMEs, or inline JSDoc
22
+ 3. **Diátaxis framework** — Organize docs into four categories using the two-question compass:
23
+ - **Q1**: Is the reader trying to **do** something (action) or **understand** something (cognition)?
24
+ - **Q2**: Is the reader **learning** (study) or **working** (work)?
25
+ - Action+Study → Tutorial · Action+Work → How-to · Cognition+Work → Reference · Cognition+Study → Explanation
26
+ - See [references/diataxis-compass.md](references/diataxis-compass.md) for the full classification system
27
+ 4. **Minimal but complete** — Create docs only when they add value beyond what code communicates
28
+ 5. **Delegate to specialists** — Architecture diagrams → `c4-architecture` skill. Decision records → `adr-skill`
29
+
30
+ ## Documentation Modes
31
+
32
+ This skill operates in two modes, often combined:
33
+
34
+ ### Source-Only Mode
35
+ Generate documentation from code analysis alone. Used when:
36
+ - Bootstrapping `docs/` for the first time (`produce_knowledge`, `analyze_*` tools)
37
+ - Running outside a flow context (manual documentation refresh)
38
+ - Flow produced no artifacts (auto-skipped design step)
39
+
40
+ ### Flow-Aware Mode (Primary)
41
+ Generate documentation from code changes **plus** flow artifacts. This is the primary mode during `_docs-sync` because every completed flow produces structured artifacts containing design decisions, requirements, and verification results.
42
+
43
+ Flow artifacts are the most valuable documentation input — they capture the *why* behind changes (decisions, constraints, trade-offs, risks) while code only shows the *what*.
44
+
45
+ **Artifact reading sequence:**
46
+ ```
47
+ flow_status() # Get artifactsPath
48
+ find({ pattern: "*.md", path: "<artifactsPath>" }) # Discover all artifacts
49
+ digest({ sources: [ # Compress into working context
50
+ { path: "<found-artifact-1>" },
51
+ { path: "<found-artifact-2>" },
52
+ ...
53
+ ]})
54
+ ```
55
+
56
+ See [references/flow-artifacts-guide.md](references/flow-artifacts-guide.md) for the artifact catalog and artifact-to-documentation mapping.
57
+
58
+ ## AI Kit Tools for Documentation
59
+
60
+ Use these existing AI Kit tools to generate documentation content — never write docs from scratch when a tool can provide the foundation:
61
+
62
+ | Documentation Task | AI Kit Tool | What It Provides |
63
+ |---|---|---|
64
+ | Project overview | `produce_knowledge({ path: "." })` | Comprehensive analysis: structure, patterns, dependencies → `docs/README.md` |
65
+ | Architecture overview | `analyze_structure({ path: "." })` | File tree, package layout, layer organization → `docs/architecture/overview.md` |
66
+ | Architecture diagrams | `analyze_diagram({ path: "." })` | Mermaid diagrams of component relationships → `docs/architecture/` |
67
+ | Dependency map | `analyze_dependencies({ path: "." })` | Import graph, cross-package edges → `docs/architecture/overview.md` dependencies section |
68
+ | Component analysis | `analyze_symbols({ path: "src/component" })` | Exports, classes, interfaces → `docs/architecture/components/{name}.md` |
69
+ | Entry points / API surface | `analyze_entry_points({ path: "." })` | CLI bins, route handlers, main exports → `docs/reference/api.md` |
70
+ | Code patterns | `analyze_patterns({ path: "." })` | Design patterns, conventions → `docs/architecture/overview.md` patterns section |
71
+ | Impact analysis | `blast_radius({ changed_files: [...] })` | What's affected by changes → targeted doc updates |
72
+ | Change detection | `git_context({})` | Recent changes, diff summary → determine which docs need updating |
73
+ | Module graph | `graph({ action: 'neighbors', node_id })` | Who-imports-whom, cross-package dependencies → architecture diagrams |
74
+ | Full audit | `audit({ path: "." })` | Structure + deps + patterns + health + dead symbols → comprehensive docs refresh |
75
+
76
+ ### Tool-First Workflow
77
+
78
+ When creating documentation, always start with tool output, then enhance with human context:
79
+
80
+ ```
81
+ 1. Run the relevant analysis tool(s)
82
+ 2. Use the output as the doc's foundation
83
+ 3. Add: purpose/motivation (why, not just what)
84
+ 4. Add: decision context (link to ADRs)
85
+ 5. Add: cross-references to related docs
86
+ 6. Remove: implementation details visible in code
87
+ ```
88
+
89
+ ## `docs/` Convention
90
+
91
+ ```
92
+ docs/
93
+ ├── README.md ← Project overview + docs index (always exists)
94
+ ├── architecture/
95
+ │ ├── overview.md ← C4 context + container diagrams (c4-architecture skill)
96
+ │ ├── stack.md ← Language, runtime, frameworks, all dependencies
97
+ │ ├── structure.md ← Directory layout, entry points, key files
98
+ │ ├── design.md ← Layers, patterns, data flow
99
+ │ ├── conventions.md ← Naming, formatting, error handling, imports
100
+ │ ├── integrations.md ← External APIs, databases, auth, monitoring
101
+ │ ├── testing.md ← Frameworks, file organization, mocking strategy
102
+ │ ├── concerns.md ← Tech debt, bugs, security risks, perf bottlenecks
103
+ │ └── components/
104
+ │ └── {component-name}.md ← Per-component technical docs
105
+ ├── decisions/ ← Architecture Decision Records (adr-skill)
106
+ │ ├── index.md ← ADR log / table of contents
107
+ │ └── NNN-{title}.md ← Individual ADRs
108
+ ├── guides/
109
+ │ ├── tutorials/ ← Learning-oriented lessons (Diátaxis: Tutorial)
110
+ │ │ └── {topic}.md
111
+ │ └── {topic}.md ← How-to guides for common tasks (Diátaxis: How-To)
112
+ └── reference/
113
+ ├── api.md ← API reference (endpoints, schemas, auth)
114
+ └── configuration.md ← Configuration options and environment variables
115
+ ```
116
+
117
+ ### Directory Purposes
118
+
119
+ | Directory | Diátaxis Quadrant | What Goes Here | When to Create/Update |
120
+ |-----------|-------------------|----------------|----------------------|
121
+ | `architecture/` | Explanation + Reference | C4 diagrams, project knowledge (stack, structure, design, conventions, integrations, testing, concerns), component docs | Initial onboarding, new component, structural change, architecture decision |
122
+ | `decisions/` | Explanation | ADRs — why decisions were made | Non-trivial technical decision (see adr-skill triggers) |
123
+ | `guides/` | How-To | Step-by-step instructions for tasks | New workflow, complex setup, common operations |
124
+ | `guides/tutorials/` | Tutorial | Learning-oriented guided lessons with concrete outcomes | New technology/feature adoption, onboarding new developers |
125
+ | `reference/` | Reference | API docs, config options, data schemas | API change, new config option, schema modification |
126
+
127
+ ## Change-to-Doc Mapping
128
+
129
+ Use this decision tree to determine what documentation action to take after a flow completes:
130
+
131
+ ```
132
+ What changed?
133
+ ├── New component/module/package
134
+ │ ├── Creates public API? → Create docs/architecture/components/{name}.md + update reference/api.md
135
+ │ └── Internal only? → Update docs/architecture/overview.md (component list)
136
+ ├── API change (new endpoint, changed contract, new config)
137
+ │ └── Update docs/reference/api.md or docs/reference/configuration.md
138
+ ├── Architecture/infrastructure decision
139
+ │ └── Delegate to adr-skill → creates/updates docs/decisions/NNN-{title}.md
140
+ ├── Structural/architecture change
141
+ │ └── Delegate to c4-architecture skill → updates docs/architecture/overview.md
142
+ ├── New developer workflow (build, deploy, test pattern)
143
+ │ └── Create or update docs/guides/{topic}.md
144
+ ├── Bug fix
145
+ │ ├── Reveals missing docs? → Create the missing doc
146
+ │ └── Straightforward fix? → No docs update needed
147
+ └── Dependency update / refactor / cleanup
148
+ └── No docs update needed (unless public API changed)
149
+ ```
150
+
151
+ ### Classify by Diátaxis Quadrant
152
+
153
+ After determining the documentation action, classify the target document's quadrant:
154
+
155
+ | Action → Cognition? | Study → Work? | Quadrant | Target Directory |
156
+ |---------------------|---------------|----------|------------------|
157
+ | Action (doing) | Study (learning) | **Tutorial** | `guides/tutorials/` |
158
+ | Action (doing) | Work (applying) | **How-To** | `guides/` |
159
+ | Cognition (understanding) | Work (using) | **Reference** | `reference/` |
160
+ | Cognition (understanding) | Study (grasping) | **Explanation** | `architecture/`, `decisions/` |
161
+
162
+ Use the [Diátaxis Compass](references/diataxis-compass.md) for edge cases and ambiguous content.
163
+
164
+ ## Templates
165
+
166
+ ### Component Doc Template (`docs/architecture/components/{name}.md`)
167
+
168
+ ```markdown
169
+ # {Component Name}
170
+
171
+ ## Purpose
172
+ One-paragraph description of what this component does and why it exists.
173
+
174
+ ## Architecture
175
+ - **Location**: `src/{path}/`
176
+ - **Entry point**: `{file}`
177
+ - **Key dependencies**: {list}
178
+
179
+ ## Public API
180
+ Brief description of the component's public interface.
181
+
182
+ ## Design Decisions
183
+ - Link to relevant ADRs: [ADR-NNN](../../decisions/NNN-{title}.md)
184
+
185
+ ## Data Flow
186
+ How data enters, transforms through, and exits this component.
187
+ ```
188
+
189
+ ### Guide Template (`docs/guides/{topic}.md`)
190
+
191
+ ```markdown
192
+ # How to {Task}
193
+
194
+ ## Prerequisites
195
+ What you need before starting.
196
+
197
+ ## Steps
198
+ 1. Step one
199
+ 2. Step two
200
+ 3. Step three
201
+
202
+ ## Verification
203
+ How to confirm it worked.
204
+
205
+ ## Troubleshooting
206
+ Common issues and solutions.
207
+ ```
208
+
209
+ ### Reference Template (`docs/reference/{topic}.md`)
210
+
211
+ ```markdown
212
+ # {Topic} Reference
213
+
214
+ ## Overview
215
+ Brief description of what this reference covers.
216
+
217
+ ## {Section}
218
+
219
+ | Item | Type | Default | Description |
220
+ |------|------|---------|-------------|
221
+ | ... | ... | ... | ... |
222
+ ```
223
+
224
+ > **Tutorial and Explanation templates**: For the remaining two Diátaxis quadrants, see [references/diataxis-templates.md](references/diataxis-templates.md).
225
+
226
+ ## Integration with Other Skills
227
+
228
+ ### `adr-skill` Integration
229
+ - All ADRs live in `docs/decisions/`
230
+ - When the docs-sync step detects an architecture decision was made during the flow, delegate to `adr-skill`
231
+ - After `adr-skill` creates/updates an ADR, update `docs/decisions/index.md`
232
+ - Cross-reference ADRs from component docs where relevant
233
+
234
+ ### `c4-architecture` Integration
235
+ - Architecture diagrams live in `docs/architecture/`
236
+ - When the docs-sync step detects structural changes (new packages, changed boundaries), delegate to `c4-architecture`
237
+ - Use Mermaid format for docs files (not HTML) — markdown renders in GitHub
238
+ - Reference diagrams from component docs
239
+
240
+ ## Project Knowledge Acquisition
241
+
242
+ Produces seven populated documents in `docs/architecture/` covering everything needed to work effectively on the project — stack, structure, design, conventions, integrations, testing, and concerns.
243
+
244
+ **Only document what is verifiable from files or tool output — never infer or assume.**
245
+
246
+ ### Output Contract
247
+
248
+ All of the following must be true before finishing:
249
+
250
+ 1. All seven files exist in `docs/architecture/`: `stack.md`, `structure.md`, `design.md`, `conventions.md`, `integrations.md`, `testing.md`, `concerns.md`
251
+ 2. Every claim is traceable to source files, config, or AI Kit tool output
252
+ 3. Unknowns are marked `[TODO]`; intent-dependent decisions are marked `[ASK USER]`
253
+ 4. Every document includes a short "Evidence" section with file paths or tool receipts
254
+ 5. Final response includes numbered `[ASK USER]` questions and intent-vs-reality divergences
255
+
256
+ ### Documents
257
+
258
+ | Document | Covers | Primary Tools |
259
+ |----------|--------|---------------|
260
+ | `stack.md` | Language, runtime, frameworks, dependencies, dev tooling | `analyze_dependencies`, `analyze_structure` |
261
+ | `structure.md` | Directory layout, entry points, key files, packages | `analyze_structure`, `analyze_entry_points` |
262
+ | `design.md` | Layers, patterns, data flow, component boundaries | `analyze_structure`, `analyze_patterns`, `analyze_diagram` |
263
+ | `conventions.md` | Naming, formatting, error handling, import conventions | `analyze_patterns`, `search("conventions")` |
264
+ | `integrations.md` | External APIs, databases, auth, monitoring, CI/CD | `analyze_dependencies`, `search("API\|database\|auth")` |
265
+ | `testing.md` | Test frameworks, file organization, mocking, coverage | `analyze_patterns`, `test_run({})`, `search("test")` |
266
+ | `concerns.md` | Tech debt, bugs, security risks, perf, high-churn files | `audit()`, `dead_symbols()`, `git_context()` |
267
+
268
+ Use [references/project-knowledge-templates.md](references/project-knowledge-templates.md) for the standard template of each document.
269
+
270
+ ### Workflow & References
271
+
272
+ Follow the four-phase workflow: **Scan → Investigate → Populate → Validate**.
273
+
274
+ - [references/project-knowledge-workflow.md](references/project-knowledge-workflow.md) — Full 4-phase workflow, investigation tools per document, population rules, focus area mode
275
+ - [references/project-knowledge-gotchas.md](references/project-knowledge-gotchas.md) — Environment gotchas and anti-pattern table
276
+
277
+ ## Architecture Blueprint Generation
278
+
279
+ When bootstrapping `docs/` for the first time or refreshing architecture documentation, generate a comprehensive architecture blueprint. This replaces manual documentation with tool-driven analysis.
280
+
281
+ ### Blueprint Workflow
282
+
283
+ ```
284
+ Step 1: Detect & Analyze
285
+ analyze_structure({ path: "." }) → project layout, packages, layers
286
+ analyze_patterns({ path: "." }) → conventions, design patterns
287
+ analyze_entry_points({ path: "." }) → API surface, CLI entry points
288
+
289
+ Step 2: Map Dependencies
290
+ analyze_dependencies({ path: "." }) → import graph, cross-package edges
291
+ graph({ action: 'find_nodes', name_pattern: '*' }) → module graph nodes
292
+ graph({ action: 'neighbors', node_id: '...' }) → dependency directions
293
+
294
+ Step 3: Visualize
295
+ analyze_diagram({ path: "." }) → Mermaid architecture diagrams
296
+ Delegate to c4-architecture skill → C4 context/container/component views
297
+
298
+ Step 4: Synthesize
299
+ produce_knowledge({ path: "." }) → comprehensive analysis
300
+ Combine outputs into docs/ structure
301
+ ```
302
+
303
+ ### Blueprint Sections
304
+
305
+ The architecture blueprint should cover these areas (adapted from the Architecture Blueprint Generator pattern):
306
+
307
+ #### 1. Architecture Detection & Analysis
308
+ - **Auto-detect**: Project type, framework, architectural pattern (Clean Architecture, Microservices, Layered, etc.)
309
+ - **Tools**: `analyze_structure` → folder organization, `analyze_patterns` → framework detection, `analyze_dependencies` → dependency flow
310
+ - **Output**: `docs/architecture/overview.md` header section
311
+
312
+ #### 2. Architectural Overview
313
+ - Guiding principles from code structure
314
+ - Architectural boundaries and enforcement mechanisms
315
+ - Hybrid patterns or adaptations
316
+ - **Tools**: `produce_knowledge` + `analyze_structure`
317
+ - **Output**: `docs/architecture/overview.md` main body
318
+
319
+ #### 3. Architecture Visualization
320
+ - High-level subsystem diagram
321
+ - Component interaction diagrams
322
+ - Data flow diagrams
323
+ - **Tools**: `analyze_diagram` + `c4-architecture` skill
324
+ - **Output**: `docs/architecture/overview.md` diagrams + `docs/architecture/diagrams/`
325
+
326
+ #### 4. Core Architectural Components
327
+ For each major component:
328
+ - Purpose and responsibility
329
+ - Internal structure
330
+ - Key abstractions
331
+ - Interaction patterns
332
+ - **Tools**: `analyze_symbols({ path: "component/" })` + `compact({ path, query: "exports" })`
333
+ - **Output**: `docs/architecture/components/{name}.md`
334
+
335
+ #### 5. Layers & Dependencies
336
+ - Layer structure as implemented
337
+ - Dependency rules between layers
338
+ - Abstraction mechanisms for separation
339
+ - Circular dependencies or violations
340
+ - **Tools**: `analyze_dependencies` + `graph({ action: 'neighbors' })`
341
+ - **Output**: `docs/architecture/overview.md` layers section
342
+
343
+ #### 6. Cross-Cutting Concerns
344
+ Document implementation patterns for:
345
+ - Error handling & resilience
346
+ - Logging & observability
347
+ - Validation patterns
348
+ - Configuration management
349
+ - **Tools**: `analyze_patterns` + `search({ query: "error handling" })`
350
+ - **Output**: `docs/architecture/overview.md` cross-cutting section
351
+
352
+ #### 7. Testing Architecture
353
+ - Test framework and strategy
354
+ - Test boundary patterns (unit, integration, e2e)
355
+ - Test file conventions
356
+ - **Tools**: `analyze_patterns` + `search({ query: "test" })`
357
+ - **Output**: `docs/guides/testing.md`
358
+
359
+ #### 8. Extension & Evolution
360
+ - How to add features while preserving architecture
361
+ - Component creation patterns
362
+ - Integration patterns for external systems
363
+ - **Tools**: `analyze_entry_points` + `analyze_patterns`
364
+ - **Output**: `docs/guides/contributing.md` or `docs/architecture/overview.md` extension section
365
+
366
+ ## Rules for the `_docs-sync` Epilogue Step
367
+
368
+ When this skill is loaded during the `_docs-sync` epilogue:
369
+
370
+ ### 0. Gather Flow Artifacts
371
+
372
+ Read all available artifacts from the completed flow before assessing code changes:
373
+
374
+ ```
375
+ flow_status() # Get artifactsPath, topic, phase
376
+ find({ pattern: "*.md", path: "<artifactsPath>" }) # Discover all flow artifacts
377
+ digest({ sources: [ # Compress artifacts for context
378
+ { path: "<found-artifact-1>" },
379
+ { path: "<found-artifact-2>" },
380
+ ...
381
+ ]})
382
+ ```
383
+
384
+ Map each discovered artifact to documentation actions using [references/flow-artifacts-guide.md](references/flow-artifacts-guide.md).
385
+
386
+ Read every artifact `find()` returns — different flows produce different files. Focus on artifacts that contain decisions, requirements, and verification results; skip artifacts that only repeat completed work.
387
+
388
+ If `flow_status()` returns no active flow or no artifacts directory exists, skip this step (source-only mode).
389
+
390
+ ### 1. Assess Changes (tool-driven)
391
+
392
+ ```
393
+ git_context({}) # What changed in this flow
394
+ blast_radius({ changed_files: ["changed-files"] }) # Impact analysis
395
+ ```
396
+
397
+ Use the output to classify changes against the Change-to-Doc Mapping decision tree.
398
+
399
+ ### 1b. Classify Target Quadrant
400
+
401
+ For each doc action identified in Step 1, determine the Diátaxis quadrant:
402
+
403
+ 1. Ask: **Action or Cognition?** Is the reader doing something or understanding something?
404
+ 2. Ask: **Study or Work?** Is the reader learning or applying?
405
+ 3. Match the answer pair to a quadrant → pick the target directory
406
+ 4. If ambiguous → consult [references/diataxis-compass.md](references/diataxis-compass.md) for edge cases
407
+
408
+ Run the [quality checklist](references/diataxis-quality.md) against any doc created or substantially modified.
409
+
410
+ ### 2. Apply the Mapping
411
+
412
+ Follow the Change-to-Doc Mapping decision tree above to determine required documentation actions.
413
+
414
+ ### 3. Bootstrap `docs/` If Needed (tool-driven)
415
+
416
+ If `docs/` doesn't exist, run the full Architecture Blueprint workflow:
417
+
418
+ ```
419
+ # Generate content with tools
420
+ produce_knowledge({ path: "." }) # → docs/README.md foundation
421
+ analyze_structure({ path: "." }) # → docs/architecture/overview.md structure section
422
+ analyze_diagram({ path: "." }) # → docs/architecture/ Mermaid diagrams
423
+ analyze_dependencies({ path: "." }) # → docs/architecture/overview.md dependency section
424
+ analyze_entry_points({ path: "." }) # → docs/reference/api.md foundation
425
+ analyze_patterns({ path: "." }) # → docs/architecture/overview.md patterns section
426
+
427
+ # Create the docs/ tree
428
+ docs/
429
+ ├── README.md ← From produce_knowledge output + project context
430
+ ├── architecture/
431
+ │ ├── overview.md ← From analyze_structure + analyze_dependencies + analyze_diagram
432
+ │ └── components/ ← From analyze_symbols per major component
433
+ ├── decisions/
434
+ │ └── index.md ← ADR log (delegate to adr-skill)
435
+ ├── guides/
436
+ │ └── testing.md ← From analyze_patterns test info
437
+ └── reference/
438
+ └── api.md ← From analyze_entry_points
439
+ ```
440
+
441
+ ### 4. Update Existing Docs (tool-assisted)
442
+
443
+ - Use `compact({ path: "docs/existing.md", query: "section to update" })` to read the current section
444
+ - Use `blast_radius` output to identify which sections need updating
445
+ - **Don't rewrite** — update relevant sections, preserve existing content
446
+ - **Don't duplicate** — reference code comments/READMEs instead of copying
447
+
448
+ ### 5. Delegate When Appropriate
449
+
450
+ - Architecture decisions → `adr-skill` → `docs/decisions/`
451
+ - Architecture diagrams → `c4-architecture` skill → `docs/architecture/`
452
+ - Blueprint refresh → Run Blueprint Workflow above
453
+
454
+ ### 6. Update the Index
455
+
456
+ If docs were added/removed, update `docs/README.md` index.
457
+
458
+ ### 7. Skip If Nothing Changed
459
+
460
+ If the flow's changes don't warrant doc updates (e.g., pure bug fix with no revelations), report "No documentation updates needed" and move on.
461
+
462
+ ## Writing Style
463
+
464
+ Follow these rules when generating documentation content. Adapted from *The Elements of Agent Style* (CC BY 4.0, Yue Zhao) and classic writing authorities.
465
+
466
+ ### Clarity and Precision
467
+ - **Concrete over abstract** — Use specific terms, not vague language ("the retry handler" not "the relevant component")
468
+ - **No needless words** — Cut filler; every sentence earns its place
469
+ - **Active voice when the agent matters** — "The scheduler retries failed jobs" not "Failed jobs are retried"
470
+ - **Affirmative form** — State what something does, not what it does not do (unless a warning)
471
+ - **Claims match evidence** — Do not overstate or understate; back factual claims with file paths or tool output
472
+
473
+ ### Structure
474
+ - **Parallel structure** — Express coordinate ideas in similar form (consistent table columns, consistent list grammar)
475
+ - **Stress position** — Place the important information at the end of the sentence
476
+ - **Sentence variety** — Break sentences over 30 words; vary length to maintain rhythm
477
+ - **Bullets only for genuine lists** — Do not convert flowing prose into bullet points; two items or a sentence do not need bullets
478
+
479
+ ### AI-Tell Avoidance
480
+ - **No dying metaphors** — Avoid "cutting-edge", "leverages", "streamlines", "robust", "seamless"
481
+ - **No transition-word openers** — Do not start paragraphs with "Additionally", "Furthermore", "Moreover"
482
+ - **No em-dash overuse** — Use commas, semicolons, or separate sentences instead
483
+ - **No summary closers** — Do not end every paragraph by restating what it just said
484
+ - **Consistent terminology** — Pick one term and use it throughout; do not alternate synonyms for variety
485
+
486
+ ## Anti-Patterns
487
+
488
+ ### Documentation Maintenance
489
+ - ❌ Documenting implementation details that are obvious from code
490
+ - ❌ Creating docs for every small change (use the mapping tree)
491
+ - ❌ Duplicating information already in code comments or README files
492
+ - ❌ Writing docs that will be immediately outdated (e.g., exact version numbers)
493
+ - ❌ Creating empty placeholder docs "for later"
494
+ - ❌ Rewriting existing docs from scratch instead of updating sections
495
+
496
+ ### Quadrant Mixing (Diátaxis)
497
+ - ❌ **Tutorial with Explanation** — conceptual paragraphs between steps → extract "why" to Explanation doc, link from tutorial
498
+ - ❌ **How-To that Teaches** — "Let's learn..." framing in a task guide → assume competence, link prerequisites
499
+ - ❌ **Reference with Narrative** — opinions in API tables ("I recommend...") → strip opinions to Explanation doc
500
+ - ❌ **Explanation with Procedures** — numbered steps in a conceptual doc → move procedures to How-To
501
+ - ❌ **Mixed-Mode Document** — one doc serving multiple quadrants → split into separate documents per quadrant
502
+ - See [references/diataxis-anti-patterns.md](references/diataxis-anti-patterns.md) for detection signals, counterexamples, and blur zones
503
+
504
+ ### Project Knowledge
505
+ - See [references/project-knowledge-gotchas.md](references/project-knowledge-gotchas.md) for environment gotchas and anti-pattern table
506
+
507
+ ---
508
+
509
509
  *Diátaxis content in this skill and its reference files is adapted from the [Diátaxis framework](https://diataxis.fr/) by Daniele Procida, used under [CC-BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/).*