@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
@@ -12,10 +12,11 @@ You are conducting a code review using Draft's Context-Driven Development method
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. Stage 1 (Automated Validation) **starts from the graph**:
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"
@@ -27,11 +28,14 @@ DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
27
28
 
28
29
  Filesystem `grep` is reserved for source-text scans (string literals, log messages, regex matches in code) — not for discovering modules, files, or callers when the graph can answer.
29
30
 
30
- ## Red Flags - STOP if you're:
31
+ When `draft/graph/schema.yaml` does **not** exist, the graph checks do not run and must be reported as not run — never inferred from grep. See Step 0.
32
+
33
+ ## Red Flags - STOP if you're
31
34
 
32
35
  See [shared red flags](../../core/shared/red-flags.md) — applies to all code-touching skills.
33
36
 
34
37
  Skill-specific:
38
+
35
39
  - Reviewing without reading the track's spec.md and plan.md first
36
40
  - Reporting findings without reading the actual code
37
41
  - Skipping spec compliance stage and jumping to code quality
@@ -47,6 +51,7 @@ Skill-specific:
47
51
  This command is the **canonical review parent**.
48
52
 
49
53
  It orchestrates review workflows at two levels:
54
+
50
55
  - **Track-level:** Review against spec.md and plan.md (three-stage: automated validation, spec compliance, code quality)
51
56
  - **Project-level:** Review arbitrary changes (automated validation + code quality)
52
57
 
@@ -67,6 +72,27 @@ Automated static validation (OWASP secrets, dead code, dependency cycles, N+1 pa
67
72
 
68
73
  ---
69
74
 
75
+ ## Step 0: Detect Setup Level (run first, always)
76
+
77
+ `/draft:review` is **context-optional**. It runs on an un-indexed repo with no setup, so a first-time user gets findings before paying for `/draft:init`.
78
+
79
+ ```bash
80
+ ls draft/ 2>/dev/null # absent -> zero-setup mode
81
+ ls draft/graph/schema.yaml 2>/dev/null # absent -> graph-less
82
+ ```
83
+
84
+ | `draft/` | graph | Mode | Behavior |
85
+ |---|---|---|---|
86
+ | absent | absent | **zero-setup** | Follow [references/zero-setup-mode.md](references/zero-setup-mode.md) for scope resolution, stage behavior, output, and CTA. Skip Steps 2.1–2.2 and Stage 2. |
87
+ | present | absent | **graph-less** | Full workflow minus graph queries. Report every graph check as not run. |
88
+ | present | present | **full** | Everything below. |
89
+
90
+ Do **not** print "Draft not initialized" and stop — that error belongs to skills that cannot function without context (`/draft:learn`, `/draft:deep-review`, `/draft:tech-debt`, `/draft:implement`). See [core/shared/context-verify.md](../../core/shared/context-verify.md).
91
+
92
+ In any degraded mode: report what did not run, never simulate it, and end with the specific checks that indexing would add.
93
+
94
+ ---
95
+
70
96
  ## Step 1: Parse Arguments
71
97
 
72
98
  Extract and validate command arguments from user input.
@@ -74,18 +100,21 @@ Extract and validate command arguments from user input.
74
100
  ### Supported Arguments
75
101
 
76
102
  **Explicit review modes:**
103
+
77
104
  - `quick` - Route to `/draft:quick-review`
78
105
  - `bughunt` - Route to `/draft:bughunt`
79
106
  - `deep` - Route to `/draft:deep-review`
80
107
  - `assist` - Route to `/draft:assist-review`
81
108
 
82
109
  **Scope specifiers (mutually exclusive for baseline review):**
110
+
83
111
  - `track <id|name>` - Review specific track (exact ID or fuzzy name match)
84
112
  - `project` - Review uncommitted changes (`git diff HEAD`)
85
113
  - `files <pattern>` - Review specific file pattern (e.g., `src/**/*.ts`)
86
114
  - `commits <range>` - Review commit range (e.g., `main...HEAD`, `abc123..def456`)
87
115
 
88
116
  **Quality integration modifiers:**
117
+
89
118
  - `with-bughunt` - Include `/draft:bughunt` results
90
119
  - `with-assist` - Include `/draft:assist-review` summary
91
120
  - `full` - Enable all sensible add-ons for the selected scope (`with-bughunt`, `with-assist`, and any justified deep-review escalation)
@@ -100,10 +129,12 @@ Extract and validate command arguments from user input.
100
129
  ### Default Behavior
101
130
 
102
131
  If no arguments provided:
132
+
103
133
  - Auto-detect active `[~]` In Progress track from `draft/tracks.md`
104
134
  - If no `[~]` track, find first `[ ]` Pending track
105
135
  - If track found: display `Auto-detected track: <id> - <name> [<status>]` and proceed
106
136
  - If no track is found but the repo has local changes: default to project-level review of current changes
137
+ - If no `draft/tracks.md` exists (zero-setup mode): resolve scope from git per `references/zero-setup-mode.md` §Scope resolution without tracks — uncommitted changes, else branch-vs-default diff, else `HEAD`
107
138
  - If no track and no changes: error "No review scope found. Specify a track, files, commit range, or create changes to review."
108
139
 
109
140
  ---
@@ -145,9 +176,11 @@ Based on parsed arguments, determine review scope and load appropriate context.
145
176
  #### 2.1: Resolve Track
146
177
 
147
178
  1. **Check if argument is exact directory match:**
179
+
148
180
  ```bash
149
181
  ls draft/tracks/<arg>/ 2>/dev/null
150
182
  ```
183
+
151
184
  If exists → use this track
152
185
 
153
186
  2. **Parse tracks.md for fuzzy matching:**
@@ -164,12 +197,14 @@ Based on parsed arguments, determine review scope and load appropriate context.
164
197
  3. **Handle matches:**
165
198
  - **Exact match:** Use immediately
166
199
  - **Multiple matches:** Display numbered list with format:
167
- ```
200
+
201
+ ```text
168
202
  Multiple tracks match '<input>':
169
203
  1. <id> - <name> [<status>]
170
204
  2. <id> - <name> [<status>]
171
205
  Select track (1-N):
172
206
  ```
207
+
173
208
  Validate selection is within 1-N range. Re-prompt on invalid input.
174
209
  - **No matches:** Error with suggestions (closest 3 by edit distance)
175
210
 
@@ -178,6 +213,7 @@ Based on parsed arguments, determine review scope and load appropriate context.
178
213
  Once track is resolved:
179
214
 
180
215
  1. **Verify track directory exists:**
216
+
181
217
  ```bash
182
218
  ls draft/tracks/<id>/ 2>/dev/null
183
219
  ```
@@ -187,12 +223,12 @@ Once track is resolved:
187
223
  - Extract: Summary, Requirements, Acceptance Criteria, Non-Goals
188
224
  - Store for Stage 1 compliance checks
189
225
 
190
- 2.5. **Read hld.md and lld.md (when present):**
226
+ 3. **Read hld.md and lld.md (when present):**
191
227
  - `draft/tracks/<id>/hld.md` — extract §High-Level Design / Architecture, §Detailed Design (per-component subsections), §Dependencies, §Checklist (Performance/Scale/Security/Resiliency/Multi-tenancy/Upgrade/Cost), §Approvals
192
228
  - `draft/tracks/<id>/lld.md` — extract §Classes and Interfaces (signatures, invariants), §Data Model (schemas, migrations), §Error Handling, §Observability metrics
193
229
  - Store for HLD/LLD compliance pass (Stage 1.5 below)
194
230
 
195
- 3. **Read plan.md:**
231
+ 4. **Read plan.md:**
196
232
  - Load `draft/tracks/<id>/plan.md`
197
233
  - Extract commit SHAs from completed `[x]` task lines only. Match pattern: 7+ character hex strings in parentheses, regex `\(([a-f0-9]{7,})\)`. Example: `- [x] **Task 1.1:** Description (7a7dc85)`. Collect SHAs in order of appearance; deduplicate keeping first occurrence.
198
234
  - Determine commit range:
@@ -201,15 +237,16 @@ Once track is resolved:
201
237
  - If the parent does NOT exist (first commit in the repo — `git rev-parse` fails): use the empty tree SHA `4b825dc642cb6eb9a060e54bf8d69288fbee4904` as the range start, i.e., `4b825dc642cb6eb9a060e54bf8d69288fbee4904..<last_SHA>`. Alternatively, for single-commit ranges, use `git diff-tree --root -p <first_SHA>` to obtain the diff.
202
238
  - Last commit: `<last_SHA>`
203
239
 
204
- 4. **Check for incomplete work:**
240
+ 5. **Check for incomplete work:**
205
241
  - Parse plan.md task statuses
206
242
  - Count `[ ]`, `[~]`, `[x]`, `[!]` tasks
207
243
  - If `[ ]` or `[~]` tasks exist: Display warning and proceed:
208
- ```
244
+
245
+ ```yaml
209
246
  Warning: Track has N incomplete tasks (M in-progress, K pending). Reviewing completed work only.
210
247
  ```
211
248
 
212
- 5. **Handle missing files:**
249
+ 6. **Handle missing files:**
213
250
  - Missing spec.md: Error "spec.md not found for track <id>"
214
251
  - Missing plan.md: Warn "plan.md not found, skipping commit extraction"
215
252
  - No commits found: Warn "No commits found in plan.md, review may be incomplete"
@@ -228,17 +265,21 @@ Once track is resolved:
228
265
  - Scope: Specific files matching glob pattern
229
266
  - Command: `git diff HEAD -- <pattern>`
230
267
  - Validate pattern matches files:
268
+
231
269
  ```bash
232
270
  git ls-files <pattern> | head -1
233
271
  ```
272
+
234
273
  If empty: Error "No files match pattern '<pattern>'"
235
274
 
236
275
  3. **`commits <range>` argument:**
237
276
  - Scope: Commit range
238
277
  - Validate range exists:
278
+
239
279
  ```bash
240
280
  git rev-parse <range> 2>/dev/null
241
281
  ```
282
+
242
283
  If fails: Error "Invalid commit range '<range>'"
243
284
  - Command: `git diff <range>`
244
285
 
@@ -250,8 +291,9 @@ For project-level reviews (no track context):
250
291
  Read and follow the base procedure in `core/shared/draft-context-loading.md`.
251
292
 
252
293
  2. **Note limitations:**
253
- - No spec.md → Skip Stage 1 (spec compliance)
254
- - Run Stage 2 (code quality) only
294
+ - No spec.md → skip Stage 2 (spec compliance); say it was skipped and why
295
+ - Run Stage 1 (automated validation) and Stage 3 (code quality)
296
+ - Zero-setup mode → also declare every unavailable graph check, per `references/zero-setup-mode.md` §What degrades, precisely
255
297
 
256
298
  ---
257
299
 
@@ -323,6 +365,7 @@ Generate diff output using smart chunking to avoid context overflow.
323
365
  ### 3.1: Determine Diff Size
324
366
 
325
367
  Run shortstat to check diff size:
368
+
326
369
  ```bash
327
370
  git diff --shortstat <range>
328
371
  ```
@@ -332,18 +375,24 @@ Parse output robustly — handle both singular (`1 file changed`) and plural (`N
332
375
  ### 3.2: Smart Chunking Strategy
333
376
 
334
377
  **Small/Medium changes (<300 lines changed):**
378
+
335
379
  - Run full diff in one pass:
380
+
336
381
  ```bash
337
382
  git diff <range>
338
383
  ```
384
+
339
385
  - Store complete diff for analysis
340
386
 
341
387
  **Large changes (≥300 lines changed):**
388
+
342
389
  - Announce: "Large changeset detected (N files). Using file-by-file review mode."
343
390
  - Get file list:
391
+
344
392
  ```bash
345
393
  git diff --name-only <range>
346
394
  ```
395
+
347
396
  - For each file:
348
397
  - Display progress: `[N/M] Reviewing <filename>`
349
398
  - Run: `git diff <range> -- <file>`
@@ -354,6 +403,7 @@ Parse output robustly — handle both singular (`1 file changed`) and plural (`N
354
403
  ### 3.3: Filter Files (Optional)
355
404
 
356
405
  Skip non-source files to focus review:
406
+
357
407
  - Ignore lock/minified: `*.lock`, `package-lock.json`, `yarn.lock`, `*.min.js`, `*.min.css`, `*.map`
358
408
  - Ignore build artifacts: `dist/`, `build/`, `target/`, `out/`, `__pycache__/`, `*.pyc`
359
409
  - Ignore vendored: `node_modules/`, `vendor/`, `.git/`
@@ -381,10 +431,11 @@ For the files changed in the diff, perform static checks using `grep` or similar
381
431
  - **Blast Radius Assessment** (if the `draft/graph/` snapshot exists):
382
432
 
383
433
  First resolve the bundled helpers:
434
+
384
435
  ```bash
385
436
  # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
386
437
  # is not exported into skill Bash). See core/shared/tool-resolver.md.
387
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
438
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
388
439
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
389
440
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
390
441
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
@@ -458,6 +509,7 @@ For the files changed in the diff, perform static checks using `grep` or similar
458
509
  - **E**levation of Privilege: Are authorization checks in place? (RBAC/ABAC check)
459
510
 
460
511
  **Verdict:**
512
+
461
513
  - **PASS:** No critical issues found → Proceed to Stage 2
462
514
  - **FAIL:** ANY Critical issue found (e.g., circular dependency, hardcoded secret, raw SQL injection) → List the static analysis failures, generate the review report, and **STOP**. Do not proceed to Stage 2. This prevents wasting effort on structurally broken code.
463
515
 
@@ -473,7 +525,7 @@ After completing Stage 1, recommend appropriate static analysis tools based on t
473
525
  | Go | gosec, staticcheck |
474
526
  | Rust | `cargo clippy`, `cargo audit` |
475
527
  | C/C++ | Clang Static Analyzer, cppcheck |
476
- | Multi-language | Semgrep (https://semgrep.dev/), CodeQL (semantic code analysis) |
528
+ | Multi-language | Semgrep (<https://semgrep.dev/>), CodeQL (semantic code analysis) |
477
529
 
478
530
  References: Meta Infer for CI integration patterns, Google Error Prone for compile-time analysis.
479
531
 
@@ -488,12 +540,14 @@ Load `spec.md` acceptance criteria and verify implementation:
488
540
  #### 4.1: Requirements Coverage
489
541
 
490
542
  For each functional requirement in `spec.md`:
543
+
491
544
  - [ ] Requirement implemented (find evidence in diff)
492
545
  - [ ] Files modified/created match requirement
493
546
 
494
547
  #### 4.2: Acceptance Criteria
495
548
 
496
549
  For each criterion in `spec.md`:
550
+
497
551
  - [ ] Criterion met (check against diff)
498
552
  - [ ] Test coverage exists (if TDD enabled)
499
553
 
@@ -503,6 +557,7 @@ For each criterion in `spec.md`:
503
557
  - [ ] No extra unneeded work (scope creep)
504
558
 
505
559
  **Verdict:**
560
+
506
561
  - **PASS:** All requirements implemented AND all acceptance criteria met → Proceed to Stage 3
507
562
  - **PASS WITH NOTES:** All requirements met but minor gaps in acceptance criteria verification → Proceed to Stage 3 with notes
508
563
  - **FAIL:** ANY requirement missing OR ANY acceptance criterion not met → List gaps, report, and stop (no Stage 3)
@@ -519,12 +574,14 @@ For each criterion in `spec.md`:
519
574
  #### 2.5.2: HLD §Detailed Design coverage
520
575
 
521
576
  For every component subsection in HLD §Detailed Design:
577
+
522
578
  - [ ] Files listed in the component diff actually exist at the cited `path:line`
523
579
  - [ ] Each component's `Whitebox requirements addressed` list is non-empty
524
580
 
525
581
  #### 2.5.3: HLD §Checklist populated
526
582
 
527
583
  For `criticality ∈ {high, mission-critical}` (frontmatter):
584
+
528
585
  - [ ] §Performance, §Scale, §Security, §Resiliency, §Multi-tenancy, §Upgrade, §Cost are populated (not still "<Describe...>" placeholders)
529
586
 
530
587
  #### 2.5.4: Code-vs-HLD drift
@@ -540,6 +597,7 @@ For `criticality ∈ {high, mission-critical}` (frontmatter):
540
597
  - [ ] Diff respects LLD invariants (thread safety, idempotency, ordering)
541
598
 
542
599
  **Verdict:**
600
+
543
601
  - PASS → Stage 3
544
602
  - FAIL → list HLD/LLD gaps with severity Critical (drift) or Important (incomplete sections), then Stage 3
545
603
 
@@ -550,24 +608,29 @@ For `criticality ∈ {high, mission-critical}` (frontmatter):
550
608
  Analyze semantic code quality across four dimensions:
551
609
 
552
610
  #### 4.4: Architecture
611
+
553
612
  - [ ] Follows project patterns (from tech-stack.md or CLAUDE.md)
554
613
  - [ ] Appropriate separation of concerns
555
614
  - [ ] Critical invariants honored (if `.ai-context.md` exists — check ## Critical Invariants section)
556
615
 
557
616
  #### 4.5: Error Handling
617
+
558
618
  - [ ] Errors handled at appropriate level
559
619
  - [ ] User-facing errors are helpful
560
620
  - [ ] No silent failures
561
621
 
562
622
  #### 4.6: Testing
623
+
563
624
  - [ ] Tests test real logic (not implementation details)
564
625
  - [ ] Edge cases have test coverage
565
626
 
566
627
  #### 4.7: Maintainability
628
+
567
629
  - [ ] Code is readable without excessive comments
568
630
  - [ ] Consistent naming and style
569
631
 
570
632
  #### 4.8: Diff Complexity Metrics
633
+
571
634
  - [ ] No functions exceeding cognitive complexity threshold (>15)
572
635
  - [ ] No files with high churn + high complexity (flag as refactoring candidates)
573
636
  - [ ] No deeply nested control flow (>3 levels of nesting)
@@ -604,10 +667,12 @@ Classify all findings by severity:
604
667
  | **Minor** | Style, optimization, nice-to-have | Note for later, don't block |
605
668
 
606
669
  **Scope-specific behavior:**
670
+
607
671
  - For **track-level** reviews: Run all three stages. Stage 2 uses `spec.md` acceptance criteria loaded in Step 2.
608
672
  - For **project-level** reviews: Skip Stage 2 (no spec). Run Stage 1 and Stage 3 only.
609
673
 
610
674
  **Issue format:**
675
+
611
676
  ```markdown
612
677
  - [ ] [File:line] Description of issue `[RC-### or CQ-### or SEC-## if applicable]`
613
678
  - **Impact:** [what breaks/degrades]
@@ -625,11 +690,13 @@ Run the specialist workflows selected explicitly or by the Step 2.5 heuristics.
625
690
  ### 5.1: Run Bughunt
626
691
 
627
692
  **Track-level:**
693
+
628
694
  ```bash
629
695
  /draft:bughunt --track <id>
630
696
  ```
631
697
 
632
698
  **Project-level:**
699
+
633
700
  ```bash
634
701
  /draft:bughunt
635
702
  ```
@@ -664,11 +731,13 @@ If deep-review is recommended but not auto-run:
664
731
  ### 5.4: Aggregate Findings
665
732
 
666
733
  Merge findings from:
734
+
667
735
  1. Reviewer agent (Stage 1, 2, 3)
668
736
  2. Bughunt results (if run)
669
737
  3. Deep-review findings relevant to the current diff (if run)
670
738
 
671
739
  **Deduplication:**
740
+
672
741
  - Two findings are duplicates if they reference the **same file and line number**
673
742
  - Severity ordering: **Critical > Important > Minor**
674
743
  - On duplicate: keep the finding with highest severity; merge tool attribution as "Found by: reviewer, bughunt, deep-review" as applicable
@@ -687,6 +756,7 @@ Create unified review report in markdown format.
687
756
  **Path:** `draft/tracks/<id>/review-report-<timestamp>.md` (where `<timestamp>` is generated via `date +%Y-%m-%dT%H%M`, e.g., `2026-03-15T1430`)
688
757
 
689
758
  After writing the timestamped report, create a symlink pointing to it:
759
+
690
760
  ```bash
691
761
  ln -sf review-report-<timestamp>.md draft/tracks/<id>/review-report-latest.md
692
762
  ```
@@ -797,11 +867,13 @@ ln -sf review-report-<timestamp>.md draft/tracks/<id>/review-report-latest.md
797
867
  **Path:** `draft/review-report-<timestamp>.md` (where `<timestamp>` is generated via `date +%Y-%m-%dT%H%M`, e.g., `2026-03-15T1430`)
798
868
 
799
869
  After writing the timestamped report, create a symlink pointing to it:
870
+
800
871
  ```bash
801
872
  ln -sf review-report-<timestamp>.md draft/review-report-latest.md
802
873
  ```
803
874
 
804
875
  Similar format but:
876
+
805
877
  - No Stage 2 section (no spec compliance)
806
878
  - Header shows scope instead of track ID:
807
879
  - `project`: "Scope: Uncommitted changes"
@@ -810,6 +882,10 @@ Similar format but:
810
882
  - Each run creates a new timestamped file; the `-latest.md` symlink always points to the most recent report
811
883
  - Include "Previous review: <timestamp>" if a prior `-latest.md` symlink exists (read its target to determine the previous timestamp)
812
884
 
885
+ ### Zero-Setup Report (no `draft/` directory)
886
+
887
+ **Render inline; write no files.** An evaluating user has not asked for artifacts in their repo, and creating `draft/` is `/draft:init`'s job. On explicit request, save to `.draft-review/review-report-<timestamp>.md`. Full format and the mandatory closing CTA: `references/zero-setup-mode.md` §Output.
888
+
813
889
  ### Report History
814
890
 
815
891
  Previous timestamped reports are preserved. The `-latest.md` symlink always points to the most recent report.
@@ -852,7 +928,7 @@ Display summary to user with actionable next steps.
852
928
 
853
929
  ### Success Output
854
930
 
855
- ```
931
+ ```text
856
932
  ✅ Review complete: <track_id>
857
933
 
858
934
  Report: draft/tracks/<id>/review-report-<timestamp>.md (symlink: review-report-latest.md)
@@ -878,7 +954,7 @@ Next: Address findings and run /draft:review again, or mark track complete.
878
954
 
879
955
  ### Failure Output
880
956
 
881
- ```
957
+ ```text
882
958
  ❌ Review failed: <track_id>
883
959
 
884
960
  Report: draft/tracks/<id>/review-report-<timestamp>.md (symlink: review-report-latest.md)
@@ -904,23 +980,26 @@ Next: Fix gaps and run /draft:review again.
904
980
 
905
981
  ## Error Handling
906
982
 
907
- ### Missing Draft Directory
983
+ ### Missing Draft Directory — not an error
908
984
 
909
- ```
910
- Error: Draft not initialized.
911
- Run /draft:init to set up Context-Driven Development.
985
+ A missing `draft/` directory is a **supported mode**, not a failure. Enter zero-setup mode (Step 0) and review the diff. Never emit "Draft not initialized" from this skill.
986
+
987
+ The only legitimate stop is a repository with nothing to review:
988
+
989
+ ```text
990
+ No changes to review. Make a change, or run /draft:review commits <range>.
912
991
  ```
913
992
 
914
993
  ### No Tracks Found
915
994
 
916
- ```
995
+ ```yaml
917
996
  Error: No tracks found in draft/tracks.md
918
997
  Run /draft:new-track to create your first track.
919
998
  ```
920
999
 
921
1000
  ### Track Not Found
922
1001
 
923
- ```
1002
+ ```yaml
924
1003
  Error: Track 'xyz' not found.
925
1004
 
926
1005
  Did you mean:
@@ -932,7 +1011,7 @@ Use exact track ID or run /draft:status to see all tracks.
932
1011
 
933
1012
  ### Ambiguous Match
934
1013
 
935
- ```
1014
+ ```text
936
1015
  Multiple tracks match 'review':
937
1016
  1. add-review-command - Add /draft:review Command [~]
938
1017
  2. review-architecture-md - Review architecture.md [x]
@@ -942,7 +1021,7 @@ Select track (1-2):
942
1021
 
943
1022
  ### Invalid Git Range
944
1023
 
945
- ```
1024
+ ```yaml
946
1025
  Error: Invalid commit range 'main...feature'
947
1026
  Git error: fatal: ambiguous argument 'feature': unknown revision
948
1027
 
@@ -952,7 +1031,7 @@ Verify the range exists:
952
1031
 
953
1032
  ### Missing Commits in Plan
954
1033
 
955
- ```
1034
+ ```text
956
1035
  ⚠️ Warning: No commit SHAs found in plan.md
957
1036
 
958
1037
  Cannot determine commit range for review.
@@ -974,6 +1053,8 @@ Options:
974
1053
  | Ignore incomplete tasks | Warn user, suggest completing work first |
975
1054
  | Auto-fix issues found | Report only, let developer decide |
976
1055
  | Batch multiple tracks | Review one track at a time |
1056
+ | Refuse to run because `draft/` is missing | Enter zero-setup mode and review the diff |
1057
+ | Report blast radius / hotspots without the graph | Say the check did not run |
977
1058
 
978
1059
  ---
979
1060
 
@@ -986,56 +1067,67 @@ After generating the review report, execute the pattern learning phase from `cor
986
1067
  ## Examples
987
1068
 
988
1069
  ### Review active track
1070
+
989
1071
  ```bash
990
1072
  /draft:review
991
1073
  ```
992
1074
 
993
1075
  ### Review specific track by ID
1076
+
994
1077
  ```bash
995
1078
  /draft:review track add-user-auth
996
1079
  ```
997
1080
 
998
1081
  ### Review specific track by name (fuzzy)
1082
+
999
1083
  ```bash
1000
1084
  /draft:review track "user authentication"
1001
1085
  ```
1002
1086
 
1003
1087
  ### Comprehensive track review
1088
+
1004
1089
  ```bash
1005
1090
  /draft:review track add-user-auth full
1006
1091
  ```
1007
1092
 
1008
1093
  ### Review uncommitted changes
1094
+
1009
1095
  ```bash
1010
1096
  /draft:review project
1011
1097
  ```
1012
1098
 
1013
1099
  ### Review specific files
1100
+
1014
1101
  ```bash
1015
1102
  /draft:review files "src/**/*.ts"
1016
1103
  ```
1017
1104
 
1018
1105
  ### Review commit range
1106
+
1019
1107
  ```bash
1020
1108
  /draft:review commits main...feature-branch
1021
1109
  ```
1022
1110
 
1023
1111
  ### Review with bughunt
1112
+
1024
1113
  ```bash
1025
1114
  /draft:review track my-feature with-bughunt
1026
1115
  ```
1027
1116
 
1028
1117
  ### Explicit quick review via parent
1118
+
1029
1119
  ```bash
1030
1120
  /draft:review quick files "src/**/*.ts"
1031
1121
  ```
1032
1122
 
1033
1123
  ### Explicit deep review via parent
1124
+
1034
1125
  ```bash
1035
1126
  /draft:review deep auth
1036
1127
  ```
1037
1128
 
1038
1129
  ### Explicit assist review via parent
1130
+
1039
1131
  ```bash
1040
1132
  /draft:review assist track my-feature
1041
1133
  ```
@@ -1055,6 +1147,7 @@ Every review report must end with a `## Next Actions` section listing the smalle
1055
1147
  ```
1056
1148
 
1057
1149
  Rules:
1150
+
1058
1151
  - Critical findings produce blocker rows (`Blocker? = yes`); proceeding to merge is forbidden until cleared.
1059
1152
  - Each action is imperative ("Add CSRF token to /api/transfer"), not a restatement of the finding.
1060
1153
  - Suggest the Draft follow-up when one applies (`/draft:debug`, `/draft:regression`, `/draft:tech-debt`, `/draft:bughunt`, `/draft:adr`). Otherwise put `n/a`.
@@ -1071,24 +1164,28 @@ Rules:
1071
1164
  After review completion, based on findings:
1072
1165
 
1073
1166
  **If significant code quality findings:**
1074
- ```
1167
+
1168
+ ```text
1075
1169
  "Review complete. Consider:
1076
1170
  → /draft:tech-debt — Catalog and prioritize the technical debt found"
1077
1171
  ```
1078
1172
 
1079
1173
  **If new public APIs lack documentation:**
1080
- ```
1174
+
1175
+ ```text
1081
1176
  → /draft:documentation api — Document new API endpoints"
1082
1177
  ```
1083
1178
 
1084
1179
  **If undocumented design decisions discovered:**
1085
- ```
1180
+
1181
+ ```text
1086
1182
  → /draft:adr — Record architectural decisions found during review"
1087
1183
  ```
1088
1184
 
1089
1185
  ### Jira Sync
1090
1186
 
1091
1187
  If Jira ticket linked, sync via `core/shared/jira-sync.md`:
1188
+
1092
1189
  - Attach `review-report-latest.md` to ticket
1093
1190
  - Post comment: "[draft] review-complete: {PASS/FAIL}. {n} findings: {critical} critical, {suggestions} suggestions."
1094
1191
 
@@ -1111,6 +1208,7 @@ Emit the canonical footer from [core/shared/graph-usage-report.md](../../core/sh
1111
1208
  As the last step after saving the review report, emit a metrics record. Best-effort — never block.
1112
1209
 
1113
1210
  **Payload fields:**
1211
+
1114
1212
  ```json
1115
1213
  {
1116
1214
  "skill": "review",
@@ -1126,10 +1224,11 @@ As the last step after saving the review report, emit a metrics record. Best-eff
1126
1224
  ```
1127
1225
 
1128
1226
  **Emit call:**
1227
+
1129
1228
  ```bash
1130
1229
  # Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
1131
1230
  # is not exported into skill Bash). See core/shared/tool-resolver.md.
1132
- DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
1231
+ DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$(cat ~/.cache/draft/plugin-root 2>/dev/null)}/scripts/tools"
1133
1232
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
1134
1233
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
1135
1234
  [ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"