@drafthq/draft 3.6.0 → 3.7.1

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 (117) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/.cursor-plugin/plugin.json +1 -1
  4. package/README.md +28 -49
  5. package/bin/README.md +47 -1
  6. package/cli/src/installer.js +1 -1
  7. package/cli/src/lib/cursor-registry.js +10 -0
  8. package/core/agents/architect.md +21 -9
  9. package/core/agents/debugger.md +5 -0
  10. package/core/agents/ops.md +7 -2
  11. package/core/agents/planner.md +7 -0
  12. package/core/agents/rca.md +14 -3
  13. package/core/agents/reviewer.md +1 -0
  14. package/core/agents/writer.md +6 -0
  15. package/core/knowledge-base.md +22 -3
  16. package/core/methodology.md +30 -5
  17. package/core/shared/condensation.md +27 -17
  18. package/core/shared/context-verify.md +3 -1
  19. package/core/shared/cross-skill-dispatch.md +7 -3
  20. package/core/shared/draft-context-loading.md +3 -0
  21. package/core/shared/git-report-metadata.md +1 -0
  22. package/core/shared/graph-query.md +0 -2
  23. package/core/shared/graph-usage-report.md +1 -1
  24. package/core/shared/jira-sync.md +10 -6
  25. package/core/shared/okf-retrieval.md +1 -1
  26. package/core/shared/parallel-analysis.md +14 -7
  27. package/core/shared/pattern-learning.md +2 -0
  28. package/core/shared/template-contract.md +1 -1
  29. package/core/shared/vcs-commands.md +5 -2
  30. package/core/templates/ai-context.md +3 -2
  31. package/core/templates/ai-profile.md +7 -0
  32. package/core/templates/architecture.md +6 -2
  33. package/core/templates/discovery.md +1 -1
  34. package/core/templates/guardrails.md +9 -0
  35. package/core/templates/hld.md +5 -4
  36. package/core/templates/intake-questions.md +45 -0
  37. package/core/templates/jira.md +11 -2
  38. package/core/templates/lld.md +8 -5
  39. package/core/templates/okf/concept.md +0 -1
  40. package/core/templates/product.md +11 -2
  41. package/core/templates/rca.md +6 -0
  42. package/core/templates/service-index.md +1 -0
  43. package/core/templates/spec.md +15 -0
  44. package/core/templates/tech-stack.md +12 -0
  45. package/core/templates/workflow.md +20 -0
  46. package/integrations/agents/AGENTS.md +1272 -292
  47. package/integrations/copilot/.github/copilot-instructions.md +1272 -292
  48. package/package.json +1 -1
  49. package/scripts/fetch-memory-engine.sh +24 -6
  50. package/scripts/lib.sh +11 -4
  51. package/scripts/tools/_graph_queries.sh +10 -3
  52. package/scripts/tools/_lib.sh +33 -11
  53. package/scripts/tools/check-repo-size.sh +125 -0
  54. package/scripts/tools/check-skill-line-caps.sh +1 -2
  55. package/scripts/tools/check-template-noop.sh +0 -1
  56. package/scripts/tools/classify-files.sh +2 -2
  57. package/scripts/tools/cycle-detect.sh +16 -8
  58. package/scripts/tools/fix-whitespace.sh +3 -0
  59. package/scripts/tools/git-metadata.sh +6 -0
  60. package/scripts/tools/graph-arch.sh +1 -1
  61. package/scripts/tools/graph-callers.sh +6 -3
  62. package/scripts/tools/graph-impact.sh +4 -2
  63. package/scripts/tools/graph-init.sh +12 -8
  64. package/scripts/tools/graph-preflight.sh +3 -0
  65. package/scripts/tools/graph-query.sh +70 -7
  66. package/scripts/tools/graph-snapshot.sh +29 -5
  67. package/scripts/tools/hotspot-rank.sh +2 -1
  68. package/scripts/tools/install-smoke-test.sh +223 -0
  69. package/scripts/tools/mermaid-from-graph.sh +2 -1
  70. package/scripts/tools/migrate-track-frontmatter.sh +9 -10
  71. package/scripts/tools/okf-coverage-check.sh +4 -3
  72. package/scripts/tools/okf-fix-links.sh +18 -93
  73. package/scripts/tools/okf-plan-concepts.sh +5 -8
  74. package/scripts/tools/okf-render-views.sh +19 -14
  75. package/scripts/tools/okf-validate-quality.sh +13 -2
  76. package/scripts/tools/okf-validate.sh +13 -2
  77. package/scripts/tools/parse-git-log.sh +19 -1
  78. package/scripts/tools/resolve-tools.sh +24 -8
  79. package/scripts/tools/verify-citations.sh +1 -2
  80. package/scripts/tools/verify-doc-anchors.sh +13 -33
  81. package/scripts/tools/verify-graph-binary.sh +13 -3
  82. package/skills/GRAPH.md +21 -10
  83. package/skills/adr/SKILL.md +24 -6
  84. package/skills/assist-review/SKILL.md +2 -1
  85. package/skills/bughunt/SKILL.md +54 -11
  86. package/skills/bughunt/references/regression-tests.md +14 -4
  87. package/skills/change/SKILL.md +19 -9
  88. package/skills/coverage/SKILL.md +26 -10
  89. package/skills/debug/SKILL.md +12 -2
  90. package/skills/decompose/SKILL.md +39 -9
  91. package/skills/deep-review/SKILL.md +17 -4
  92. package/skills/deploy-checklist/SKILL.md +9 -2
  93. package/skills/documentation/SKILL.md +12 -1
  94. package/skills/draft/SKILL.md +40 -29
  95. package/skills/draft/context-files.md +8 -1
  96. package/skills/draft/quality-guide.md +10 -2
  97. package/skills/graph/SKILL.md +1 -1
  98. package/skills/impact/SKILL.md +3 -1
  99. package/skills/implement/SKILL.md +60 -18
  100. package/skills/incident-response/SKILL.md +5 -2
  101. package/skills/init/SKILL.md +102 -23
  102. package/skills/init/references/architecture-spec.md +31 -7
  103. package/skills/init/references/okf-emitter.md +3 -3
  104. package/skills/jira/SKILL.md +33 -13
  105. package/skills/jira/references/review.md +61 -19
  106. package/skills/learn/SKILL.md +29 -6
  107. package/skills/new-track/SKILL.md +73 -18
  108. package/skills/quick-review/SKILL.md +7 -2
  109. package/skills/revert/SKILL.md +11 -5
  110. package/skills/review/SKILL.md +123 -24
  111. package/skills/review/references/zero-setup-mode.md +117 -0
  112. package/skills/standup/SKILL.md +9 -1
  113. package/skills/status/SKILL.md +6 -6
  114. package/skills/tech-debt/SKILL.md +7 -1
  115. package/skills/testing-strategy/SKILL.md +10 -2
  116. package/skills/tour/SKILL.md +2 -1
  117. package/skills/upload/SKILL.md +3 -2
@@ -7,7 +7,7 @@ description: Handle mid-track requirement changes. Analyzes impact on completed
7
7
 
8
8
  You are handling a mid-track requirement change using Draft's Context-Driven Development methodology.
9
9
 
10
- ## Red Flags - STOP if you're:
10
+ ## Red Flags - STOP if you're
11
11
 
12
12
  - Applying changes to spec.md or plan.md without showing the user what will change first
13
13
  - Invalidating `[x]` completed tasks without flagging them explicitly
@@ -38,11 +38,13 @@ Extract from `$ARGUMENTS`:
38
38
  ### Default Behavior
39
39
 
40
40
  If no `track <id>` specified:
41
+
41
42
  - Auto-detect the active `[~]` In Progress track from `draft/tracks.md`
42
43
  - If no `[~]` track, find the first `[ ]` Pending track
43
44
  - Display: `Auto-detected track: <id> - <name>` before proceeding
44
45
 
45
46
  If no change description provided:
47
+
46
48
  - Error: "Usage: `/draft:change <description>` or `/draft:change track <id> <description>`"
47
49
 
48
50
  ---
@@ -73,7 +75,8 @@ For each requirement and acceptance criterion, classify the effect:
73
75
  | **Unaffected** | No change needed |
74
76
 
75
77
  Produce a concise impact list. Example:
76
- ```
78
+
79
+ ```text
77
80
  Spec impact:
78
81
  - AC #2 "User can export to CSV" → Modified (now also requires JSON format)
79
82
  - AC #5 "Export limited to 1000 rows" → Removed (no row limit)
@@ -81,6 +84,7 @@ Spec impact:
81
84
  ```
82
85
 
83
86
  **HLD impact** (only when `hld.md` exists):
87
+
84
88
  - §Architecture / Component Diagram — does the change introduce new modules or alter integration edges?
85
89
  - §Detailed Design — does any per-component subsection need updating, or are new components introduced?
86
90
  - §Dependencies — new/removed dependent components?
@@ -89,6 +93,7 @@ Spec impact:
89
93
  - §Deployment — does the deployment surface change?
90
94
 
91
95
  **LLD impact** (only when `lld.md` exists):
96
+
92
97
  - §Classes and Interfaces — signatures added/modified/removed?
93
98
  - §Data Model — schema changes? New fields? Migration required?
94
99
  - §Key Algorithms and Workflows — algorithm changes? New sequence diagrams needed?
@@ -97,7 +102,7 @@ Spec impact:
97
102
 
98
103
  **Re-approval flag:** If the HLD Approvals table has any signed rows (Date column populated) AND the change touches HLD structural sections (Architecture, Detailed Design, Dependencies, Checklist, IP, Deployment), surface this warning prominently:
99
104
 
100
- ```
105
+ ```text
101
106
  ⚠️ HLD modified after sign-off — Approvals table requires re-circulation.
102
107
  Signed rows: [list which roles signed and when]
103
108
  Changed sections: [list of HLD sections impacted]
@@ -130,7 +135,7 @@ For each task in `plan.md`, determine if the spec change affects it:
130
135
 
131
136
  Display a clear summary before proposing any file changes:
132
137
 
133
- ```
138
+ ```yaml
134
139
  Change: [change description]
135
140
  Track: <track_id> — <track_name>
136
141
 
@@ -178,7 +183,7 @@ Show before/after for each impacted LLD section. Preserve §Approvals verbatim.
178
183
 
179
184
  ## Step 7: CHECKPOINT
180
185
 
181
- ```
186
+ ```text
182
187
  Apply these changes to spec.md and plan.md? [yes / no / edit]
183
188
  ```
184
189
 
@@ -208,7 +213,7 @@ Apply these changes to spec.md and plan.md? [yes / no / edit]
208
213
 
209
214
  4. Announce:
210
215
 
211
- ```
216
+ ```text
212
217
  Changes applied: <track_id>
213
218
 
214
219
  Updated:
@@ -235,19 +240,22 @@ Next: /draft:implement to continue, or /draft:review to assess current state.
235
240
  ## Error Handling
236
241
 
237
242
  ### Track Not Found
238
- ```
243
+
244
+ ```yaml
239
245
  Error: Track '<id>' not found.
240
246
  Run /draft:status to see available tracks.
241
247
  ```
242
248
 
243
249
  ### No Active Track
244
- ```
250
+
251
+ ```yaml
245
252
  Error: No active track found.
246
253
  Use: /draft:change track <id> <description>
247
254
  ```
248
255
 
249
256
  ### No Spec or Plan
250
- ```
257
+
258
+ ```yaml
251
259
  Error: Missing spec.md or plan.md for track <id>.
252
260
  Cannot perform change analysis without both files.
253
261
  ```
@@ -257,11 +265,13 @@ Cannot perform change analysis without both files.
257
265
  ## Examples
258
266
 
259
267
  ### Change description for active track
268
+
260
269
  ```bash
261
270
  /draft:change the export format should support JSON in addition to CSV
262
271
  ```
263
272
 
264
273
  ### Targeting a specific track
274
+
265
275
  ```bash
266
276
  /draft:change track add-export-feature also require a progress indicator for exports over 500 rows
267
277
  ```
@@ -7,7 +7,7 @@ description: Compute code coverage for active track or module. Targets 95%+ cove
7
7
 
8
8
  You are computing and reporting code coverage for the active track or a specific module. This complements the TDD workflow — TDD is the process (write test, implement, refactor), coverage is the measurement (how much code do those tests exercise).
9
9
 
10
- ## Red Flags - STOP if you're:
10
+ ## Red Flags - STOP if you're
11
11
 
12
12
  - Reporting coverage without actually running the coverage tool
13
13
  - Making up coverage percentages
@@ -26,6 +26,7 @@ You are computing and reporting code coverage for the active track or a specific
26
26
  5. Check if `draft/tracks/<id>/bughunt-report-latest.md` (track scope) or `draft/bughunt-report-latest.md` (project scope) exists for cross-referencing (see Coverage-Bughunt Cross-Reference below)
27
27
 
28
28
  If no active track and no argument provided:
29
+
29
30
  - Tell user: "No active track. Provide a path or track ID, or run `/draft:new-track` first."
30
31
 
31
32
  ## Step 2: Detect Coverage Tool
@@ -54,6 +55,7 @@ If the script is unavailable or returns `framework: unknown`, fall back to the h
54
55
  | Ruby | `simplecov` |
55
56
 
56
57
  **Detection order (fallback path):**
58
+
57
59
  1. Check `tech-stack.md` for explicit testing section
58
60
  2. Check config files (`jest.config.*`, `vitest.config.*`, `pytest.ini`, `setup.cfg`, `pyproject.toml`, `.nycrc`)
59
61
  3. Check `package.json` scripts for coverage commands
@@ -62,6 +64,7 @@ If the script is unavailable or returns `framework: unknown`, fall back to the h
62
64
  ## Step 3: Determine Scope
63
65
 
64
66
  **Priority order:**
67
+
65
68
  1. If argument provided (path or module name): use as scope filter
66
69
  2. If track has `architecture.md` (or project has `.ai-context.md`) with an in-progress module: scope to that module's files
67
70
  3. If active track exists: scope to files changed in the track (use `git diff` against base branch)
@@ -84,6 +87,7 @@ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}
84
87
  ```
85
88
 
86
89
  If the script is unavailable or returns `tool: unsupported`:
90
+
87
91
  1. Execute the coverage command. Request machine-readable output when possible: `--json` for Jest, `--cov-report=json` for pytest, `-coverprofile` for Go, `--coverage-output-format json` for dotnet.
88
92
  2. Capture full output
89
93
  3. If command fails:
@@ -95,7 +99,7 @@ If the script is unavailable or returns `tool: unsupported`:
95
99
 
96
100
  Parse coverage output and present in a standardized format:
97
101
 
98
- ```
102
+ ```yaml
99
103
  ---
100
104
  COVERAGE REPORT
101
105
  ---
@@ -151,7 +155,8 @@ For files below target (using per-module targets when configured — see Per-Mod
151
155
  - **Infrastructure** - Framework boilerplate, main entry points. Usually acceptable.
152
156
  - **Legacy/Brownfield** - Modules with 0% or very low coverage that need refactoring. Apply Characterization Testing (see below).
153
157
  3. **Suggest tests** for testable gaps:
154
- ```
158
+
159
+ ```text
155
160
  SUGGESTED TESTS
156
161
  ─────────────────────────────────────────────────────────
157
162
  1. Test malformed JWT token handling (jwt.ts:45-52)
@@ -174,7 +179,8 @@ When encountering modules with 0% or very low coverage that need refactoring, do
174
179
  5. **Remove approval tests** — Once proper unit test coverage meets the target, retire the Golden Master tests.
175
180
 
176
181
  **Tool references:**
177
- - ApprovalTests (https://approvaltests.com/) — available for Java, C#, Python, JS, and more
182
+
183
+ - ApprovalTests (<https://approvaltests.com/>) — available for Java, C#, Python, JS, and more
178
184
  - Verify (.NET) — snapshot testing library
179
185
 
180
186
  Present characterization testing recommendations in the gap analysis when applicable.
@@ -191,11 +197,11 @@ After measuring line coverage (and branch coverage if applicable), prompt the en
191
197
 
192
198
  | Language | Tool | Reference |
193
199
  |----------|------|-----------|
194
- | Java | PIT | https://pitest.org/ |
195
- | JavaScript/TypeScript | Stryker | https://stryker-mutator.io/ |
200
+ | Java | PIT | <https://pitest.org/> |
201
+ | JavaScript/TypeScript | Stryker | <https://stryker-mutator.io/> |
196
202
  | Python | mutmut | (Mutation testing tool) |
197
203
  | Rust | cargo-mutants | (Mutation testing tool) |
198
- | C# | Stryker.NET | https://stryker-mutator.io/ |
204
+ | C# | Stryker.NET | <https://stryker-mutator.io/> |
199
205
  | Go | go-mutesting | (Mutation testing tool) |
200
206
 
201
207
  **Reference:** Google's mutation testing program is used by 6,000+ engineers and processes approximately 30% of all code diffs, validating that mutation testing scales to large codebases.
@@ -209,7 +215,8 @@ If a bughunt report exists (`draft/tracks/<id>/bughunt-report-latest.md` or `dra
209
215
  1. **Parse bughunt findings** — Extract file paths and line ranges of confirmed or suspected bugs.
210
216
  2. **Cross-reference with uncovered code paths** — Identify bughunt findings that fall in uncovered lines.
211
217
  3. **Flag as highest-priority test gaps** — Confirmed bugs in uncovered code are the most dangerous gaps. Present them prominently:
212
- ```
218
+
219
+ ```text
213
220
  BUGHUNT CROSS-REFERENCE
214
221
  ─────────────────────────────────────────────────────────
215
222
  ⚠ CRITICAL: Bug "Race condition in session refresh" (bughunt #3)
@@ -220,6 +227,7 @@ If a bughunt report exists (`draft/tracks/<id>/bughunt-report-latest.md` or `dra
220
227
  at src/users/repository.ts:45 — IN UNCOVERED CODE
221
228
  → Write a regression test targeting this path
222
229
  ```
230
+
223
231
  4. **Prioritize suggested tests** — Tests that cover bughunt-flagged code should appear first in the SUGGESTED TESTS section.
224
232
 
225
233
  ## Per-Module Coverage Enforcement
@@ -255,7 +263,8 @@ coverage_targets:
255
263
  **Classification heuristic:** Infer module risk from directory names and file content when explicit configuration is absent. Flag the inferred classification in the report so the developer can correct it.
256
264
 
257
265
  In the coverage report, show per-module targets alongside actual coverage:
258
- ```
266
+
267
+ ```text
259
268
  PER-FILE BREAKDOWN (module-level targets)
260
269
  ---
261
270
  src/auth/middleware.ts 96.2% [high_risk: 95%] PASS
@@ -271,6 +280,7 @@ src/generated/api.ts — [generated: excluded]
271
280
  **STOP.** Present the full coverage report and gap analysis.
272
281
 
273
282
  Ask developer:
283
+
274
284
  - Accept current coverage? (if at or above target)
275
285
  - Write additional tests for testable gaps?
276
286
  - Justify and document acceptable uncovered lines?
@@ -283,17 +293,20 @@ Ask developer:
283
293
  After developer approves:
284
294
 
285
295
  1. **Update plan.md** - Add coverage note to the relevant phase:
296
+
286
297
  ```markdown
287
298
  **Coverage:** 96.2% (target: 95%) - PASS
288
299
  - Uncovered: defensive null checks in jwt.ts (justified)
289
300
  ```
290
301
 
291
302
  2. **Update architecture context** — update the project-level `draft/architecture.md` with coverage data (not a track-level architecture file), then run the Condensation Subroutine (defined in `core/shared/condensation.md`) to regenerate `draft/.ai-context.md`. The Condensation Subroutine only applies to the project-level `draft/architecture.md` → `draft/.ai-context.md` pipeline:
303
+
292
304
  ```markdown
293
305
  - **Status:** [x] Complete (Coverage: 96.2%)
294
306
  ```
295
307
 
296
308
  3. **Update metadata.json** - Add coverage field if not present:
309
+
297
310
  ```json
298
311
  {
299
312
  "coverage": {
@@ -307,6 +320,7 @@ After developer approves:
307
320
  4. **Write detailed coverage report** to `draft/tracks/<id>/coverage-report-<timestamp>.md` (where `<timestamp>` is generated via `date +%Y-%m-%dT%H%M`, e.g., `2026-03-15T1430`) with YAML frontmatter (include `project`, `track_id`, `generated_by: "draft:coverage"`, `generated_at`, `git` metadata matching other skills) and timestamped entries for historical tracking.
308
321
 
309
322
  After writing the timestamped report, create a symlink pointing to it:
323
+
310
324
  ```bash
311
325
  ln -sf coverage-report-<timestamp>.md draft/tracks/<id>/coverage-report-latest.md
312
326
  ```
@@ -316,7 +330,8 @@ After developer approves:
316
330
  ## Completion
317
331
 
318
332
  Announce:
319
- ```
333
+
334
+ ```text
320
335
  Coverage report complete.
321
336
 
322
337
  Overall: [percentage]% (target: [target]%)
@@ -335,6 +350,7 @@ Results recorded in:
335
350
  ## Re-running Coverage
336
351
 
337
352
  When coverage is run again on the same track/module:
353
+
338
354
  1. Compare with previous results from metadata.json. If no previous coverage data found in metadata.json, skip delta comparison and report current values only.
339
355
  2. Show delta: "Coverage improved from 87.3% to 96.2% (+8.9%)"
340
356
  3. Highlight newly covered lines
@@ -29,11 +29,12 @@ When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-firs
29
29
 
30
30
  Filesystem `grep` is reserved for source-text scans (literal error strings, stack-trace symbols when the graph misses). Use the fallback sentence on graph miss.
31
31
 
32
- ## Red Flags — STOP if you're:
32
+ ## Red Flags — STOP if you're
33
33
 
34
34
  See [shared red flags](../../core/shared/red-flags.md) — applies to all code-touching skills.
35
35
 
36
36
  Skill-specific:
37
+
37
38
  - Making code changes before reproducing the bug
38
39
  - Guessing at the cause instead of tracing data/control flow
39
40
  - Trying multiple fixes simultaneously ("shotgun debugging")
@@ -70,6 +71,7 @@ Debug can run standalone (without draft context) or within a draft track. If `dr
70
71
  Read and follow the base procedure in `core/shared/draft-context-loading.md`.
71
72
 
72
73
  Key context for debugging:
74
+
73
75
  - `.ai-context.md` — Module boundaries, data flows, invariants (crucial for tracing)
74
76
  - `tech-stack.md` — Language-specific debugging tools and techniques
75
77
  - `guardrails.md` — Known anti-patterns that may be causing the issue
@@ -78,12 +80,14 @@ Key context for debugging:
78
80
  ## Step 1: Parse Arguments
79
81
 
80
82
  Check for arguments:
83
+
81
84
  - `/draft:debug` — Interactive: ask what's broken
82
85
  - `/draft:debug <description>` — Start with the described problem
83
86
  - `/draft:debug track <id>` — Debug within a specific track context (load spec.md, plan.md)
84
87
  - `/draft:debug <JIRA-KEY>` — Pull context from Jira ticket via MCP
85
88
 
86
89
  If a Jira ticket is provided:
90
+
87
91
  1. Pull ticket via Jira MCP: `get_issue()`, `get_issue_description()`, `get_issue_comments()`
88
92
  2. Extract: URLs, log paths, stack traces, reproduction steps, affected services
89
93
  3. Use `curl`/`wget` to fetch any URLs mentioned (dashboards, error pages, API responses)
@@ -111,8 +115,10 @@ Reference `core/agents/debugger.md` Phase 1 for detailed investigation technique
111
115
  1. **Trace data flow** — Follow data from input to failure point, documenting each hop with `file:line` references
112
116
  2. **Trace control flow** — Map the execution path, identify where it diverges from expected behavior
113
117
  3. **Differential analysis** — Compare working vs failing cases:
118
+
114
119
  | Aspect | Working Case | Failing Case | Difference |
115
120
  |--------|-------------|-------------|------------|
121
+
116
122
  4. **Check boundaries** — Reference `.ai-context.md` module boundaries to scope the investigation
117
123
 
118
124
  Reference `core/agents/debugger.md` Phase 2 for language-specific debugging techniques.
@@ -143,9 +149,11 @@ Reference `core/agents/debugger.md` Phase 3 and `core/agents/rca.md` for 5 Whys
143
149
  ### Test Writing Guardrail
144
150
 
145
151
  **STOP.** Before writing any test:
146
- ```
152
+
153
+ ```yaml
147
154
  ASK: "Root cause confirmed: [summary]. Want me to write a regression test for this fix? [Y/n]"
148
155
  ```
156
+
149
157
  - If accepted: write regression test first (fails before fix, passes after)
150
158
  - If declined: note "Tests: developer-handled" and proceed to fix
151
159
 
@@ -172,6 +180,7 @@ Include the report header table immediately after frontmatter:
172
180
  ```
173
181
 
174
182
  Save to:
183
+
175
184
  - Track-scoped: `draft/tracks/<id>/debug-report.md`
176
185
  - Standalone: `draft/debug-report-<timestamp>.md` with symlink `debug-report-latest.md`
177
186
 
@@ -194,6 +203,7 @@ If `draft/graph/schema.yaml` does not exist, set `Graph files queried: NONE` and
194
203
  ## Graph Usage Report (append to debug report)
195
204
 
196
205
  Emit the canonical footer from [core/shared/graph-usage-report.md](../../core/shared/graph-usage-report.md) §Canonical footer. The lint hook `scripts/tools/check-graph-usage-report.sh` validates the section on save.
206
+
197
207
  ## Cross-Skill Dispatch
198
208
 
199
209
  - **Auto-invoked by:** `/draft:new-track` (bug tracks — Offer tier), `/draft:implement` (blocked tasks — Offer tier)
@@ -29,7 +29,7 @@ When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-firs
29
29
 
30
30
  Filesystem `grep`/`find` for module discovery is only permitted **after** a documented graph miss, using the fallback sentence `Graph returned no match for <X>; falling back to grep.` and recorded in the Graph Usage Report.
31
31
 
32
- ## Red Flags - STOP if you're:
32
+ ## Red Flags - STOP if you're
33
33
 
34
34
  See [shared red flags](../../core/shared/red-flags.md) — applies to all code-touching skills. In particular, the **Ground-Truth Red Flags** are load-bearing for decompose: HLD/LLD are design-mandated artifacts and TBD citations on Modified modules fail review.
35
35
 
@@ -44,6 +44,7 @@ must pass clean on the regenerated set. Plan.md must back-link to
44
44
  [core/shared/discovery-schema.md](../../core/shared/discovery-schema.md).
45
45
 
46
46
  Skill-specific:
47
+
47
48
  - Defining modules without understanding the codebase
48
49
  - Creating modules with circular dependencies
49
50
  - Making modules too large (>3 files, excluding test files) or too small (single function)
@@ -67,6 +68,7 @@ For track-scoped decomposition, also derive the human-readable track title used
67
68
  - `{TRACK_TITLE}` — first-level heading text from the active track's `spec.md` (the `# ...` line). If `spec.md` has no H1, fall back to the `{TRACK_ID}`.
68
69
 
69
70
  Also extract from `spec.md` frontmatter:
71
+
70
72
  - `classification.criticality`, `classification.data_classification`, `classification.deployment_surface` — copy verbatim into hld.md frontmatter.
71
73
  - `approvers.*` — pre-fill the HLD Approvals table (tech_leads, arb_leads, cloudops_leads, qa_leads, pm_leads) and LLD Approvals table (team_leads, tech_leads, qa). If a field is empty in spec.md, leave the table cell empty — do not invent names.
72
74
 
@@ -100,6 +102,7 @@ Parse `$ARGUMENTS` for flags first, then strip them before interpreting the rema
100
102
  - `--lld` → **LLD mode** — generate Section 6 (Low-Level Design) in addition to HLD. Strip from arguments before scope detection.
101
103
 
102
104
  Scope detection (on stripped arguments):
105
+
103
106
  - `project` or no argument with no active track → **Project-wide** decomposition → `draft/architecture.md` + `draft/.ai-context.md`
104
107
  - Track ID or active track exists → **Track-scoped** decomposition → `draft/tracks/<id>/hld.md` (always) + `draft/tracks/<id>/lld.md` (when triggered)
105
108
 
@@ -135,25 +138,30 @@ For brownfield projects, scan the existing codebase using these concrete steps:
135
138
  ### Codebase Scanning Patterns
136
139
 
137
140
  **Directory structure** — Map top-level organization:
141
+
138
142
  ```bash
139
143
  ls -d src/*/ lib/*/ app/*/ packages/*/ 2>/dev/null
140
144
  ```
141
145
 
142
146
  **Entry points** — Find main files and exports:
147
+
143
148
  - Look for: `index.ts`, `main.ts`, `app.ts`, `mod.rs`, `__init__.py`, `main.go`
144
149
  - Check `package.json` `main`/`exports` fields, `pyproject.toml` entry points, `go.mod` module path
145
150
 
146
151
  **Existing module boundaries** — Identify by:
152
+
147
153
  - Directory-per-feature patterns (e.g., `src/auth/`, `src/users/`)
148
154
  - Package files (`package.json` in subdirs, `__init__.py`, `go` package declarations)
149
155
  - Barrel exports (`index.ts` re-exporting from a directory)
150
156
 
151
157
  **Dependency patterns** — Trace imports:
158
+
152
159
  - Search for `import` / `require` / `from` statements across source files
153
160
  - Identify which directories import from which other directories
154
161
  - Flag cross-cutting imports (e.g., `utils/` imported everywhere)
155
162
 
156
163
  **File type filters by language:**
164
+
157
165
  | Language | Source Extensions | Config Files |
158
166
  |----------|-------------------|--------------|
159
167
  | TypeScript/JS | `*.ts`, `*.tsx`, `*.js`, `*.jsx` | `tsconfig.json`, `package.json` |
@@ -180,6 +188,7 @@ This data is deterministic and exhaustive. The manual scanning recipes above onl
180
188
  Propose a module breakdown through dialogue:
181
189
 
182
190
  For each module, define:
191
+
183
192
  - **Name** - Short, descriptive identifier
184
193
  - **Responsibility** - One sentence: what this module owns
185
194
  - **Files** - Expected source files (existing or to be created)
@@ -193,6 +202,7 @@ For each module, define:
193
202
  2. Target 1-3 files per module
194
203
  3. Every module needs a clear API boundary
195
204
  4. **Minimal Coupling** — communicate through interfaces, not internals
205
+
196
206
  - Modules should be testable in isolation
197
207
  - Each module typically contains: API, control flow, execution state, functions
198
208
 
@@ -200,7 +210,7 @@ For each module, define:
200
210
 
201
211
  **STOP.** Present the module breakdown to the developer.
202
212
 
203
- ```
213
+ ```yaml
204
214
  ---
205
215
  MODULE BREAKDOWN
206
216
  ---
@@ -235,7 +245,7 @@ After modules are approved:
235
245
 
236
246
  **STOP.** Present the dependency diagram and implementation order.
237
247
 
238
- ```
248
+ ```yaml
239
249
  ---
240
250
  DEPENDENCY ANALYSIS
241
251
  ---
@@ -277,6 +287,7 @@ Template selection depends on scope:
277
287
  - **Track-scoped** → `core/templates/hld.md` (always) and `core/templates/lld.md` (when triggered)
278
288
 
279
289
  **Output location:**
290
+
280
291
  - Project-wide: Update `draft/architecture.md` with the module changes, then run the Condensation Subroutine (defined in `core/shared/condensation.md`) to regenerate `draft/.ai-context.md`.
281
292
  - Track-scoped: write to `draft/tracks/<id>/hld.md` and (when triggered) `draft/tracks/<id>/lld.md`.
282
293
 
@@ -287,6 +298,7 @@ Template selection depends on scope:
287
298
  Generate `draft/tracks/<id>/hld.md` from `core/templates/hld.md`. Populate every section that has a directive — do not ship placeholders.
288
299
 
289
300
  **Frontmatter:**
301
+
290
302
  - Copy git metadata from current repo state.
291
303
  - Copy `classification.*` from `spec.md` frontmatter (criticality, data_classification, deployment_surface). The HLD's `links.*` block is statically correct in `core/templates/hld.md` — do not copy it from spec.md.
292
304
 
@@ -297,6 +309,7 @@ Generate `draft/tracks/<id>/hld.md` from `core/templates/hld.md`. Populate every
297
309
  **§Requirements:** Do not duplicate `spec.md`. Verify the link references resolve to actual sections in spec.md; if a section is missing, flag it.
298
310
 
299
311
  **§High Level Design / Architecture:**
312
+
300
313
  - **`<!-- GRAPH:track-component-diagram -->` slot:** Render Mermaid `flowchart TD` with three subgraphs — `Track` (modules in scope from Step 3), `Existing` (existing modules this track touches per integration edges), `External` (DB, queue, 3P APIs). Label edges with transport (HTTP / RPC / queue / direct call) when non-obvious.
301
314
  - **Architecture narrative** (≤300 words). Explain how blackbox requirements map to the architecture. Name the architectural style. Justify from observable evidence.
302
315
 
@@ -307,11 +320,13 @@ Generate `draft/tracks/<id>/hld.md` from `core/templates/hld.md`. Populate every
307
320
  **§High Level Design / Alternatives Considered:** Table format. Promote any non-trivial rejected alternative to a standalone ADR via `/draft:adr` and link both ways.
308
321
 
309
322
  **§Detailed Design:**
323
+
310
324
  - **`<!-- GRAPH:track-component-table -->` slot:** Render one row per module from Step 3. Columns: Module, Status (`New`/`Modified`/`Existing`), Files (count + comma list), Public API count, Fan-In, Fan-Out, Complexity (`Low`/`Medium`/`High`), Primary Deps, Citation (`path:line` of entry symbol).
311
325
  - **Mandatory Citation Gate:** For every row whose Status is `Modified` or `Existing`, the Citation cell **MUST** resolve to a real `path:line` from a file you Read in this run. `TBD` is only legal for `Status: New` rows, and only when the planned file path is filled (e.g. `Citation: newscribe/server/ops/shuffle_memory_eligibility.h (planned)`). If a Modified-row Citation is unresolved, **halt** — Read the file, locate the entry symbol, and fill the cell before emitting the table. See [graph-query.md](../../core/shared/graph-query.md) §Ground-Truth Discipline rules G1 and G3.
312
326
  - **Per-component subsection:** One `#### {Component Name}` block per module. Fill Responsibility, Status, Entry point (resolved `path:line` for Modified/Existing modules), Public API link to LLD, Whitebox requirements addressed (AC IDs from spec.md), Design notes (≤200 words).
313
327
 
314
328
  **§Dependencies:**
329
+
315
330
  - **`<!-- GRAPH:track-dependencies -->` slot:** Render rows per cross-module integration edge of kind `call`/`import`/`event`/`shared-schema`. Columns: Dependent Component, Edge Kind, Impact Assessment (Small/Medium/Large — graph fan-in heuristic: 1–2 = Small, 3–5 = Medium, 6+ = Large), Description, Citation. The Citation column is bound by the same Mandatory Citation Gate as the component table.
316
331
 
317
332
  **§Intellectual Property, §Checklist, §Deployment, §Observability:** These are author-driven sections that the design author completes before the HLD is presented for approval. Decompose's job is to **scaffold structured TBD bullets**, not to invent claims and not to leave bare `-` placeholders.
@@ -388,11 +403,13 @@ When triggered, generate `draft/tracks/<id>/lld.md` from `core/templates/lld.md`
388
403
  **§Requirements:** Link-only to `spec.md`; list AC IDs covered by this LLD.
389
404
 
390
405
  **§Low Level Design / Classes and Interfaces:**
406
+
391
407
  - **`<!-- GRAPH:track-class-table -->` slot:** Render per-module table from graph public-API index. One row per public symbol. Columns: Symbol, Kind (class/iface/func/method), Signature, Visibility, Citation (`path:line`), Concurrency Notes.
392
408
  - **Mandatory Citation Gate (LLD):** Same rule as HLD §Detailed Design. For every symbol whose owning module has Status `Modified` or `Existing`, Citation must resolve to a real `path:line` from a file Read in this run. For `Status: New` symbols, Citation may be `<planned path>:<planned line or TBD>` provided the file path is concrete. A bare `TBD` cell is a halt — fix before emitting.
393
409
  - **Per-component subsection:** Public API table with full signatures, params, returns, errors, citation. Document Preconditions, Postconditions, Invariants (thread safety, idempotency, ordering).
394
410
 
395
411
  **§Low Level Design / Data Model:**
412
+
396
413
  - **`<!-- GRAPH:track-data-models -->` slot:** Render one block per new/modified entity. Pull proto/struct/class declarations and field metadata from the graph data-model index.
397
414
  - **Per-model subsection:** Field table (type, nullable, default, validation), Storage, Indexes/Keys, Migration path.
398
415
 
@@ -432,6 +449,7 @@ Run unconditionally — idempotent if files are already clean.
432
449
  ### CHECKPOINT (MANDATORY)
433
450
 
434
451
  **STOP.** Present the generated `hld.md` (and `lld.md` if generated) to the developer. Call out:
452
+
435
453
  - Which graph slots were populated vs. unpopulated (and why — e.g., "no proto definitions found, GRAPH:track-data-models slot empty").
436
454
  - Whether LLD was generated, and the trigger (`--lld` flag or auto-triggered by High-complexity module X).
437
455
  - Author-driven sections that still need manual content: §IP, §Checklist (HLD), §PaaS/§UT (LLD), §Observability metrics/thresholds.
@@ -452,7 +470,7 @@ If this is a track-scoped decomposition and a `plan.md` exists:
452
470
  `core/templates/plan.md` (and tracks generated from it at template_version
453
471
  ≥ 2.0.0) wraps phase tables in:
454
472
 
455
- ```
473
+ ```text
456
474
  <!-- DECOMPOSE:REGENERATE START -->
457
475
  ... phase tables ...
458
476
  <!-- DECOMPOSE:REGENERATE END -->
@@ -479,6 +497,7 @@ When restructuring plan.md around modules, follow these rules for existing tasks
479
497
  **Completed tasks `[x]`:** Preserve exactly as-is. Map them to the appropriate module phase. Do not rename, reorder, or modify. Add a note: `(preserved from original plan)`.
480
498
 
481
499
  **In-progress tasks `[~]`:** Map to the appropriate module phase. Flag for developer review if the task spans multiple modules:
500
+
482
501
  ```markdown
483
502
  - [~] **Task 2.1:** Original task description
484
503
  - ⚠ REVIEW: This task may need splitting across modules [auth] and [database]
@@ -489,6 +508,7 @@ When restructuring plan.md around modules, follow these rules for existing tasks
489
508
  **Blocked tasks `[!]`:** Preserve the blocked status and reason. Map to appropriate module. If the blocker is in a different module, add a cross-module dependency note.
490
509
 
491
510
  **Conflict handling:** If a task doesn't map cleanly to any module:
511
+
492
512
  1. List it under a `### Unmapped Tasks` section at the end
493
513
  2. Flag it for developer decision
494
514
  3. Never silently drop tasks
@@ -497,7 +517,7 @@ When restructuring plan.md around modules, follow these rules for existing tasks
497
517
 
498
518
  **STOP.** Present the updated plan structure.
499
519
 
500
- ```
520
+ ```text
501
521
  PROPOSED PLAN RESTRUCTURE
502
522
  ---
503
523
  Phase 1: [Module A] (Foundation)
@@ -521,7 +541,8 @@ After applying the approved plan changes:
521
541
  ## Completion
522
542
 
523
543
  **Track-scoped announcement:**
524
- ```
544
+
545
+ ```text
525
546
  Track decomposition complete.
526
547
 
527
548
  Created: draft/tracks/<id>/hld.md
@@ -547,7 +568,8 @@ Next steps:
547
568
  ```
548
569
 
549
570
  **Project-wide announcement** (when scope = project):
550
- ```
571
+
572
+ ```text
551
573
  Project architecture refresh complete.
552
574
 
553
575
  Updated: draft/architecture.md
@@ -570,6 +592,7 @@ When adding new modules to the project-wide architecture:
570
592
  4. Run the Condensation Subroutine (defined in `core/shared/condensation.md`) to regenerate `draft/.ai-context.md`
571
593
 
572
594
  **Safe write pattern for architecture.md:**
595
+
573
596
  1. Backup `architecture.md` → `architecture.md.backup`
574
597
  2. Write changes to `architecture.md.new`
575
598
  3. Present diff for review
@@ -579,12 +602,14 @@ When adding new modules to the project-wide architecture:
579
602
  ## Updating design context
580
603
 
581
604
  **Project-wide rerun** (running `/draft:decompose` on existing `.ai-context.md` / `architecture.md`):
605
+
582
606
  1. Read the existing context file
583
607
  2. Ask developer what changed (new modules, removed modules, restructured boundaries)
584
608
  3. Follow the same checkpoint process for changes
585
609
  4. Update `draft/architecture.md`, preserving completed module statuses and stories, then regenerate `.ai-context.md`
586
610
 
587
611
  **Track-scoped rerun** (running `/draft:decompose <track>` on existing `hld.md` / `lld.md`):
612
+
588
613
  1. Read the existing HLD (and LLD if present)
589
614
  2. If the track's `spec.md` has materially changed, prefer `/draft:change` first to amend spec/plan and flag HLD/LLD impact
590
615
  3. Otherwise, regenerate the graph-fenced slots only (component diagram, component table, dependencies table, class table, data models). Author-driven sections (§IP, §Checklist, §PaaS, §UT, §Observability) and the §Approvals table are preserved verbatim
@@ -598,7 +623,7 @@ When adding new modules to the project-wide architecture:
598
623
 
599
624
  After defining module boundaries and interfaces:
600
625
 
601
- ```
626
+ ```text
602
627
  "Decomposition complete. Consider:
603
628
 
604
629
  Testing:
@@ -614,7 +639,8 @@ Architecture:
614
639
  ### Dependency Cycle Detection
615
640
 
616
641
  If dependency analysis (Step 4) detects cycles or high coupling:
617
- ```
642
+
643
+ ```text
618
644
  "Detected dependency cycles / high coupling. Consider:
619
645
  → /draft:tech-debt — Catalog architecture debt and prioritize remediation"
620
646
  ```
@@ -622,6 +648,7 @@ If dependency analysis (Step 4) detects cycles or high coupling:
622
648
  ### ADR Auto-Invocation
623
649
 
624
650
  When decomposition involves breaking a monolith, choosing module boundaries, or extracting services:
651
+
625
652
  - Auto-invoke: "This decomposition is a significant architectural decision. Creating ADR to document rationale."
626
653
  - Invoke `/draft:adr "Module boundary decisions for {project}"`
627
654
 
@@ -644,11 +671,13 @@ If `draft/graph/schema.yaml` does not exist, set `Graph files queried: NONE` and
644
671
  ## Graph Usage Report (append to output)
645
672
 
646
673
  Emit the canonical footer from [core/shared/graph-usage-report.md](../../core/shared/graph-usage-report.md) §Canonical footer. The lint hook `scripts/tools/check-graph-usage-report.sh` validates the section on save.
674
+
647
675
  ## Skill Telemetry
648
676
 
649
677
  As the last step after the completion announcement, emit a metrics record. Best-effort — never block.
650
678
 
651
679
  **Payload fields:**
680
+
652
681
  ```json
653
682
  {
654
683
  "skill": "decompose",
@@ -661,6 +690,7 @@ As the last step after the completion announcement, emit a metrics record. Best-
661
690
  ```
662
691
 
663
692
  **Emit call:**
693
+
664
694
  ```bash
665
695
  # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
666
696
  # is not exported into skill Bash). See core/shared/tool-resolver.md.