@drafthq/draft 2.7.0
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.
- package/.claude-plugin/marketplace.json +38 -0
- package/.claude-plugin/plugin.json +26 -0
- package/LICENSE +21 -0
- package/README.md +272 -0
- package/bin/README.md +49 -0
- package/cli/bin/draft.js +13 -0
- package/cli/src/cli.js +113 -0
- package/cli/src/hosts/claude-code.js +46 -0
- package/cli/src/hosts/codex.js +33 -0
- package/cli/src/hosts/cursor.js +50 -0
- package/cli/src/hosts/index.js +24 -0
- package/cli/src/hosts/opencode.js +39 -0
- package/cli/src/installer.js +61 -0
- package/cli/src/lib/fsx.js +34 -0
- package/cli/src/lib/graph.js +23 -0
- package/cli/src/lib/log.js +32 -0
- package/cli/src/lib/paths.js +14 -0
- package/core/agents/architect.md +338 -0
- package/core/agents/debugger.md +193 -0
- package/core/agents/ops.md +104 -0
- package/core/agents/planner.md +158 -0
- package/core/agents/rca.md +314 -0
- package/core/agents/reviewer.md +256 -0
- package/core/agents/writer.md +110 -0
- package/core/guardrails/README.md +4 -0
- package/core/guardrails/code-quality.md +4 -0
- package/core/guardrails/dependency-triage.md +4 -0
- package/core/guardrails/design-norms.md +4 -0
- package/core/guardrails/language-standards.md +4 -0
- package/core/guardrails/review-checks.md +4 -0
- package/core/guardrails/secure-patterns.md +4 -0
- package/core/guardrails/security.md +4 -0
- package/core/guardrails.md +22 -0
- package/core/knowledge-base.md +127 -0
- package/core/methodology.md +1221 -0
- package/core/shared/condensation.md +224 -0
- package/core/shared/context-verify.md +44 -0
- package/core/shared/cross-skill-dispatch.md +127 -0
- package/core/shared/discovery-schema.md +75 -0
- package/core/shared/draft-context-loading.md +282 -0
- package/core/shared/git-report-metadata.md +106 -0
- package/core/shared/graph-query.md +239 -0
- package/core/shared/graph-usage-report.md +22 -0
- package/core/shared/jira-sync.md +170 -0
- package/core/shared/parallel-analysis.md +386 -0
- package/core/shared/parallel-fanout.md +10 -0
- package/core/shared/pattern-learning.md +146 -0
- package/core/shared/red-flags.md +58 -0
- package/core/shared/template-contract.md +22 -0
- package/core/shared/template-hygiene.md +10 -0
- package/core/shared/tool-resolver.md +10 -0
- package/core/shared/vcs-commands.md +97 -0
- package/core/shared/verification-gates.md +47 -0
- package/core/templates/CHANGELOG.md +70 -0
- package/core/templates/ai-context-export.md +8 -0
- package/core/templates/ai-context.md +270 -0
- package/core/templates/ai-profile.md +41 -0
- package/core/templates/architecture.md +203 -0
- package/core/templates/dependency-graph.md +103 -0
- package/core/templates/discovery.md +79 -0
- package/core/templates/guardrails.md +143 -0
- package/core/templates/hld.md +327 -0
- package/core/templates/intake-questions.md +403 -0
- package/core/templates/jira.md +119 -0
- package/core/templates/lld.md +283 -0
- package/core/templates/metadata.json +66 -0
- package/core/templates/plan.md +130 -0
- package/core/templates/product.md +110 -0
- package/core/templates/rca.md +86 -0
- package/core/templates/root-architecture.md +127 -0
- package/core/templates/root-product.md +53 -0
- package/core/templates/root-tech-stack.md +117 -0
- package/core/templates/service-index.md +55 -0
- package/core/templates/session-summary.md +8 -0
- package/core/templates/spec.md +165 -0
- package/core/templates/tech-matrix.md +101 -0
- package/core/templates/tech-stack.md +169 -0
- package/core/templates/track-architecture.md +311 -0
- package/core/templates/workflow.md +187 -0
- package/integrations/agents/AGENTS.md +24384 -0
- package/integrations/copilot/.github/copilot-instructions.md +24384 -0
- package/integrations/gemini/.gemini.md +26 -0
- package/package.json +53 -0
- package/scripts/fetch-memory-engine.sh +116 -0
- package/scripts/lib.sh +256 -0
- package/scripts/tools/_lib.sh +220 -0
- package/scripts/tools/adr-index.sh +117 -0
- package/scripts/tools/check-graph-usage-report.sh +95 -0
- package/scripts/tools/check-scope-conflicts.sh +139 -0
- package/scripts/tools/check-skill-line-caps.sh +115 -0
- package/scripts/tools/check-template-noop.sh +87 -0
- package/scripts/tools/check-track-hygiene.sh +230 -0
- package/scripts/tools/classify-files.sh +231 -0
- package/scripts/tools/cycle-detect.sh +75 -0
- package/scripts/tools/detect-test-framework.sh +135 -0
- package/scripts/tools/diff-templates-vs-tracks.sh +176 -0
- package/scripts/tools/emit-skill-metrics.sh +71 -0
- package/scripts/tools/fix-whitespace.sh +192 -0
- package/scripts/tools/freshness-check.sh +143 -0
- package/scripts/tools/git-metadata.sh +203 -0
- package/scripts/tools/graph-callers.sh +74 -0
- package/scripts/tools/graph-impact.sh +93 -0
- package/scripts/tools/graph-snapshot.sh +102 -0
- package/scripts/tools/hotspot-rank.sh +75 -0
- package/scripts/tools/manage-symlinks.sh +85 -0
- package/scripts/tools/mermaid-from-graph.sh +92 -0
- package/scripts/tools/migrate-track-frontmatter.sh +241 -0
- package/scripts/tools/parse-git-log.sh +135 -0
- package/scripts/tools/parse-reports.sh +114 -0
- package/scripts/tools/render-track.sh +145 -0
- package/scripts/tools/run-coverage.sh +153 -0
- package/scripts/tools/scan-markers.sh +144 -0
- package/scripts/tools/skill-caps.conf +24 -0
- package/scripts/tools/validate-frontmatter.sh +125 -0
- package/scripts/tools/verify-citations.sh +250 -0
- package/scripts/tools/verify-doc-anchors.sh +204 -0
- package/scripts/tools/verify-graph-binary.sh +154 -0
- package/skills/GRAPH.md +332 -0
- package/skills/adr/SKILL.md +374 -0
- package/skills/assist-review/SKILL.md +49 -0
- package/skills/bughunt/SKILL.md +668 -0
- package/skills/bughunt/references/regression-tests.md +399 -0
- package/skills/change/SKILL.md +267 -0
- package/skills/coverage/SKILL.md +336 -0
- package/skills/debug/SKILL.md +201 -0
- package/skills/decompose/SKILL.md +656 -0
- package/skills/deep-review/SKILL.md +326 -0
- package/skills/deploy-checklist/SKILL.md +254 -0
- package/skills/discover/SKILL.md +66 -0
- package/skills/docs/SKILL.md +42 -0
- package/skills/documentation/SKILL.md +197 -0
- package/skills/draft/SKILL.md +177 -0
- package/skills/draft/context-files.md +57 -0
- package/skills/draft/intent-mapping.md +37 -0
- package/skills/draft/quality-guide.md +51 -0
- package/skills/graph/SKILL.md +107 -0
- package/skills/impact/SKILL.md +86 -0
- package/skills/implement/SKILL.md +794 -0
- package/skills/incident-response/SKILL.md +245 -0
- package/skills/index/SKILL.md +848 -0
- package/skills/init/SKILL.md +1784 -0
- package/skills/init/references/architecture-spec.md +1259 -0
- package/skills/integrations/SKILL.md +53 -0
- package/skills/jira/SKILL.md +577 -0
- package/skills/jira/references/review.md +1322 -0
- package/skills/learn/SKILL.md +478 -0
- package/skills/new-track/SKILL.md +841 -0
- package/skills/ops/SKILL.md +57 -0
- package/skills/plan/SKILL.md +60 -0
- package/skills/quick-review/SKILL.md +216 -0
- package/skills/revert/SKILL.md +178 -0
- package/skills/review/SKILL.md +1114 -0
- package/skills/standup/SKILL.md +183 -0
- package/skills/status/SKILL.md +183 -0
- package/skills/tech-debt/SKILL.md +318 -0
- package/skills/testing-strategy/SKILL.md +195 -0
- package/skills/tour/SKILL.md +38 -0
- package/skills/upload/SKILL.md +117 -0
|
@@ -0,0 +1,1114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: review
|
|
3
|
+
description: "Canonical review parent command. Runs the default three-stage review for tracks or project changes, and routes to quick-review, bughunt, deep-review, or assist-review when the user asks for explicit review depth or when the review context justifies escalation."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Code Review
|
|
7
|
+
|
|
8
|
+
You are conducting a code review using Draft's Context-Driven Development methodology.
|
|
9
|
+
|
|
10
|
+
## MANDATORY GRAPH LOOKUP (read before any review stage)
|
|
11
|
+
|
|
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
|
+
|
|
14
|
+
1. Run blast-radius assessment from `draft/graph/hotspots.jsonl` and `scripts/tools/graph-impact.sh` (see Stage 1).
|
|
15
|
+
2. For each changed file with non-trivial diff size, run `scripts/tools/graph-impact.sh --repo . --file <path>` to obtain the affected module set deterministically.
|
|
16
|
+
3. For each public symbol modified, run `scripts/tools/graph-callers.sh --repo . --symbol <name>` to enumerate downstream callers before judging breaking-change severity.
|
|
17
|
+
|
|
18
|
+
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.
|
|
19
|
+
|
|
20
|
+
## Red Flags - STOP if you're:
|
|
21
|
+
|
|
22
|
+
See [shared red flags](../../core/shared/red-flags.md) — applies to all code-touching skills.
|
|
23
|
+
|
|
24
|
+
Skill-specific:
|
|
25
|
+
- Reviewing without reading the track's spec.md and plan.md first
|
|
26
|
+
- Reporting findings without reading the actual code
|
|
27
|
+
- Skipping spec compliance stage and jumping to code quality
|
|
28
|
+
- Making up file locations or line numbers
|
|
29
|
+
- Claiming "no issues" without systematic analysis evidence
|
|
30
|
+
|
|
31
|
+
**Read before you review. Evidence over opinion.**
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Overview
|
|
36
|
+
|
|
37
|
+
This command is the **canonical review parent**.
|
|
38
|
+
|
|
39
|
+
It orchestrates review workflows at two levels:
|
|
40
|
+
- **Track-level:** Review against spec.md and plan.md (three-stage: automated validation, spec compliance, code quality)
|
|
41
|
+
- **Project-level:** Review arbitrary changes (automated validation + code quality)
|
|
42
|
+
|
|
43
|
+
Specialist review workflows remain available:
|
|
44
|
+
|
|
45
|
+
- `/draft:quick-review`
|
|
46
|
+
- `/draft:bughunt`
|
|
47
|
+
- `/draft:deep-review`
|
|
48
|
+
- `/draft:assist-review`
|
|
49
|
+
|
|
50
|
+
`/draft:review` should remove the burden of choosing among them when the right depth is obvious from user intent or track state.
|
|
51
|
+
|
|
52
|
+
Important semantic note:
|
|
53
|
+
|
|
54
|
+
- `/draft:impact` is **not** a review-depth mode in the current product. It measures project/track delivery telemetry, not code-change review depth. Do not route `/draft:review` to `/draft:impact`.
|
|
55
|
+
|
|
56
|
+
Automated static validation (OWASP secrets, dead code, dependency cycles, N+1 patterns) is natively built into Stage 1 of this review.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Step 1: Parse Arguments
|
|
61
|
+
|
|
62
|
+
Extract and validate command arguments from user input.
|
|
63
|
+
|
|
64
|
+
### Supported Arguments
|
|
65
|
+
|
|
66
|
+
**Explicit review modes:**
|
|
67
|
+
- `quick` - Route to `/draft:quick-review`
|
|
68
|
+
- `bughunt` - Route to `/draft:bughunt`
|
|
69
|
+
- `deep` - Route to `/draft:deep-review`
|
|
70
|
+
- `assist` - Route to `/draft:assist-review`
|
|
71
|
+
|
|
72
|
+
**Scope specifiers (mutually exclusive for baseline review):**
|
|
73
|
+
- `track <id|name>` - Review specific track (exact ID or fuzzy name match)
|
|
74
|
+
- `project` - Review uncommitted changes (`git diff HEAD`)
|
|
75
|
+
- `files <pattern>` - Review specific file pattern (e.g., `src/**/*.ts`)
|
|
76
|
+
- `commits <range>` - Review commit range (e.g., `main...HEAD`, `abc123..def456`)
|
|
77
|
+
|
|
78
|
+
**Quality integration modifiers:**
|
|
79
|
+
- `with-bughunt` - Include `/draft:bughunt` results
|
|
80
|
+
- `with-assist` - Include `/draft:assist-review` summary
|
|
81
|
+
- `full` - Enable all sensible add-ons for the selected scope (`with-bughunt`, `with-assist`, and any justified deep-review escalation)
|
|
82
|
+
|
|
83
|
+
### Validation Rules
|
|
84
|
+
|
|
85
|
+
1. **Mode exclusivity:** At most one explicit mode among `quick`, `bughunt`, `deep`, `assist`
|
|
86
|
+
2. **Scope requirement:** At least one scope specifier OR no arguments (auto-detect track/project)
|
|
87
|
+
3. **Scope exclusivity:** Only one of `track`, `project`, `files`, `commits`
|
|
88
|
+
4. **Modifier normalization:** If `full` is present, enable `with-bughunt` and `with-assist`. Do not silently force `deep`; deep-review is module-scoped and must still satisfy escalation rules.
|
|
89
|
+
|
|
90
|
+
### Default Behavior
|
|
91
|
+
|
|
92
|
+
If no arguments provided:
|
|
93
|
+
- Auto-detect active `[~]` In Progress track from `draft/tracks.md`
|
|
94
|
+
- If no `[~]` track, find first `[ ]` Pending track
|
|
95
|
+
- If track found: display `Auto-detected track: <id> - <name> [<status>]` and proceed
|
|
96
|
+
- If no track is found but the repo has local changes: default to project-level review of current changes
|
|
97
|
+
- If no track and no changes: error "No review scope found. Specify a track, files, commit range, or create changes to review."
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Step 1.5: Route Explicit Modes Before Baseline Review
|
|
102
|
+
|
|
103
|
+
If the user explicitly invoked a specialist mode, route directly.
|
|
104
|
+
|
|
105
|
+
### Explicit Mode Routing
|
|
106
|
+
|
|
107
|
+
- `/draft:review quick ...` → follow `/draft:quick-review`
|
|
108
|
+
- `/draft:review bughunt ...` → follow `/draft:bughunt`
|
|
109
|
+
- `/draft:review deep ...` → follow `/draft:deep-review`
|
|
110
|
+
- `/draft:review assist ...` → follow `/draft:assist-review`
|
|
111
|
+
|
|
112
|
+
When routing, preserve any scope that can be mapped sensibly.
|
|
113
|
+
|
|
114
|
+
Examples:
|
|
115
|
+
|
|
116
|
+
- `/draft:review quick files "src/**/*.ts"` → quick review of those files
|
|
117
|
+
- `/draft:review bughunt track payments-refactor` → bughunt scoped to that track
|
|
118
|
+
- `/draft:review deep auth` → deep-review of the `auth` module
|
|
119
|
+
- `/draft:review assist track add-user-auth` → reviewer-assist summary for that track
|
|
120
|
+
|
|
121
|
+
Explicit mode always wins over automatic escalation.
|
|
122
|
+
|
|
123
|
+
If no explicit mode is present, continue with the baseline `/draft:review` workflow below.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Step 2: Determine Review Scope
|
|
128
|
+
|
|
129
|
+
Based on parsed arguments, determine review scope and load appropriate context.
|
|
130
|
+
|
|
131
|
+
### Track-Level Review
|
|
132
|
+
|
|
133
|
+
**Trigger:** `track <id|name>` argument OR auto-detected track
|
|
134
|
+
|
|
135
|
+
#### 2.1: Resolve Track
|
|
136
|
+
|
|
137
|
+
1. **Check if argument is exact directory match:**
|
|
138
|
+
```bash
|
|
139
|
+
ls draft/tracks/<arg>/ 2>/dev/null
|
|
140
|
+
```
|
|
141
|
+
If exists → use this track
|
|
142
|
+
|
|
143
|
+
2. **Parse tracks.md for fuzzy matching:**
|
|
144
|
+
- Read `draft/tracks.md`
|
|
145
|
+
- Split by `---` separators
|
|
146
|
+
- For each section, extract:
|
|
147
|
+
- Track ID (from path: `./tracks/<id>/`)
|
|
148
|
+
- Track name (from heading: `### <id> - <name>`)
|
|
149
|
+
- Match input against:
|
|
150
|
+
- Exact ID (case-insensitive)
|
|
151
|
+
- Partial ID (substring)
|
|
152
|
+
- Partial name (substring, case-insensitive)
|
|
153
|
+
|
|
154
|
+
3. **Handle matches:**
|
|
155
|
+
- **Exact match:** Use immediately
|
|
156
|
+
- **Multiple matches:** Display numbered list with format:
|
|
157
|
+
```
|
|
158
|
+
Multiple tracks match '<input>':
|
|
159
|
+
1. <id> - <name> [<status>]
|
|
160
|
+
2. <id> - <name> [<status>]
|
|
161
|
+
Select track (1-N):
|
|
162
|
+
```
|
|
163
|
+
Validate selection is within 1-N range. Re-prompt on invalid input.
|
|
164
|
+
- **No matches:** Error with suggestions (closest 3 by edit distance)
|
|
165
|
+
|
|
166
|
+
#### 2.2: Load Track Context
|
|
167
|
+
|
|
168
|
+
Once track is resolved:
|
|
169
|
+
|
|
170
|
+
1. **Verify track directory exists:**
|
|
171
|
+
```bash
|
|
172
|
+
ls draft/tracks/<id>/ 2>/dev/null
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
2. **Read spec.md:**
|
|
176
|
+
- Load `draft/tracks/<id>/spec.md`
|
|
177
|
+
- Extract: Summary, Requirements, Acceptance Criteria, Non-Goals
|
|
178
|
+
- Store for Stage 1 compliance checks
|
|
179
|
+
|
|
180
|
+
2.5. **Read hld.md and lld.md (when present):**
|
|
181
|
+
- `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
|
|
182
|
+
- `draft/tracks/<id>/lld.md` — extract §Classes and Interfaces (signatures, invariants), §Data Model (schemas, migrations), §Error Handling, §Observability metrics
|
|
183
|
+
- Store for HLD/LLD compliance pass (Stage 1.5 below)
|
|
184
|
+
|
|
185
|
+
3. **Read plan.md:**
|
|
186
|
+
- Load `draft/tracks/<id>/plan.md`
|
|
187
|
+
- 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.
|
|
188
|
+
- Determine commit range:
|
|
189
|
+
- First commit parent: run `git rev-parse <first_SHA>^ 2>/dev/null`
|
|
190
|
+
- If the parent exists: use `<first_SHA>^..<last_SHA>` as the range
|
|
191
|
+
- 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.
|
|
192
|
+
- Last commit: `<last_SHA>`
|
|
193
|
+
|
|
194
|
+
4. **Check for incomplete work:**
|
|
195
|
+
- Parse plan.md task statuses
|
|
196
|
+
- Count `[ ]`, `[~]`, `[x]`, `[!]` tasks
|
|
197
|
+
- If `[ ]` or `[~]` tasks exist: Display warning and proceed:
|
|
198
|
+
```
|
|
199
|
+
Warning: Track has N incomplete tasks (M in-progress, K pending). Reviewing completed work only.
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
5. **Handle missing files:**
|
|
203
|
+
- Missing spec.md: Error "spec.md not found for track <id>"
|
|
204
|
+
- Missing plan.md: Warn "plan.md not found, skipping commit extraction"
|
|
205
|
+
- No commits found: Warn "No commits found in plan.md, review may be incomplete"
|
|
206
|
+
|
|
207
|
+
### Project-Level Review
|
|
208
|
+
|
|
209
|
+
**Trigger:** `project`, `files <pattern>`, `commits <range>` argument, or no active track with local changes
|
|
210
|
+
|
|
211
|
+
#### 2.3: Project Scope Detection
|
|
212
|
+
|
|
213
|
+
1. **`project` argument:**
|
|
214
|
+
- Scope: Uncommitted changes
|
|
215
|
+
- Command: `git diff HEAD`
|
|
216
|
+
|
|
217
|
+
2. **`files <pattern>` argument:**
|
|
218
|
+
- Scope: Specific files matching glob pattern
|
|
219
|
+
- Command: `git diff HEAD -- <pattern>`
|
|
220
|
+
- Validate pattern matches files:
|
|
221
|
+
```bash
|
|
222
|
+
git ls-files <pattern> | head -1
|
|
223
|
+
```
|
|
224
|
+
If empty: Error "No files match pattern '<pattern>'"
|
|
225
|
+
|
|
226
|
+
3. **`commits <range>` argument:**
|
|
227
|
+
- Scope: Commit range
|
|
228
|
+
- Validate range exists:
|
|
229
|
+
```bash
|
|
230
|
+
git rev-parse <range> 2>/dev/null
|
|
231
|
+
```
|
|
232
|
+
If fails: Error "Invalid commit range '<range>'"
|
|
233
|
+
- Command: `git diff <range>`
|
|
234
|
+
|
|
235
|
+
#### 2.4: Load Project Context
|
|
236
|
+
|
|
237
|
+
For project-level reviews (no track context):
|
|
238
|
+
|
|
239
|
+
1. **Load Draft context (if available):**
|
|
240
|
+
Read and follow the base procedure in `core/shared/draft-context-loading.md`.
|
|
241
|
+
|
|
242
|
+
2. **Note limitations:**
|
|
243
|
+
- No spec.md → Skip Stage 1 (spec compliance)
|
|
244
|
+
- Run Stage 2 (code quality) only
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Step 2.5: Choose Baseline Review Depth
|
|
249
|
+
|
|
250
|
+
After scope is resolved, decide whether baseline `/draft:review` should proceed as the full three-stage review or should delegate to a specialist by default.
|
|
251
|
+
|
|
252
|
+
### Routing Heuristics for Bare `/draft:review`
|
|
253
|
+
|
|
254
|
+
1. **Tiny ad-hoc scope with no track context**
|
|
255
|
+
If scope is project/files/commits and the diff is small, prefer `/draft:quick-review`.
|
|
256
|
+
|
|
257
|
+
Good signals:
|
|
258
|
+
- single file or very small file set
|
|
259
|
+
- no spec/plan context available
|
|
260
|
+
- user asks for a sanity check rather than a formal gate
|
|
261
|
+
|
|
262
|
+
2. **Track-complete or handoff review**
|
|
263
|
+
If the review is track-scoped and the output is likely for another reviewer or approver, attach `/draft:assist-review` unless the user explicitly opted out.
|
|
264
|
+
|
|
265
|
+
Good signals:
|
|
266
|
+
- all tasks completed
|
|
267
|
+
- upload / PR / handoff language
|
|
268
|
+
- `full` or `with-assist` modifier present
|
|
269
|
+
|
|
270
|
+
3. **High defect-risk changes**
|
|
271
|
+
If the diff touches high-risk surfaces, attach `/draft:bughunt`.
|
|
272
|
+
|
|
273
|
+
Good signals:
|
|
274
|
+
- auth, payments, persistence, concurrency, migrations, public API boundaries
|
|
275
|
+
- hotspot / high-fanIn files
|
|
276
|
+
- weak or missing tests
|
|
277
|
+
- `full` or `with-bughunt` modifier present
|
|
278
|
+
|
|
279
|
+
4. **Single-module structural risk**
|
|
280
|
+
If the review scope maps cleanly to one high-risk module, attach `/draft:deep-review`.
|
|
281
|
+
|
|
282
|
+
Good signals:
|
|
283
|
+
- single module or service dominates the diff
|
|
284
|
+
- structural or resilience-sensitive changes
|
|
285
|
+
- high blast radius plus concurrency / durability / resiliency concerns
|
|
286
|
+
|
|
287
|
+
If the diff spans many modules, do **not** auto-run multiple deep reviews. Instead, finish baseline review and recommend targeted deep-review follow-ups for the highest-risk modules.
|
|
288
|
+
|
|
289
|
+
### Mandatory Baseline Behavior
|
|
290
|
+
|
|
291
|
+
Even when no specialist command is attached:
|
|
292
|
+
|
|
293
|
+
- always compute and report blast radius / hotspot impact from graph data when available
|
|
294
|
+
- always explain which specialist workflows were auto-invoked and why
|
|
295
|
+
|
|
296
|
+
Example:
|
|
297
|
+
|
|
298
|
+
```text
|
|
299
|
+
Running /draft:review
|
|
300
|
+
- baseline three-stage review
|
|
301
|
+
- bughunt attached because auth and persistence paths changed
|
|
302
|
+
- assist-review attached because this is a completed track handoff
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
If the heuristic selects `/draft:quick-review` instead of baseline review, route there directly and stop this workflow.
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Step 3: Generate Git Diff (Smart Chunking)
|
|
310
|
+
|
|
311
|
+
Generate diff output using smart chunking to avoid context overflow.
|
|
312
|
+
|
|
313
|
+
### 3.1: Determine Diff Size
|
|
314
|
+
|
|
315
|
+
Run shortstat to check diff size:
|
|
316
|
+
```bash
|
|
317
|
+
git diff --shortstat <range>
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Parse output robustly — handle both singular (`1 file changed`) and plural (`N files changed`) forms. Extract numeric values for files, insertions, and deletions. Use total lines changed (insertions + deletions) for the chunking threshold.
|
|
321
|
+
|
|
322
|
+
### 3.2: Smart Chunking Strategy
|
|
323
|
+
|
|
324
|
+
**Small/Medium changes (<300 lines changed):**
|
|
325
|
+
- Run full diff in one pass:
|
|
326
|
+
```bash
|
|
327
|
+
git diff <range>
|
|
328
|
+
```
|
|
329
|
+
- Store complete diff for analysis
|
|
330
|
+
|
|
331
|
+
**Large changes (≥300 lines changed):**
|
|
332
|
+
- Announce: "Large changeset detected (N files). Using file-by-file review mode."
|
|
333
|
+
- Get file list:
|
|
334
|
+
```bash
|
|
335
|
+
git diff --name-only <range>
|
|
336
|
+
```
|
|
337
|
+
- For each file:
|
|
338
|
+
- Display progress: `[N/M] Reviewing <filename>`
|
|
339
|
+
- Run: `git diff <range> -- <file>`
|
|
340
|
+
- Analyze immediately (don't store all)
|
|
341
|
+
- Track findings in temporary structure
|
|
342
|
+
- Aggregate findings after all files processed
|
|
343
|
+
|
|
344
|
+
### 3.3: Filter Files (Optional)
|
|
345
|
+
|
|
346
|
+
Skip non-source files to focus review:
|
|
347
|
+
- Ignore lock/minified: `*.lock`, `package-lock.json`, `yarn.lock`, `*.min.js`, `*.min.css`, `*.map`
|
|
348
|
+
- Ignore build artifacts: `dist/`, `build/`, `target/`, `out/`, `__pycache__/`, `*.pyc`
|
|
349
|
+
- Ignore vendored: `node_modules/`, `vendor/`, `.git/`
|
|
350
|
+
- Ignore binaries: images, fonts, compiled assets
|
|
351
|
+
- Ignore generated files: check first 10 lines for `@generated` marker (case-insensitive, any comment syntax: `/* @generated */`, `// @generated`, `# @generated`)
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## Step 4: Run Reviewer Agent
|
|
356
|
+
|
|
357
|
+
Apply a three-stage review process (merging static validation and semantic review).
|
|
358
|
+
|
|
359
|
+
### Stage 1: Automated Validation
|
|
360
|
+
|
|
361
|
+
**Goal:** Detect structural, security, and performance issues using fast, objective searches across the diff.
|
|
362
|
+
|
|
363
|
+
Load plugin guardrails before scanning: `core/guardrails/review-checks.md` (RC-###), `core/guardrails/security.md` (SEC-##), and the relevant `core/guardrails/language-standards.md` section for the detected stack. `draft/guardrails.md` project rules take precedence on any conflict.
|
|
364
|
+
|
|
365
|
+
**Hard red line violations (SEC-01…SEC-10) are always Critical and block review approval.** If the violation has a `// SECURITY-OVERRIDE: <ticket> <justification>` annotation, downgrade to Important and record the ticket in the report.
|
|
366
|
+
|
|
367
|
+
**Read-before-report gate (Ground-Truth Discipline G1):** Static checks (grep, scanner output) identify *candidate* findings. Every candidate that survives to the final review report must be backed by an actual Read of the cited file in this session. A grep hit on `dangerouslySetInnerHTML` is a candidate; only after opening the file and checking surrounding context (sanitiser? test/mock file? feature flag?) does it become a reported finding. Filing findings directly from grep output is the dominant false-positive source in review skills — do not do it.
|
|
368
|
+
|
|
369
|
+
For the files changed in the diff, perform static checks using `grep` or similar tools:
|
|
370
|
+
|
|
371
|
+
- **Blast Radius Assessment** (if the `draft/graph/` snapshot exists):
|
|
372
|
+
- List all changed files from the diff
|
|
373
|
+
- For each changed file, check if it appears in `hotspots.jsonl` — if yes, record its `fanIn` value
|
|
374
|
+
- Classify: files with fanIn in the top 20% of the hotspots list = **HIGH IMPACT**; top 21–50% = **MEDIUM**; below 50% or not in list = **STANDARD**
|
|
375
|
+
- For any file in a HIGH or MEDIUM module, check `architecture.json` `.packages[].fan_in` (how many modules depend on this module)
|
|
376
|
+
- Include a `Blast Radius` line in the Stage 1 report summary: `Blast Radius: HIGH | MEDIUM | STANDARD — <N> changed files affect high-fanIn modules: [file list]`
|
|
377
|
+
- If any changed file is HIGH IMPACT: escalate Stage 3 thoroughness (check all callers of changed functions) and note this in the report header
|
|
378
|
+
- **Architecture Conformance:** Search for pattern violations documented in `draft/.ai-context.md`. (e.g. `import * from 'database'` in a React component).
|
|
379
|
+
- **Dead Code:** Check for newly exported functions/classes in the diff that have 0 references across the codebase.
|
|
380
|
+
- **Dependency Cycles:** Trace the import chains for new imports to ensure no circular dependencies (e.g., A → B → C → A) are introduced.
|
|
381
|
+
- **Graph Boundary Check** (if `draft/graph/architecture.json` exists) `[RC-013]`:
|
|
382
|
+
- For each changed file, identify its module from the graph
|
|
383
|
+
- Check if any new cross-module includes were added in the diff
|
|
384
|
+
- Verify they follow the established dependency direction from `architecture.json` package fan-in/out
|
|
385
|
+
- Flag reverse-direction dependencies (module A now depends on module B, but only B→A existed before) as "Potential architecture violation — new dependency direction"
|
|
386
|
+
- Check if changes introduce files in modules listed in graph cycles — flag as higher risk
|
|
387
|
+
- **Security Scan** `[RC-001, RC-002, RC-003, RC-011]`:
|
|
388
|
+
- Hardcoded secrets and API keys `[RC-001]`
|
|
389
|
+
- SQL injection risks (string concatenation in queries) `[RC-002]`
|
|
390
|
+
- XSS vulnerabilities (`innerHTML` or raw DOM insertion) `[RC-011]`
|
|
391
|
+
- Missing input validation at new entry points `[RC-003]`
|
|
392
|
+
- **Dependency Manifest Check** `[RC-014]`: If diff modifies `package.json`, `requirements.txt`, `go.mod`, `Cargo.toml`, `pom.xml`, or `build.gradle`, run the project's configured dependency vulnerability scanner (from `draft/tech-stack.md`) or recommend `npm audit` / `pip-audit` / `cargo audit` as appropriate. Include results in Stage 1 findings.
|
|
393
|
+
- **Performance Anti-patterns:** Scan the diff for:
|
|
394
|
+
- N+1 database queries (loops containing queries)
|
|
395
|
+
- Blocking synchronous I/O within async functions
|
|
396
|
+
- Unbounded queries lacking pagination
|
|
397
|
+
|
|
398
|
+
- **Context-Specific Checks:** Identify the primary domain of changed files and apply domain-specific checks:
|
|
399
|
+
|
|
400
|
+
- **Crypto/Security changes** (files matching `auth`, `crypto`, `security`, `token`, `password`, `hash`, `encrypt`):
|
|
401
|
+
- [ ] Timing-safe comparisons used (no `==` for secret comparison)
|
|
402
|
+
- [ ] Constant-time operations for sensitive data
|
|
403
|
+
- [ ] Secure random generation (no `Math.random()` for security)
|
|
404
|
+
- [ ] Key length meets minimum requirements
|
|
405
|
+
- **Database/Migration changes** (files matching `migration`, `schema`, `model`, `entity`, `repository`):
|
|
406
|
+
- [ ] Backward compatibility preserved (no destructive column drops without migration path)
|
|
407
|
+
- [ ] Index coverage for new queries
|
|
408
|
+
- [ ] Constraint preservation (foreign keys, unique constraints)
|
|
409
|
+
- [ ] Zero-downtime migration safety (no table locks on large tables)
|
|
410
|
+
- **API Endpoint changes** (files matching `controller`, `handler`, `route`, `endpoint`, `resolver`) `[RC-005, RC-012]`:
|
|
411
|
+
- [ ] Backward compatibility of public signatures (no breaking param changes) `[RC-012]`
|
|
412
|
+
- [ ] Input validation present for all new parameters `[RC-003]`
|
|
413
|
+
- [ ] Rate limiting configured for new endpoints
|
|
414
|
+
- [ ] Authentication/authorization checks in place `[RC-005]`
|
|
415
|
+
- **Configuration changes** (files matching `config`, `env`, `settings`):
|
|
416
|
+
- [ ] No secrets exposed in plaintext
|
|
417
|
+
- [ ] Validation at startup for required config values
|
|
418
|
+
- [ ] Fallback defaults provided where appropriate
|
|
419
|
+
- **UI/Frontend changes** (files matching `component`, `view`, `page`, `template`):
|
|
420
|
+
- [ ] No XSS vectors (`innerHTML`, `dangerouslySetInnerHTML`, `v-html`)
|
|
421
|
+
- [ ] Accessibility present (ARIA attributes, keyboard navigation)
|
|
422
|
+
- [ ] Performance impact considered (bundle size, render cycles)
|
|
423
|
+
|
|
424
|
+
- **Breaking Change Detection** `[RC-012]`: Check for public API changes in the diff:
|
|
425
|
+
- [ ] Exported function/method signatures unchanged (no added required params, no changed return types)
|
|
426
|
+
- [ ] No removed or renamed exported symbols
|
|
427
|
+
- [ ] Error types and error codes unchanged
|
|
428
|
+
- [ ] Serialization format preserved (JSON field names, protobuf field numbers)
|
|
429
|
+
- Flag as **CRITICAL** if breaking change found with no deprecation period or version bump
|
|
430
|
+
|
|
431
|
+
- **Threat Model (STRIDE):** For new endpoints or data mutations, check:
|
|
432
|
+
- **S**poofing: Can the caller's identity be faked? (authentication check)
|
|
433
|
+
- **T**ampering: Can request data be modified in transit? (integrity check)
|
|
434
|
+
- **R**epudiation: Are actions logged for audit? (logging check)
|
|
435
|
+
- **I**nformation Disclosure: Does the response leak internal details? (error message check)
|
|
436
|
+
- **D**enial of Service: Can the endpoint be abused? (rate limiting, resource limits)
|
|
437
|
+
- **E**levation of Privilege: Are authorization checks in place? (RBAC/ABAC check)
|
|
438
|
+
|
|
439
|
+
**Verdict:**
|
|
440
|
+
- **PASS:** No critical issues found → Proceed to Stage 2
|
|
441
|
+
- **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.
|
|
442
|
+
|
|
443
|
+
### SAST Tool Recommendations
|
|
444
|
+
|
|
445
|
+
After completing Stage 1, recommend appropriate static analysis tools based on the project's `tech-stack.md`. Check if these tools are already configured in CI; if not, recommend adding them.
|
|
446
|
+
|
|
447
|
+
| Language | Recommended Tools |
|
|
448
|
+
|----------|-------------------|
|
|
449
|
+
| JavaScript/TypeScript | ESLint with `eslint-plugin-security`, Semgrep |
|
|
450
|
+
| Python | Bandit, Semgrep, pylint |
|
|
451
|
+
| Java | Error Prone, SpotBugs, Semgrep |
|
|
452
|
+
| Go | gosec, staticcheck |
|
|
453
|
+
| Rust | `cargo clippy`, `cargo audit` |
|
|
454
|
+
| C/C++ | Clang Static Analyzer, cppcheck |
|
|
455
|
+
| Multi-language | Semgrep (https://semgrep.dev/), CodeQL (semantic code analysis) |
|
|
456
|
+
|
|
457
|
+
References: Meta Infer for CI integration patterns, Google Error Prone for compile-time analysis.
|
|
458
|
+
|
|
459
|
+
Include tool recommendations in the review report under Stage 1 as a "Recommended Tooling" subsection. Only recommend tools relevant to the languages detected in the diff.
|
|
460
|
+
|
|
461
|
+
### Stage 2: Spec Compliance (Track-Level Only)
|
|
462
|
+
|
|
463
|
+
**Skip for project-level reviews (no spec exists)**
|
|
464
|
+
|
|
465
|
+
Load `spec.md` acceptance criteria and verify implementation:
|
|
466
|
+
|
|
467
|
+
#### 4.1: Requirements Coverage
|
|
468
|
+
|
|
469
|
+
For each functional requirement in `spec.md`:
|
|
470
|
+
- [ ] Requirement implemented (find evidence in diff)
|
|
471
|
+
- [ ] Files modified/created match requirement
|
|
472
|
+
|
|
473
|
+
#### 4.2: Acceptance Criteria
|
|
474
|
+
|
|
475
|
+
For each criterion in `spec.md`:
|
|
476
|
+
- [ ] Criterion met (check against diff)
|
|
477
|
+
- [ ] Test coverage exists (if TDD enabled)
|
|
478
|
+
|
|
479
|
+
#### 4.3: Scope Adherence
|
|
480
|
+
|
|
481
|
+
- [ ] No missing features from spec
|
|
482
|
+
- [ ] No extra unneeded work (scope creep)
|
|
483
|
+
|
|
484
|
+
**Verdict:**
|
|
485
|
+
- **PASS:** All requirements implemented AND all acceptance criteria met → Proceed to Stage 3
|
|
486
|
+
- **PASS WITH NOTES:** All requirements met but minor gaps in acceptance criteria verification → Proceed to Stage 3 with notes
|
|
487
|
+
- **FAIL:** ANY requirement missing OR ANY acceptance criterion not met → List gaps, report, and stop (no Stage 3)
|
|
488
|
+
|
|
489
|
+
### Stage 2.5: HLD/LLD Compliance (Track-Level Only, when hld.md exists)
|
|
490
|
+
|
|
491
|
+
**Skip if no `hld.md`** — fall through to Stage 3.
|
|
492
|
+
|
|
493
|
+
#### 2.5.1: HLD §Approvals signed
|
|
494
|
+
|
|
495
|
+
- [ ] All required approver rows have a Date populated (per `/draft:upload` Step 3.1 logic)
|
|
496
|
+
- [ ] If HLD was modified after the latest signed Date → flag as Critical "HLD modified after sign-off — re-circulate"
|
|
497
|
+
|
|
498
|
+
#### 2.5.2: HLD §Detailed Design coverage
|
|
499
|
+
|
|
500
|
+
For every component subsection in HLD §Detailed Design:
|
|
501
|
+
- [ ] Files listed in the component diff actually exist at the cited `path:line`
|
|
502
|
+
- [ ] Each component's `Whitebox requirements addressed` list is non-empty
|
|
503
|
+
|
|
504
|
+
#### 2.5.3: HLD §Checklist populated
|
|
505
|
+
|
|
506
|
+
For `criticality ∈ {high, mission-critical}` (frontmatter):
|
|
507
|
+
- [ ] §Performance, §Scale, §Security, §Resiliency, §Multi-tenancy, §Upgrade, §Cost are populated (not still "<Describe...>" placeholders)
|
|
508
|
+
|
|
509
|
+
#### 2.5.4: Code-vs-HLD drift
|
|
510
|
+
|
|
511
|
+
- [ ] Diff introduces no new modules absent from HLD §Detailed Design
|
|
512
|
+
- [ ] Diff introduces no new cross-module dependencies absent from HLD §Dependencies
|
|
513
|
+
- [ ] Diff respects HLD §Key Design Decisions (e.g., decision says "single-writer" → no new shared-write paths in code)
|
|
514
|
+
|
|
515
|
+
#### 2.5.5: LLD compliance (when lld.md exists)
|
|
516
|
+
|
|
517
|
+
- [ ] Public API additions in diff are reflected in LLD §Classes and Interfaces
|
|
518
|
+
- [ ] Schema/data-model changes in diff are reflected in LLD §Data Model with migration path
|
|
519
|
+
- [ ] Diff respects LLD invariants (thread safety, idempotency, ordering)
|
|
520
|
+
|
|
521
|
+
**Verdict:**
|
|
522
|
+
- PASS → Stage 3
|
|
523
|
+
- FAIL → list HLD/LLD gaps with severity Critical (drift) or Important (incomplete sections), then Stage 3
|
|
524
|
+
|
|
525
|
+
### Stage 3: Code Quality
|
|
526
|
+
|
|
527
|
+
**Run for both track-level (if Stage 2 passes) and project-level reviews**
|
|
528
|
+
|
|
529
|
+
Analyze semantic code quality across four dimensions:
|
|
530
|
+
|
|
531
|
+
#### 4.4: Architecture
|
|
532
|
+
- [ ] Follows project patterns (from tech-stack.md or CLAUDE.md)
|
|
533
|
+
- [ ] Appropriate separation of concerns
|
|
534
|
+
- [ ] Critical invariants honored (if `.ai-context.md` exists — check ## Critical Invariants section)
|
|
535
|
+
|
|
536
|
+
#### 4.5: Error Handling
|
|
537
|
+
- [ ] Errors handled at appropriate level
|
|
538
|
+
- [ ] User-facing errors are helpful
|
|
539
|
+
- [ ] No silent failures
|
|
540
|
+
|
|
541
|
+
#### 4.6: Testing
|
|
542
|
+
- [ ] Tests test real logic (not implementation details)
|
|
543
|
+
- [ ] Edge cases have test coverage
|
|
544
|
+
|
|
545
|
+
#### 4.7: Maintainability
|
|
546
|
+
- [ ] Code is readable without excessive comments
|
|
547
|
+
- [ ] Consistent naming and style
|
|
548
|
+
|
|
549
|
+
#### 4.8: Diff Complexity Metrics
|
|
550
|
+
- [ ] No functions exceeding cognitive complexity threshold (>15)
|
|
551
|
+
- [ ] No files with high churn + high complexity (flag as refactoring candidates)
|
|
552
|
+
- [ ] No deeply nested control flow (>3 levels of nesting)
|
|
553
|
+
|
|
554
|
+
For each flagged function, report: file path, function name, estimated complexity, and recommended action (split, extract, simplify).
|
|
555
|
+
|
|
556
|
+
#### Adversarial Pass (mandatory when Stage 3 yields zero findings)
|
|
557
|
+
|
|
558
|
+
If Stage 3 produces zero findings across all four dimensions, do NOT accept "clean" without this gate. This pass is **mandatory**, not optional — a "zero findings" verdict that did not complete it is incomplete and must be flagged in the report.
|
|
559
|
+
|
|
560
|
+
Answer each of the 7 questions explicitly with `file:line` evidence (not "looks fine"):
|
|
561
|
+
|
|
562
|
+
1. **Error paths** — Is every error/exception handled? Are any failure modes silently swallowed? Quote the handler or note its absence.
|
|
563
|
+
2. **Edge cases** — Are there boundary conditions (empty input, max values, concurrent access) not covered by tests? Cite tests or note coverage gap.
|
|
564
|
+
3. **Implicit assumptions** — Does code assume inputs are always valid, services always up, or state always consistent? Quote the assumption site.
|
|
565
|
+
4. **Future brittleness** — Is anything hardcoded that will break on scale or config change? Cite the constant or flag.
|
|
566
|
+
5. **Missing coverage** — Is there behavior that should be tested but isn't? Name the behavior and the missing test.
|
|
567
|
+
6. **Guardrails** — Do any changes violate learned anti-patterns from `guardrails.md`? Cite the rule.
|
|
568
|
+
7. **Invariants** — Do any changes violate critical invariants documented in `.ai-context.md`? Cite the invariant.
|
|
569
|
+
|
|
570
|
+
Document the pass in the review report:
|
|
571
|
+
> "Adversarial pass: 7/7 answered with evidence. [one line per question with `file:line` or 'N/A — <reason>']."
|
|
572
|
+
|
|
573
|
+
A review verdict of "clean / LGTM" without this filled-in block is non-conforming and must not be emitted. Skipping the pass is a [Ground-Truth Red Flag](../../core/shared/red-flags.md) G4 violation (claim about absence-of-issues from incomplete examination).
|
|
574
|
+
|
|
575
|
+
### Issue Classification
|
|
576
|
+
|
|
577
|
+
Classify all findings by severity:
|
|
578
|
+
|
|
579
|
+
| Severity | Definition | Action |
|
|
580
|
+
|----------|------------|--------|
|
|
581
|
+
| **Critical** | Blocks release, breaks functionality, security issue | Must fix before proceeding |
|
|
582
|
+
| **Important** | Degrades quality, technical debt | Should fix before phase complete |
|
|
583
|
+
| **Minor** | Style, optimization, nice-to-have | Note for later, don't block |
|
|
584
|
+
|
|
585
|
+
**Scope-specific behavior:**
|
|
586
|
+
- For **track-level** reviews: Run all three stages. Stage 2 uses `spec.md` acceptance criteria loaded in Step 2.
|
|
587
|
+
- For **project-level** reviews: Skip Stage 2 (no spec). Run Stage 1 and Stage 3 only.
|
|
588
|
+
|
|
589
|
+
**Issue format:**
|
|
590
|
+
```markdown
|
|
591
|
+
- [ ] [File:line] Description of issue `[RC-### or CQ-### or SEC-## if applicable]`
|
|
592
|
+
- **Impact:** [what breaks/degrades]
|
|
593
|
+
- **Suggested fix:** [how to address]
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
Cite the most specific guardrail rule ID that applies. If no numbered rule covers the finding, omit the citation — the finding is still valid.
|
|
597
|
+
|
|
598
|
+
---
|
|
599
|
+
|
|
600
|
+
## Step 5: Run Specialist Integrations (Optional / Heuristic)
|
|
601
|
+
|
|
602
|
+
Run the specialist workflows selected explicitly or by the Step 2.5 heuristics.
|
|
603
|
+
|
|
604
|
+
### 5.1: Run Bughunt
|
|
605
|
+
|
|
606
|
+
**Track-level:**
|
|
607
|
+
```bash
|
|
608
|
+
/draft:bughunt --track <id>
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
**Project-level:**
|
|
612
|
+
```bash
|
|
613
|
+
/draft:bughunt
|
|
614
|
+
```
|
|
615
|
+
|
|
616
|
+
Parse output from `draft/tracks/<id>/bughunt-report-latest.md` or `draft/bughunt-report-latest.md`
|
|
617
|
+
|
|
618
|
+
### 5.2: Run Assist Review
|
|
619
|
+
|
|
620
|
+
If `with-assist`, `full`, or handoff heuristics selected assist-review:
|
|
621
|
+
|
|
622
|
+
- run `/draft:assist-review` for the same track context
|
|
623
|
+
- extract:
|
|
624
|
+
- intent summary
|
|
625
|
+
- structural edits
|
|
626
|
+
- HLD/LLD drift flags
|
|
627
|
+
- suggested review order
|
|
628
|
+
|
|
629
|
+
Append this as a dedicated section in the final review report rather than merging it into bug findings.
|
|
630
|
+
|
|
631
|
+
### 5.3: Run Deep Review
|
|
632
|
+
|
|
633
|
+
If deep-review escalation is justified and the scope maps to one dominant module:
|
|
634
|
+
|
|
635
|
+
- run `/draft:deep-review <module>`
|
|
636
|
+
- extract critical and important findings relevant to the current diff
|
|
637
|
+
- include a short `Deep Review Escalation` section in the report
|
|
638
|
+
|
|
639
|
+
If deep-review is recommended but not auto-run:
|
|
640
|
+
|
|
641
|
+
- add a `Next Actions` row pointing to `/draft:review deep <module>` or `/draft:deep-review <module>`
|
|
642
|
+
|
|
643
|
+
### 5.4: Aggregate Findings
|
|
644
|
+
|
|
645
|
+
Merge findings from:
|
|
646
|
+
1. Reviewer agent (Stage 1, 2, 3)
|
|
647
|
+
2. Bughunt results (if run)
|
|
648
|
+
3. Deep-review findings relevant to the current diff (if run)
|
|
649
|
+
|
|
650
|
+
**Deduplication:**
|
|
651
|
+
- Two findings are duplicates if they reference the **same file and line number**
|
|
652
|
+
- Severity ordering: **Critical > Important > Minor**
|
|
653
|
+
- On duplicate: keep the finding with highest severity; merge tool attribution as "Found by: reviewer, bughunt, deep-review" as applicable
|
|
654
|
+
- If same severity from different tools: merge into single finding, combine descriptions
|
|
655
|
+
|
|
656
|
+
---
|
|
657
|
+
|
|
658
|
+
## Step 6: Generate Review Report
|
|
659
|
+
|
|
660
|
+
Create unified review report in markdown format.
|
|
661
|
+
|
|
662
|
+
**MANDATORY: Include YAML frontmatter with git metadata.** Follow the procedure in `core/shared/git-report-metadata.md` to gather git info, generate frontmatter, and include the report header table. Use `generated_by: "draft:review"`.
|
|
663
|
+
|
|
664
|
+
### Track-Level Report
|
|
665
|
+
|
|
666
|
+
**Path:** `draft/tracks/<id>/review-report-<timestamp>.md` (where `<timestamp>` is generated via `date +%Y-%m-%dT%H%M`, e.g., `2026-03-15T1430`)
|
|
667
|
+
|
|
668
|
+
After writing the timestamped report, create a symlink pointing to it:
|
|
669
|
+
```bash
|
|
670
|
+
ln -sf review-report-<timestamp>.md draft/tracks/<id>/review-report-latest.md
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
```markdown
|
|
674
|
+
[YAML frontmatter — see core/shared/git-report-metadata.md, use track_id: "<id>"]
|
|
675
|
+
|
|
676
|
+
# Review Report: <Track Title>
|
|
677
|
+
|
|
678
|
+
[Report header table — see core/shared/git-report-metadata.md]
|
|
679
|
+
|
|
680
|
+
**Track ID:** <id>
|
|
681
|
+
**Reviewer:** [Current model name and context window from runtime]
|
|
682
|
+
**Commit Range:** <first_SHA>^..<last_SHA>
|
|
683
|
+
**Diff Stats:** N files changed, M insertions(+), K deletions(-)
|
|
684
|
+
|
|
685
|
+
---
|
|
686
|
+
|
|
687
|
+
## Stage 1: Automated Validation
|
|
688
|
+
|
|
689
|
+
**Status:** PASS / FAIL
|
|
690
|
+
|
|
691
|
+
- **Blast Radius:** HIGH | MEDIUM | STANDARD — [list hotspot files if HIGH/MEDIUM]
|
|
692
|
+
- **Architecture Conformance:** PASS/FAIL
|
|
693
|
+
- **Dead Code:** N found
|
|
694
|
+
- **Dependency Cycles:** PASS/FAIL
|
|
695
|
+
- **Security Scan:** N issues found
|
|
696
|
+
- **Dependency Vulnerabilities:** N Critical / N High (or "Clean" if scanner found none)
|
|
697
|
+
- **Performance:** N anti-patterns detected
|
|
698
|
+
|
|
699
|
+
[If FAIL: List critical structural issues and stop here]
|
|
700
|
+
|
|
701
|
+
---
|
|
702
|
+
|
|
703
|
+
## Stage 2: Spec Compliance
|
|
704
|
+
|
|
705
|
+
**Status:** PASS / FAIL
|
|
706
|
+
|
|
707
|
+
### Requirements Coverage
|
|
708
|
+
- [x] Requirement 1 - Implemented in <file:line>
|
|
709
|
+
- [x] Requirement 2 - Implemented in <file:line>
|
|
710
|
+
- [ ] Requirement 3 - **MISSING**
|
|
711
|
+
|
|
712
|
+
### Acceptance Criteria
|
|
713
|
+
- [x] Criterion 1 - Verified in <file:line>
|
|
714
|
+
- [x] Criterion 2 - Verified in <file:line>
|
|
715
|
+
- [ ] Criterion 3 - **NOT MET**
|
|
716
|
+
|
|
717
|
+
[If FAIL: List gaps and stop here]
|
|
718
|
+
|
|
719
|
+
---
|
|
720
|
+
|
|
721
|
+
## Stage 3: Code Quality
|
|
722
|
+
|
|
723
|
+
**Status:** PASS / PASS WITH NOTES / FAIL
|
|
724
|
+
|
|
725
|
+
### Critical Issues
|
|
726
|
+
[None / List with file:line]
|
|
727
|
+
|
|
728
|
+
### Important Issues
|
|
729
|
+
[None / List with file:line]
|
|
730
|
+
|
|
731
|
+
### Minor Notes
|
|
732
|
+
[None / List items]
|
|
733
|
+
|
|
734
|
+
---
|
|
735
|
+
|
|
736
|
+
[If with-bughunt or full]
|
|
737
|
+
## Integrations
|
|
738
|
+
|
|
739
|
+
### Bug Hunt Results
|
|
740
|
+
- **Critical:** N found
|
|
741
|
+
- **Important:** N found
|
|
742
|
+
- **Minor:** N found
|
|
743
|
+
- Full report: `./bughunt-report-latest.md`
|
|
744
|
+
|
|
745
|
+
---
|
|
746
|
+
|
|
747
|
+
## Summary
|
|
748
|
+
|
|
749
|
+
**Total Semantic Issues:** N
|
|
750
|
+
- Critical: N
|
|
751
|
+
- Important: N
|
|
752
|
+
- Minor: N
|
|
753
|
+
|
|
754
|
+
**Verdict:** PASS / PASS WITH NOTES / FAIL
|
|
755
|
+
|
|
756
|
+
**Required Actions:**
|
|
757
|
+
1. [Action item if any]
|
|
758
|
+
2. [Action item if any]
|
|
759
|
+
|
|
760
|
+
---
|
|
761
|
+
|
|
762
|
+
## Recommendations
|
|
763
|
+
|
|
764
|
+
[If incomplete tasks found]
|
|
765
|
+
⚠️ **Warning:** This track has N incomplete tasks. Consider completing all tasks before marking track as done.
|
|
766
|
+
|
|
767
|
+
[If no critical issues]
|
|
768
|
+
✅ **No blocking issues found.** This track is ready to merge.
|
|
769
|
+
|
|
770
|
+
[If critical issues found]
|
|
771
|
+
❌ **Critical issues must be resolved before proceeding.**
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
### Project-Level Report
|
|
775
|
+
|
|
776
|
+
**Path:** `draft/review-report-<timestamp>.md` (where `<timestamp>` is generated via `date +%Y-%m-%dT%H%M`, e.g., `2026-03-15T1430`)
|
|
777
|
+
|
|
778
|
+
After writing the timestamped report, create a symlink pointing to it:
|
|
779
|
+
```bash
|
|
780
|
+
ln -sf review-report-<timestamp>.md draft/review-report-latest.md
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
Similar format but:
|
|
784
|
+
- No Stage 2 section (no spec compliance)
|
|
785
|
+
- Header shows scope instead of track ID:
|
|
786
|
+
- `project`: "Scope: Uncommitted changes"
|
|
787
|
+
- `files <pattern>`: "Scope: Files matching '<pattern>'"
|
|
788
|
+
- `commits <range>`: "Scope: Commits <range>"
|
|
789
|
+
- Each run creates a new timestamped file; the `-latest.md` symlink always points to the most recent report
|
|
790
|
+
- Include "Previous review: <timestamp>" if a prior `-latest.md` symlink exists (read its target to determine the previous timestamp)
|
|
791
|
+
|
|
792
|
+
### Report History
|
|
793
|
+
|
|
794
|
+
Previous timestamped reports are preserved. The `-latest.md` symlink always points to the most recent report.
|
|
795
|
+
|
|
796
|
+
---
|
|
797
|
+
|
|
798
|
+
## Step 7: Update Metadata (Track-Level Only)
|
|
799
|
+
|
|
800
|
+
For track-level reviews, update metadata.json with review status.
|
|
801
|
+
|
|
802
|
+
**Condition:** Always update metadata after generating the review report, regardless of verdict. This ensures review history is tracked for all outcomes (PASS, PASS_WITH_NOTES, or FAIL).
|
|
803
|
+
|
|
804
|
+
### 7.1: Read Current Metadata
|
|
805
|
+
|
|
806
|
+
Load `draft/tracks/<id>/metadata.json`
|
|
807
|
+
|
|
808
|
+
### 7.2: Add Review Fields
|
|
809
|
+
|
|
810
|
+
```json
|
|
811
|
+
{
|
|
812
|
+
"id": "<track_id>",
|
|
813
|
+
...
|
|
814
|
+
"lastReviewed": "<ISO timestamp>",
|
|
815
|
+
"reviewCount": N,
|
|
816
|
+
"lastReviewVerdict": "PASS" | "PASS_WITH_NOTES" | "FAIL"
|
|
817
|
+
}
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
Increment `reviewCount` on each review.
|
|
821
|
+
|
|
822
|
+
### 7.3: Write Updated Metadata
|
|
823
|
+
|
|
824
|
+
Save updated metadata.json
|
|
825
|
+
|
|
826
|
+
---
|
|
827
|
+
|
|
828
|
+
## Step 8: Present Results
|
|
829
|
+
|
|
830
|
+
Display summary to user with actionable next steps.
|
|
831
|
+
|
|
832
|
+
### Success Output
|
|
833
|
+
|
|
834
|
+
```
|
|
835
|
+
✅ Review complete: <track_id>
|
|
836
|
+
|
|
837
|
+
Report: draft/tracks/<id>/review-report-<timestamp>.md (symlink: review-report-latest.md)
|
|
838
|
+
|
|
839
|
+
Summary:
|
|
840
|
+
- Stage 1 (Automated Validation): PASS
|
|
841
|
+
- Stage 2 (Spec Compliance): PASS
|
|
842
|
+
- Stage 3 (Code Quality): PASS WITH NOTES
|
|
843
|
+
- Total semantic issues: 12 (0 Critical, 3 Important, 9 Minor)
|
|
844
|
+
|
|
845
|
+
[If full]
|
|
846
|
+
Additional Checks:
|
|
847
|
+
- Bug Hunt: 5 medium-severity findings
|
|
848
|
+
|
|
849
|
+
Verdict: PASS WITH NOTES
|
|
850
|
+
|
|
851
|
+
Recommended actions:
|
|
852
|
+
1. Fix 3 Important issues (see report)
|
|
853
|
+
2. Review 9 Minor notes for future improvements
|
|
854
|
+
|
|
855
|
+
Next: Address findings and run /draft:review again, or mark track complete.
|
|
856
|
+
```
|
|
857
|
+
|
|
858
|
+
### Failure Output
|
|
859
|
+
|
|
860
|
+
```
|
|
861
|
+
❌ Review failed: <track_id>
|
|
862
|
+
|
|
863
|
+
Report: draft/tracks/<id>/review-report-<timestamp>.md (symlink: review-report-latest.md)
|
|
864
|
+
|
|
865
|
+
Stage 1 (Automated Validation): PASS
|
|
866
|
+
Stage 2 (Spec Compliance): FAIL
|
|
867
|
+
- 3 requirements not implemented
|
|
868
|
+
- 2 acceptance criteria not met
|
|
869
|
+
|
|
870
|
+
Stage 3: SKIPPED (Stage 2 must pass first)
|
|
871
|
+
|
|
872
|
+
Verdict: FAIL
|
|
873
|
+
|
|
874
|
+
Required actions:
|
|
875
|
+
1. Implement missing requirements (see report)
|
|
876
|
+
2. Meet all acceptance criteria
|
|
877
|
+
3. Run /draft:implement to resume work
|
|
878
|
+
|
|
879
|
+
Next: Fix gaps and run /draft:review again.
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
---
|
|
883
|
+
|
|
884
|
+
## Error Handling
|
|
885
|
+
|
|
886
|
+
### Missing Draft Directory
|
|
887
|
+
|
|
888
|
+
```
|
|
889
|
+
Error: Draft not initialized.
|
|
890
|
+
Run /draft:init to set up Context-Driven Development.
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
### No Tracks Found
|
|
894
|
+
|
|
895
|
+
```
|
|
896
|
+
Error: No tracks found in draft/tracks.md
|
|
897
|
+
Run /draft:new-track to create your first track.
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
### Track Not Found
|
|
901
|
+
|
|
902
|
+
```
|
|
903
|
+
Error: Track 'xyz' not found.
|
|
904
|
+
|
|
905
|
+
Did you mean:
|
|
906
|
+
1. add-review-command
|
|
907
|
+
2. enterprise-readiness
|
|
908
|
+
|
|
909
|
+
Use exact track ID or run /draft:status to see all tracks.
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
### Ambiguous Match
|
|
913
|
+
|
|
914
|
+
```
|
|
915
|
+
Multiple tracks match 'review':
|
|
916
|
+
1. add-review-command - Add /draft:review Command [~]
|
|
917
|
+
2. review-architecture-md - Review architecture.md [x]
|
|
918
|
+
|
|
919
|
+
Select track (1-2):
|
|
920
|
+
```
|
|
921
|
+
|
|
922
|
+
### Invalid Git Range
|
|
923
|
+
|
|
924
|
+
```
|
|
925
|
+
Error: Invalid commit range 'main...feature'
|
|
926
|
+
Git error: fatal: ambiguous argument 'feature': unknown revision
|
|
927
|
+
|
|
928
|
+
Verify the range exists:
|
|
929
|
+
git log main...feature
|
|
930
|
+
```
|
|
931
|
+
|
|
932
|
+
### Missing Commits in Plan
|
|
933
|
+
|
|
934
|
+
```
|
|
935
|
+
⚠️ Warning: No commit SHAs found in plan.md
|
|
936
|
+
|
|
937
|
+
Cannot determine commit range for review.
|
|
938
|
+
|
|
939
|
+
Options:
|
|
940
|
+
1. Manually specify range: /draft:review track <id> commits <range>
|
|
941
|
+
2. Review uncommitted changes: /draft:review project
|
|
942
|
+
```
|
|
943
|
+
|
|
944
|
+
---
|
|
945
|
+
|
|
946
|
+
## Anti-Patterns
|
|
947
|
+
|
|
948
|
+
| Don't | Instead |
|
|
949
|
+
|-------|---------|
|
|
950
|
+
| Skip Stage 1 (Automated Validation) | Always run automated checks first |
|
|
951
|
+
| Skip Stage 2 (Spec Compliance) | Always verify spec compliance before quality checks |
|
|
952
|
+
| Run Stage 3 when Stage 2 fails | Fix spec gaps before quality checks |
|
|
953
|
+
| Ignore incomplete tasks | Warn user, suggest completing work first |
|
|
954
|
+
| Auto-fix issues found | Report only, let developer decide |
|
|
955
|
+
| Batch multiple tracks | Review one track at a time |
|
|
956
|
+
|
|
957
|
+
---
|
|
958
|
+
|
|
959
|
+
## Pattern Learning
|
|
960
|
+
|
|
961
|
+
After generating the review report, execute the pattern learning phase from `core/shared/pattern-learning.md` to update `draft/guardrails.md` with patterns discovered during this review.
|
|
962
|
+
|
|
963
|
+
---
|
|
964
|
+
|
|
965
|
+
## Examples
|
|
966
|
+
|
|
967
|
+
### Review active track
|
|
968
|
+
```bash
|
|
969
|
+
/draft:review
|
|
970
|
+
```
|
|
971
|
+
|
|
972
|
+
### Review specific track by ID
|
|
973
|
+
```bash
|
|
974
|
+
/draft:review track add-user-auth
|
|
975
|
+
```
|
|
976
|
+
|
|
977
|
+
### Review specific track by name (fuzzy)
|
|
978
|
+
```bash
|
|
979
|
+
/draft:review track "user authentication"
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
### Comprehensive track review
|
|
983
|
+
```bash
|
|
984
|
+
/draft:review track add-user-auth full
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
### Review uncommitted changes
|
|
988
|
+
```bash
|
|
989
|
+
/draft:review project
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
### Review specific files
|
|
993
|
+
```bash
|
|
994
|
+
/draft:review files "src/**/*.ts"
|
|
995
|
+
```
|
|
996
|
+
|
|
997
|
+
### Review commit range
|
|
998
|
+
```bash
|
|
999
|
+
/draft:review commits main...feature-branch
|
|
1000
|
+
```
|
|
1001
|
+
|
|
1002
|
+
### Review with bughunt
|
|
1003
|
+
```bash
|
|
1004
|
+
/draft:review track my-feature with-bughunt
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
### Explicit quick review via parent
|
|
1008
|
+
```bash
|
|
1009
|
+
/draft:review quick files "src/**/*.ts"
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
### Explicit deep review via parent
|
|
1013
|
+
```bash
|
|
1014
|
+
/draft:review deep auth
|
|
1015
|
+
```
|
|
1016
|
+
|
|
1017
|
+
### Explicit assist review via parent
|
|
1018
|
+
```bash
|
|
1019
|
+
/draft:review assist track my-feature
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
---
|
|
1023
|
+
|
|
1024
|
+
## Report Closing: Next Actions (REQUIRED)
|
|
1025
|
+
|
|
1026
|
+
Every review report must end with a `## Next Actions` section listing the smallest set of follow-ups in execution order. Use this exact shape:
|
|
1027
|
+
|
|
1028
|
+
```markdown
|
|
1029
|
+
## Next Actions
|
|
1030
|
+
|
|
1031
|
+
| # | Action | Owner | Blocker? | Skill / Command |
|
|
1032
|
+
|---|---|---|---|---|
|
|
1033
|
+
| 1 | <imperative one-liner> | <author\|reviewer\|TBD> | yes/no | `/draft:<skill> <args>` or `n/a` |
|
|
1034
|
+
```
|
|
1035
|
+
|
|
1036
|
+
Rules:
|
|
1037
|
+
- Critical findings produce blocker rows (`Blocker? = yes`); proceeding to merge is forbidden until cleared.
|
|
1038
|
+
- Each action is imperative ("Add CSRF token to /api/transfer"), not a restatement of the finding.
|
|
1039
|
+
- Suggest the Draft follow-up when one applies (`/draft:debug`, `/draft:regression`, `/draft:tech-debt`, `/draft:bughunt`, `/draft:adr`). Otherwise put `n/a`.
|
|
1040
|
+
- Cap at 7 actions; if more remain, add a final row pointing at the full report.
|
|
1041
|
+
|
|
1042
|
+
## Cross-Skill Dispatch
|
|
1043
|
+
|
|
1044
|
+
### Auto-Invoke at Completion
|
|
1045
|
+
|
|
1046
|
+
- **Coverage check:** If TDD enabled in workflow.md, auto-run `/draft:coverage` and include results in review report
|
|
1047
|
+
|
|
1048
|
+
### Suggestions at Completion
|
|
1049
|
+
|
|
1050
|
+
After review completion, based on findings:
|
|
1051
|
+
|
|
1052
|
+
**If significant code quality findings:**
|
|
1053
|
+
```
|
|
1054
|
+
"Review complete. Consider:
|
|
1055
|
+
→ /draft:tech-debt — Catalog and prioritize the technical debt found"
|
|
1056
|
+
```
|
|
1057
|
+
|
|
1058
|
+
**If new public APIs lack documentation:**
|
|
1059
|
+
```
|
|
1060
|
+
→ /draft:documentation api — Document new API endpoints"
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
**If undocumented design decisions discovered:**
|
|
1064
|
+
```
|
|
1065
|
+
→ /draft:adr — Record architectural decisions found during review"
|
|
1066
|
+
```
|
|
1067
|
+
|
|
1068
|
+
### Jira Sync
|
|
1069
|
+
|
|
1070
|
+
If Jira ticket linked, sync via `core/shared/jira-sync.md`:
|
|
1071
|
+
- Attach `review-report-latest.md` to ticket
|
|
1072
|
+
- Post comment: "[draft] review-complete: {PASS/FAIL}. {n} findings: {critical} critical, {suggestions} suggestions."
|
|
1073
|
+
|
|
1074
|
+
## Mandatory Self-Check (before final verdict)
|
|
1075
|
+
|
|
1076
|
+
Before printing the final verdict, internally verify and report:
|
|
1077
|
+
|
|
1078
|
+
1. **Graph files queried** — which JSONL files were loaded (e.g. `architecture.json, hotspots.jsonl`) plus any live graph query-tool invocations (impact, callers, cycles).
|
|
1079
|
+
2. **Layer 1 files deliberately skipped** — list any context sections skipped as irrelevant to the diff under review.
|
|
1080
|
+
3. **Filesystem grep fallback justification** — for every `grep`/`find` run, state the concept it searched for. Source-text scans (string literals, regex matches in code) are exempt — they are not symbol/file discovery.
|
|
1081
|
+
|
|
1082
|
+
If `draft/graph/schema.yaml` does not exist, set `Graph files queried: NONE` and use justification `graph data unavailable`.
|
|
1083
|
+
|
|
1084
|
+
## Graph Usage Report (append to review report)
|
|
1085
|
+
|
|
1086
|
+
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.
|
|
1087
|
+
|
|
1088
|
+
## Skill Telemetry
|
|
1089
|
+
|
|
1090
|
+
As the last step after saving the review report, emit a metrics record. Best-effort — never block.
|
|
1091
|
+
|
|
1092
|
+
**Payload fields:**
|
|
1093
|
+
```json
|
|
1094
|
+
{
|
|
1095
|
+
"skill": "review",
|
|
1096
|
+
"track_id": "<track_id or null>",
|
|
1097
|
+
"stage_reached": "stage1|stage2|stage3",
|
|
1098
|
+
"verdict": "PASS|PASS_WITH_NOTES|NEEDS_CHANGES|FAIL",
|
|
1099
|
+
"critical_count": <N>,
|
|
1100
|
+
"important_count": <N>,
|
|
1101
|
+
"blast_radius": "HIGH|MEDIUM|STANDARD",
|
|
1102
|
+
"graph_queries": <N>,
|
|
1103
|
+
"fallback_grep_count": <N>
|
|
1104
|
+
}
|
|
1105
|
+
```
|
|
1106
|
+
|
|
1107
|
+
**Emit call:**
|
|
1108
|
+
```bash
|
|
1109
|
+
DRAFT_TOOLS="${DRAFT_PLUGIN_ROOT:-$HOME/.claude/plugins/draft}/scripts/tools"
|
|
1110
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$HOME/.cursor/plugins/local/draft/scripts/tools"
|
|
1111
|
+
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
|
|
1112
|
+
[ -x "$DRAFT_TOOLS/emit-skill-metrics.sh" ] && bash "$DRAFT_TOOLS/emit-skill-metrics.sh" \
|
|
1113
|
+
'{"skill":"review","track_id":"<id_or_null>","stage_reached":"<stage>","verdict":"<v>","critical_count":<N>,"important_count":<N>,"blast_radius":"<br>","graph_queries":<N>,"fallback_grep_count":<N>}'
|
|
1114
|
+
```
|