@drafthq/draft 3.5.3 → 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 (143) 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/hosts/cursor.js +3 -0
  7. package/cli/src/installer.js +8 -4
  8. package/cli/src/lib/cursor-registry.js +10 -0
  9. package/cli/src/lib/fsx.js +3 -0
  10. package/cli/src/lib/marker.js +8 -3
  11. package/core/agents/architect.md +21 -9
  12. package/core/agents/debugger.md +5 -0
  13. package/core/agents/ops.md +7 -2
  14. package/core/agents/planner.md +7 -0
  15. package/core/agents/rca.md +14 -3
  16. package/core/agents/reviewer.md +1 -0
  17. package/core/agents/writer.md +6 -0
  18. package/core/knowledge-base.md +22 -3
  19. package/core/methodology.md +30 -5
  20. package/core/shared/condensation.md +28 -18
  21. package/core/shared/context-verify.md +3 -1
  22. package/core/shared/cross-skill-dispatch.md +7 -3
  23. package/core/shared/draft-context-loading.md +3 -0
  24. package/core/shared/git-report-metadata.md +2 -1
  25. package/core/shared/graph-query.md +24 -26
  26. package/core/shared/graph-usage-report.md +1 -1
  27. package/core/shared/jira-sync.md +10 -6
  28. package/core/shared/okf-retrieval.md +1 -1
  29. package/core/shared/parallel-analysis.md +14 -7
  30. package/core/shared/pattern-learning.md +2 -0
  31. package/core/shared/template-contract.md +1 -1
  32. package/core/shared/tool-resolver.md +20 -15
  33. package/core/shared/vcs-commands.md +5 -2
  34. package/core/templates/ai-context.md +3 -2
  35. package/core/templates/ai-profile.md +7 -0
  36. package/core/templates/architecture.md +6 -2
  37. package/core/templates/discovery.md +1 -1
  38. package/core/templates/guardrails.md +9 -0
  39. package/core/templates/hld.md +5 -4
  40. package/core/templates/intake-questions.md +45 -0
  41. package/core/templates/jira.md +11 -2
  42. package/core/templates/lld.md +8 -5
  43. package/core/templates/okf/concept.md +0 -1
  44. package/core/templates/plan.md +1 -1
  45. package/core/templates/product.md +11 -2
  46. package/core/templates/rca.md +6 -0
  47. package/core/templates/service-index.md +1 -0
  48. package/core/templates/spec.md +15 -0
  49. package/core/templates/tech-stack.md +12 -0
  50. package/core/templates/workflow.md +20 -0
  51. package/integrations/agents/AGENTS.md +1449 -817
  52. package/integrations/copilot/.github/copilot-instructions.md +1449 -817
  53. package/package.json +1 -1
  54. package/scripts/fetch-memory-engine.sh +25 -7
  55. package/scripts/lib.sh +90 -6
  56. package/scripts/tools/_graph_queries.sh +22 -8
  57. package/scripts/tools/_lib.sh +81 -11
  58. package/scripts/tools/adr-index.sh +1 -1
  59. package/scripts/tools/check-repo-size.sh +125 -0
  60. package/scripts/tools/check-skill-line-caps.sh +3 -4
  61. package/scripts/tools/check-template-noop.sh +0 -1
  62. package/scripts/tools/check-track-hygiene.sh +41 -21
  63. package/scripts/tools/classify-files.sh +3 -3
  64. package/scripts/tools/cycle-detect.sh +18 -17
  65. package/scripts/tools/detect-test-framework.sh +1 -1
  66. package/scripts/tools/emit-skill-metrics.sh +7 -2
  67. package/scripts/tools/fix-whitespace.sh +3 -0
  68. package/scripts/tools/freshness-check.sh +2 -2
  69. package/scripts/tools/git-metadata.sh +12 -6
  70. package/scripts/tools/graph-arch.sh +5 -11
  71. package/scripts/tools/graph-callers.sh +10 -15
  72. package/scripts/tools/graph-deps.sh +3 -10
  73. package/scripts/tools/graph-errors.sh +4 -11
  74. package/scripts/tools/graph-hierarchy.sh +4 -11
  75. package/scripts/tools/graph-impact.sh +21 -19
  76. package/scripts/tools/graph-init.sh +13 -9
  77. package/scripts/tools/graph-preflight.sh +4 -1
  78. package/scripts/tools/graph-query.sh +74 -18
  79. package/scripts/tools/graph-risk.sh +3 -10
  80. package/scripts/tools/graph-search.sh +4 -11
  81. package/scripts/tools/graph-snapshot.sh +38 -9
  82. package/scripts/tools/graph-snippet.sh +3 -10
  83. package/scripts/tools/graph-tests.sh +3 -10
  84. package/scripts/tools/graph-traces.sh +3 -10
  85. package/scripts/tools/hotspot-rank.sh +6 -12
  86. package/scripts/tools/install-smoke-test.sh +223 -0
  87. package/scripts/tools/mermaid-from-graph.sh +5 -11
  88. package/scripts/tools/migrate-track-frontmatter.sh +11 -10
  89. package/scripts/tools/okf-coverage-check.sh +8 -7
  90. package/scripts/tools/okf-emit-catalog.sh +256 -0
  91. package/scripts/tools/okf-fix-links.sh +251 -0
  92. package/scripts/tools/okf-plan-concepts.sh +242 -14
  93. package/scripts/tools/okf-render-views.sh +63 -21
  94. package/scripts/tools/okf-validate-all.sh +20 -9
  95. package/scripts/tools/okf-validate-quality.sh +15 -10
  96. package/scripts/tools/okf-validate.sh +20 -6
  97. package/scripts/tools/parse-git-log.sh +23 -5
  98. package/scripts/tools/parse-reports.sh +1 -1
  99. package/scripts/tools/render-track.sh +1 -1
  100. package/scripts/tools/resolve-tools.sh +24 -8
  101. package/scripts/tools/run-coverage.sh +1 -1
  102. package/scripts/tools/scan-markers.sh +4 -4
  103. package/scripts/tools/validate-frontmatter.sh +2 -2
  104. package/scripts/tools/verify-citations.sh +3 -4
  105. package/scripts/tools/verify-doc-anchors.sh +14 -34
  106. package/scripts/tools/verify-graph-binary.sh +15 -5
  107. package/skills/GRAPH.md +21 -10
  108. package/skills/adr/SKILL.md +25 -7
  109. package/skills/assist-review/SKILL.md +2 -1
  110. package/skills/bughunt/SKILL.md +55 -12
  111. package/skills/bughunt/references/regression-tests.md +14 -4
  112. package/skills/change/SKILL.md +19 -9
  113. package/skills/coverage/SKILL.md +28 -12
  114. package/skills/debug/SKILL.md +13 -3
  115. package/skills/decompose/SKILL.md +42 -12
  116. package/skills/deep-review/SKILL.md +19 -6
  117. package/skills/deploy-checklist/SKILL.md +10 -3
  118. package/skills/documentation/SKILL.md +12 -1
  119. package/skills/draft/SKILL.md +40 -29
  120. package/skills/draft/context-files.md +8 -1
  121. package/skills/draft/quality-guide.md +10 -2
  122. package/skills/graph/SKILL.md +2 -2
  123. package/skills/impact/SKILL.md +4 -2
  124. package/skills/implement/SKILL.md +62 -20
  125. package/skills/incident-response/SKILL.md +5 -2
  126. package/skills/init/SKILL.md +112 -30
  127. package/skills/init/references/architecture-spec.md +32 -8
  128. package/skills/init/references/okf-emitter.md +42 -78
  129. package/skills/jira/SKILL.md +33 -13
  130. package/skills/jira/references/review.md +61 -19
  131. package/skills/learn/SKILL.md +30 -7
  132. package/skills/new-track/SKILL.md +73 -18
  133. package/skills/quick-review/SKILL.md +8 -3
  134. package/skills/revert/SKILL.md +11 -5
  135. package/skills/review/SKILL.md +126 -27
  136. package/skills/review/references/zero-setup-mode.md +117 -0
  137. package/skills/standup/SKILL.md +10 -2
  138. package/skills/status/SKILL.md +7 -7
  139. package/skills/tech-debt/SKILL.md +9 -3
  140. package/skills/testing-strategy/SKILL.md +10 -2
  141. package/skills/tour/SKILL.md +2 -1
  142. package/skills/upload/SKILL.md +4 -3
  143. package/core/templates/track-architecture.md +0 -311
@@ -14,7 +14,7 @@ First resolve the bundled helpers:
14
14
  ```bash
15
15
  # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
16
16
  # is not exported into skill Bash). See core/shared/tool-resolver.md.
17
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
17
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
18
18
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
19
19
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
20
20
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -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
 
@@ -417,7 +434,7 @@ Resolve the script via the canonical tool resolver (see [core/shared/tool-resolv
417
434
  ```bash
418
435
  # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
419
436
  # is not exported into skill Bash). See core/shared/tool-resolver.md.
420
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
437
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
421
438
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
422
439
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
423
440
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -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,10 +690,11 @@ 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.
667
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
697
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
668
698
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
669
699
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
670
700
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -12,10 +12,11 @@ Perform an exhaustive end-to-end lifecycle review of a service, component, or mo
12
12
  When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-first lookup contract in [core/shared/graph-query.md](../../core/shared/graph-query.md) §Mandatory Lookup Contract. Deep-review uses the graph to **narrow review scope** — a key 30–50% scope reduction:
13
13
 
14
14
  First resolve the bundled helpers:
15
+
15
16
  ```bash
16
17
  # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
17
18
  # is not exported into skill Bash). See core/shared/tool-resolver.md.
18
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
19
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
19
20
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
20
21
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
21
22
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -28,11 +29,12 @@ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
28
29
 
29
30
  Filesystem `grep` is reserved for source-text scans (API contract strings, secret patterns, log message audits). Module enumeration and caller tracing go through the graph.
30
31
 
31
- ## Red Flags - STOP if you're:
32
+ ## Red Flags - STOP if you're
32
33
 
33
34
  See [shared red flags](../../core/shared/red-flags.md) — applies to all code-touching skills.
34
35
 
35
36
  Skill-specific:
37
+
36
38
  - Acting without reading the Draft context (`draft/.ai-context.md`, `draft/tech-stack.md`, `draft/product.md`)
37
39
  - Modifying production code. This command is for auditing and reporting only. Fixes should be handled in a separate implementation track.
38
40
  - Reviewing a module that was already reviewed recently, unless explicitly requested.
@@ -74,6 +76,7 @@ If `.ai-context.md` is missing, check for `draft/architecture.md` as a fallback
74
76
  ## Review Phases
75
77
 
76
78
  ### Phase 1: Context & Structural Analysis
79
+
77
80
  - Load Draft context following the procedure in `core/shared/draft-context-loading.md`. Use loaded context to understand intended boundaries and critical invariants.
78
81
  - **Load track HLD/LLD if any track owns this module.** Scan `draft/tracks/*/hld.md` for §Detailed Design components matching the module path. When found, extract claims from §High-Level Design / Key Design Decisions, §Checklist (Performance/Scale/Security/Resiliency/Multi-tenancy/Upgrade/Cost), §Observability, §Deployment, and any LLD §Classes and Interfaces invariants and §Error Handling policies. These claims become the design contract this audit measures against (HLD claims vs code reality).
79
82
  - **Load Learned Anti-Patterns** — If `draft/guardrails.md` exists, read the `## Learned Anti-Patterns` section before analysis begins. During the audit, when an issue matches a learned anti-pattern, prefix the finding with `[KNOWN-ANTI-PATTERN: {pattern name}]`. This separates newly discovered issues from documented recurring patterns and allows the report to recommend systemic remediation rather than isolated fixes.
@@ -124,7 +127,7 @@ Every finding in this phase must cite the relevant rule range (e.g., `[RC-008..R
124
127
  - **Latency profiles:** Are p50, p95, p99 latency targets defined and achievable?
125
128
  - **Error budget:** What percentage of the error budget has been consumed? Is the module in "protect" or "innovate" mode?
126
129
  - **Availability:** Does the module's uptime target (99.9%, 99.99%) match its actual architecture?
127
- - If no SLOs are defined, recommend defining them. Reference: Google SRE (https://sre.google/sre-book/service-level-objectives/).
130
+ - If no SLOs are defined, recommend defining them. Reference: Google SRE (<https://sre.google/sre-book/service-level-objectives/>).
128
131
  - **Database Schema Analysis:**
129
132
  - **Missing indexes:** Queries filtering/joining on unindexed columns.
130
133
  - **Wide table scans:** SELECT * or queries without WHERE clauses on large tables.
@@ -154,6 +157,7 @@ For each HLD claim extracted in Phase 1, validate it against code:
154
157
  Surface gaps as findings with prefix `[HLD-DRIFT: §<section>]` (Important if the gap is documentation-vs-implementation drift; Critical if the code violates a stated invariant or security claim).
155
158
 
156
159
  ### Phase 4: Identify Actionable Fixes (Spec Generation)
160
+
157
161
  Instead of mutating the source code, translate all findings into clear, actionable requirements that a developer (or agent) can implement via Test-Driven Development.
158
162
 
159
163
  ### Phase 5: Resilience & Chaos Engineering Assessment
@@ -225,11 +229,13 @@ reviewer: "{model name from runtime}"
225
229
  **Verdict:** PASS / CONDITIONAL PASS / FAIL
226
230
 
227
231
  **Verdict criteria:**
232
+
228
233
  - **FAIL** = any Critical issue found.
229
234
  - **CONDITIONAL PASS** = no Critical issues but Important issues exist.
230
235
  - **PASS** = only Minor issues or no issues.
231
236
 
232
237
  Format findings as actionable tasks:
238
+
233
239
  ```markdown
234
240
  ### [Critical/Important/Minor] Issue Name `[RC-### or CQ-### or SEC-## if applicable]`
235
241
  **File:** path/to/file:line
@@ -245,6 +251,7 @@ Cite the most specific rule ID from `core/guardrails/review-checks.md` (RC-###),
245
251
  **For Phase 3 (Security):** Load `core/guardrails/security.md` and apply the 5-step security reasoning chain. Hard red line violations (SEC-01…SEC-10) are always Critical. Run `core/guardrails/dependency-triage.md` procedure for any dependency manifest files in the module's scope `[RC-014]`.
246
252
 
247
253
  **Constraints:**
254
+
248
255
  - Do not refactor code yourself.
249
256
  - Flag ambiguous fixes for human review instead of guessing.
250
257
  - If the module is too large, decompose it and review sub-modules sequentially.
@@ -272,6 +279,7 @@ Every deep-review report must end with a `## Next Actions` section listing the s
272
279
  ```
273
280
 
274
281
  Rules:
282
+
275
283
  - Production-blocking findings (`[SEC-*]`, ACID violations, unbounded resource use) produce blocker rows.
276
284
  - Suggest `/draft:adr` for structural changes, `/draft:new-track` for multi-week remediation, `/draft:incident-response` for hot issues, `/draft:tech-debt` for systemic items.
277
285
  - Cap at 10 actions; group related fixes under one row.
@@ -283,14 +291,16 @@ Rules:
283
291
  After deep-review audit completion:
284
292
 
285
293
  **If architecture debt found:**
286
- ```
294
+
295
+ ```text
287
296
  "Architecture debt identified in module audit. Consider:
288
297
  → /draft:tech-debt — Catalog and prioritize the architecture debt
289
298
  → /draft:adr — Document undiscovered design decisions found during review"
290
299
  ```
291
300
 
292
301
  **If documentation gaps found:**
293
- ```
302
+
303
+ ```text
294
304
  → /draft:documentation runbook — Generate operational runbook for this module"
295
305
  ```
296
306
 
@@ -307,11 +317,13 @@ If `draft/graph/schema.yaml` does not exist, set `Graph files queried: NONE` and
307
317
  ## Graph Usage Report (append to report)
308
318
 
309
319
  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.
320
+
310
321
  ## Skill Telemetry
311
322
 
312
323
  As the last step after saving the deep-review report, emit a metrics record. Best-effort — never block.
313
324
 
314
325
  **Payload fields:**
326
+
315
327
  ```json
316
328
  {
317
329
  "skill": "deep-review",
@@ -327,10 +339,11 @@ As the last step after saving the deep-review report, emit a metrics record. Bes
327
339
  ```
328
340
 
329
341
  **Emit call:**
342
+
330
343
  ```bash
331
344
  # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
332
345
  # is not exported into skill Bash). See core/shared/tool-resolver.md.
333
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
346
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
334
347
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
335
348
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
336
349
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -17,11 +17,12 @@ When `draft/graph/schema.yaml` exists, this skill **must** follow the graph-firs
17
17
 
18
18
  Filesystem `grep` is reserved for source-text scans (migration file names, flag-key strings). Module/impact discovery goes through the graph.
19
19
 
20
- ## Red Flags — STOP if you're:
20
+ ## Red Flags — STOP if you're
21
21
 
22
22
  See [shared red flags](../../core/shared/red-flags.md) — applies to all code-touching skills.
23
23
 
24
24
  Skill-specific:
25
+
25
26
  - Deploying without a rollback plan
26
27
  - Skipping database migration verification
27
28
  - Deploying on Friday without explicit team approval
@@ -67,7 +68,7 @@ by validator.
67
68
  ```bash
68
69
  TRACK_DIR="$1" # absolute path to track-under-deploy, or .
69
70
 
70
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
71
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
71
72
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
72
73
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
73
74
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -87,6 +88,7 @@ not be considered "ready to deploy" if `pre_deploy_status != passing`.
87
88
  ## Step 1: Parse Arguments
88
89
 
89
90
  Check for arguments:
91
+
90
92
  - `/draft:deploy-checklist` — Interactive: detect active track or ask for service name
91
93
  - `/draft:deploy-checklist <service>` — Generate checklist for named service
92
94
  - `/draft:deploy-checklist track <id>` — Generate from track's change scope
@@ -111,7 +113,7 @@ Generate a four-phase checklist customized to the project's tech stack. Adapt it
111
113
 
112
114
  ### Phase 0: HLD/LLD Gate (track-scoped only, when hld.md exists)
113
115
 
114
- > ** blocker:** the HLD's §Checklist sections were the design-time commitment. If they are still empty at deploy time, the design was never validated against operational reality. This phase enforces that.
116
+ > **blocker:** the HLD's §Checklist sections were the design-time commitment. If they are still empty at deploy time, the design was never validated against operational reality. This phase enforces that.
115
117
 
116
118
  For `criticality ∈ {high, mission-critical}` (read from `hld.md` frontmatter `classification.criticality`), every row below MUST be checked before Phase 1 begins. For `standard` criticality, missing rows produce warnings but do not block. For `low`, this phase is informational.
117
119
 
@@ -176,6 +178,7 @@ If a partial file is needed for tracking, write it with `status: BLOCKED` in the
176
178
  ### Rollback Triggers
177
179
 
178
180
  Initiate rollback if ANY of these occur:
181
+
179
182
  - Error rate exceeds 2x baseline
180
183
  - p95 latency exceeds 3x baseline
181
184
  - Data corruption detected
@@ -195,10 +198,12 @@ Initiate rollback if ANY of these occur:
195
198
  ## Step 4: Present and Track
196
199
 
197
200
  Present the checklist interactively. For each critical item (marked **bold**):
201
+
198
202
  - If unchecked and user wants to proceed: warn "Critical item unchecked: [item]. Are you sure? [y/N]"
199
203
  - Default: stop and address critical items
200
204
 
201
205
  Allow the user to:
206
+
202
207
  - Check off items as they complete them
203
208
  - Add custom items specific to this deployment
204
209
  - Mark items as N/A with justification
@@ -219,6 +224,7 @@ Include the report header table immediately after frontmatter:
219
224
  ```
220
225
 
221
226
  Save to:
227
+
222
228
  - Track-scoped: `draft/tracks/<id>/deploy-checklist.md`
223
229
  - Standalone: `draft/deploy-checklist-<timestamp>.md` with symlink `deploy-checklist-latest.md`
224
230
 
@@ -241,6 +247,7 @@ If `draft/graph/schema.yaml` does not exist, set `Graph files queried: NONE` and
241
247
  ## Graph Usage Report (append to checklist)
242
248
 
243
249
  Emit the canonical footer from [core/shared/graph-usage-report.md](../../core/shared/graph-usage-report.md). The lint hook `scripts/tools/check-graph-usage-report.sh` validates the section on save.
250
+
244
251
  ## Cross-Skill Dispatch
245
252
 
246
253
  - **Auto-invoked by:** `/draft:upload` (pre-upload verification)
@@ -7,7 +7,7 @@ description: Technical documentation writing and maintenance. Modes — readme,
7
7
 
8
8
  You are generating or updating technical documentation for this project using structured writing principles.
9
9
 
10
- ## Red Flags — STOP if you're:
10
+ ## Red Flags — STOP if you're
11
11
 
12
12
  - Writing docs without reading the code first
13
13
  - Duplicating information that exists elsewhere (link instead)
@@ -22,6 +22,7 @@ You are generating or updating technical documentation for this project using st
22
22
  ## Pre-Check
23
23
 
24
24
  1. Check for Draft context:
25
+
25
26
  ```bash
26
27
  ls draft/ 2>/dev/null
27
28
  ```
@@ -41,6 +42,7 @@ If `draft/` doesn't exist, this skill works standalone — generate docs from co
41
42
  ## Step 2: Gather Source Material
42
43
 
43
44
  ### README Mode
45
+
44
46
  - Read existing `README.md` (if any)
45
47
  - Read `draft/product.md` — Product vision, users, goals
46
48
  - Read `draft/tech-stack.md` — Technologies, setup requirements
@@ -48,6 +50,7 @@ If `draft/` doesn't exist, this skill works standalone — generate docs from co
48
50
  - Scan for `Makefile`, `package.json`, `pyproject.toml` — Build/run commands
49
51
 
50
52
  ### Runbook Mode
53
+
51
54
  - Read `draft/architecture.md` or `draft/.ai-context.md` — Service topology, dependencies
52
55
  - Read `draft/workflow.md` — Deployment conventions
53
56
  - Read `draft/tech-stack.md` — Infrastructure details
@@ -55,12 +58,14 @@ If `draft/` doesn't exist, this skill works standalone — generate docs from co
55
58
  - If Jira MCP available: check recent incident tickets for the service
56
59
 
57
60
  ### API Mode
61
+
58
62
  - Read source code for public interfaces, exported functions, API routes
59
63
  - Read existing API docs (Swagger, OpenAPI, JSDoc, docstrings)
60
64
  - Read `draft/architecture.md` — API conventions, data models
61
65
  - Read `draft/tech-stack.md` — API framework details
62
66
 
63
67
  ### Onboarding Mode
68
+
64
69
  - Read ALL draft context files in order:
65
70
  1. `draft/product.md` — What is this project?
66
71
  2. `draft/tech-stack.md` — What technologies?
@@ -83,6 +88,7 @@ Follow these principles (from `core/agents/writer.md`):
83
88
  ## Step 4: Generate Document
84
89
 
85
90
  ### README Structure
91
+
86
92
  ```markdown
87
93
  # {Project Name}
88
94
 
@@ -105,6 +111,7 @@ Follow these principles (from `core/agents/writer.md`):
105
111
  ```
106
112
 
107
113
  ### Runbook Structure
114
+
108
115
  ```markdown
109
116
  # Runbook: {Service Name}
110
117
 
@@ -128,6 +135,7 @@ Follow these principles (from `core/agents/writer.md`):
128
135
  ```
129
136
 
130
137
  ### API Documentation Structure
138
+
131
139
  ```markdown
132
140
  # API: {Module Name}
133
141
 
@@ -144,6 +152,7 @@ Follow these principles (from `core/agents/writer.md`):
144
152
  ```
145
153
 
146
154
  ### Onboarding Structure
155
+
147
156
  ```markdown
148
157
  # Welcome to {Project Name}
149
158
 
@@ -172,6 +181,7 @@ Follow these principles (from `core/agents/writer.md`):
172
181
  ## Step 5: Output
173
182
 
174
183
  Save to:
184
+
175
185
  - README: `README.md` in project root
176
186
  - Runbook: `draft/docs/runbook-<service>.md`
177
187
  - API: `draft/docs/api-<module>.md`
@@ -180,6 +190,7 @@ Save to:
180
190
  Create `draft/docs/` directory if needed.
181
191
 
182
192
  **Pre-save validation:**
193
+
183
194
  - Every file path referenced in the doc resolves to a real file (broken links are a common LLM failure mode here).
184
195
  - Every relative link in the doc resolves under the project root.
185
196
  - Code blocks copied from sources match the current commit (no stale snippets).