specweave 1.0.261 → 1.0.263
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/README.md +0 -2
- package/CLAUDE.md +27 -27
- package/bin/specweave.js +14 -85
- package/dist/dashboard/assets/index-Cv1XUAKk.css +1 -0
- package/dist/dashboard/assets/index-DHOztQSu.js +11 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/src/adapters/README.md +1 -1
- package/dist/src/adapters/agents-md-generator.js +1 -1
- package/dist/src/adapters/agents-md-generator.js.map +1 -1
- package/dist/src/adapters/claude/README.md +8 -8
- package/dist/src/adapters/claude/adapter.js +2 -2
- package/dist/src/adapters/claude-md-generator.js +2 -2
- package/dist/src/adapters/claude-md-generator.js.map +1 -1
- package/dist/src/adapters/cursor/README.md +7 -7
- package/dist/src/adapters/generic/README.md +2 -2
- package/dist/src/cli/commands/create-increment.d.ts +1 -1
- package/dist/src/cli/commands/create-increment.js +1 -1
- package/dist/src/cli/commands/update.d.ts.map +1 -1
- package/dist/src/cli/commands/update.js +64 -1
- package/dist/src/cli/commands/update.js.map +1 -1
- package/dist/src/cli/helpers/init/api-docs-config.js +7 -7
- package/dist/src/cli/helpers/init/api-docs-config.js.map +1 -1
- package/dist/src/core/config/types.d.ts +18 -0
- package/dist/src/core/config/types.d.ts.map +1 -1
- package/dist/src/core/config/types.js +4 -0
- package/dist/src/core/config/types.js.map +1 -1
- package/dist/src/core/external-tools/external-items-display.d.ts.map +1 -1
- package/dist/src/core/external-tools/external-items-display.js +1 -11
- package/dist/src/core/external-tools/external-items-display.js.map +1 -1
- package/dist/src/core/increment/increment-archiver.js +1 -1
- package/dist/src/core/increment/increment-archiver.js.map +1 -1
- package/dist/src/core/increment/metadata-manager.js +2 -2
- package/dist/src/core/increment/metadata-manager.js.map +1 -1
- package/dist/src/core/increment/template-creator.d.ts +1 -1
- package/dist/src/core/increment/template-creator.js +4 -4
- package/dist/src/core/lazy-loading/llm-plugin-detector.d.ts +2 -2
- package/dist/src/core/lazy-loading/llm-plugin-detector.d.ts.map +1 -1
- package/dist/src/core/lazy-loading/llm-plugin-detector.js +15 -5
- package/dist/src/core/lazy-loading/llm-plugin-detector.js.map +1 -1
- package/dist/src/core/living-docs/feature-consistency-validator.js +1 -1
- package/dist/src/core/living-docs/feature-consistency-validator.js.map +1 -1
- package/dist/src/core/living-docs/scaffolding/scaffold.js +3 -3
- package/dist/src/core/notifications/command-integration.d.ts.map +1 -1
- package/dist/src/core/notifications/command-integration.js +0 -1
- package/dist/src/core/notifications/command-integration.js.map +1 -1
- package/dist/src/core/reflection/reflect-handler.js +2 -2
- package/dist/src/core/reflection/reflect-handler.js.map +1 -1
- package/dist/src/core/validators/ac-presence-validator.d.ts +1 -1
- package/dist/src/core/validators/ac-presence-validator.js +3 -3
- package/dist/src/core/validators/ac-presence-validator.js.map +1 -1
- package/dist/src/dashboard/server/command-runner.d.ts.map +1 -1
- package/dist/src/dashboard/server/command-runner.js +2 -2
- package/dist/src/dashboard/server/command-runner.js.map +1 -1
- package/dist/src/dashboard/server/dashboard-server.d.ts.map +1 -1
- package/dist/src/dashboard/server/dashboard-server.js +22 -10
- package/dist/src/dashboard/server/dashboard-server.js.map +1 -1
- package/dist/src/dashboard/server/data/dashboard-data-aggregator.d.ts +9 -1
- package/dist/src/dashboard/server/data/dashboard-data-aggregator.d.ts.map +1 -1
- package/dist/src/dashboard/server/data/dashboard-data-aggregator.js +140 -13
- package/dist/src/dashboard/server/data/dashboard-data-aggregator.js.map +1 -1
- package/dist/src/dashboard/server/data/plugin-scanner.d.ts +1 -1
- package/dist/src/dashboard/server/data/plugin-scanner.d.ts.map +1 -1
- package/dist/src/dashboard/server/data/plugin-scanner.js +2 -2
- package/dist/src/dashboard/server/data/plugin-scanner.js.map +1 -1
- package/dist/src/utils/agents-md-compiler.js +1 -1
- package/dist/src/utils/agents-md-compiler.js.map +1 -1
- package/dist/src/utils/find-project-root.d.ts +5 -4
- package/dist/src/utils/find-project-root.d.ts.map +1 -1
- package/dist/src/utils/find-project-root.js +8 -10
- package/dist/src/utils/find-project-root.js.map +1 -1
- package/dist/src/utils/generate-skills-index.js +3 -3
- package/dist/src/utils/notification-constants.js +1 -1
- package/dist/src/utils/notification-constants.js.map +1 -1
- package/package.json +1 -1
- package/plugins/FINAL-AUDIT-RECOMMENDATIONS.md +3 -3
- package/plugins/specweave/PLUGIN.md +0 -22
- package/plugins/specweave/commands/analytics.md +1 -1
- package/plugins/specweave/commands/discrepancies.md +0 -1
- package/plugins/specweave/commands/living-docs.md +0 -1
- package/plugins/specweave/commands/reconcile.md +1 -1
- package/plugins/specweave/hooks/hooks.json +19 -0
- package/plugins/specweave/hooks/pre-compact.sh +39 -0
- package/plugins/specweave/hooks/stop-sync.sh +23 -1
- package/plugins/specweave/hooks/universal/fail-fast-wrapper.sh +4 -0
- package/plugins/specweave/hooks/user-prompt-submit.sh +193 -59
- package/plugins/specweave/hooks/v2/dispatchers/post-tool-use-analytics.sh +83 -0
- package/plugins/specweave/hooks/v2/dispatchers/session-start.sh +7 -0
- package/plugins/specweave/hooks/v2/guards/spec-template-enforcement-guard.sh +1 -1
- package/plugins/specweave/hooks/v2/handlers/ac-sync-dispatcher.sh +25 -6
- package/plugins/specweave/hooks/v2/handlers/universal-auto-create-dispatcher.sh +21 -3
- package/plugins/specweave/hooks/v2/lib/check-provider-enabled.sh +52 -0
- package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js +2 -2
- package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js.map +1 -1
- package/plugins/specweave/scripts/track-analytics.sh +4 -0
- package/plugins/specweave/skills/do/SKILL.md +1 -1
- package/plugins/specweave/skills/done/SKILL.md +1 -1
- package/plugins/specweave/skills/framework/SKILL.md +4 -4
- package/plugins/specweave/skills/increment/SKILL.md +192 -25
- package/plugins/specweave/skills/next/SKILL.md +36 -630
- package/plugins/specweave/skills/pm/phases/00-deep-interview.md +2 -2
- package/plugins/specweave/skills/progress-sync/SKILL.md +7 -25
- package/plugins/specweave/skills/spec-generator/SKILL.md +44 -626
- package/plugins/specweave/skills/tdd-green/SKILL.md +10 -798
- package/plugins/specweave/skills/tdd-red/SKILL.md +8 -136
- package/plugins/specweave/skills/tdd-refactor/SKILL.md +15 -147
- package/plugins/specweave-github/hooks/github-auto-create-handler.sh +23 -5
- package/src/templates/AGENTS.md.template +11 -11
- package/src/templates/CLAUDE.md.template +1 -1
- package/dist/dashboard/assets/index-CDl14O5G.css +0 -1
- package/dist/dashboard/assets/index-CmqBqnWd.js +0 -11
- package/plugins/specweave/commands/api-docs.md +0 -672
- package/plugins/specweave/commands/check-hooks.md +0 -241
- package/plugins/specweave/commands/embed-acs.md +0 -445
- package/plugins/specweave/commands/external.md +0 -145
- package/plugins/specweave/commands/import-docs.md +0 -212
- package/plugins/specweave/commands/migrate-config.md +0 -104
- package/plugins/specweave/commands/notifications.md +0 -94
- package/plugins/specweave/commands/plugin-validator.md +0 -429
- package/plugins/specweave/commands/revert-wip-limit.md +0 -82
- package/plugins/specweave/commands/sync-acs.md +0 -342
- package/plugins/specweave/commands/sync-specs.md +0 -339
- package/plugins/specweave/commands/sync-tasks.md +0 -255
- package/plugins/specweave/commands/update-scope.md +0 -351
- package/plugins/specweave/commands/validate-features.md +0 -207
- package/plugins/specweave/skills/archive-increments/SKILL.md +0 -209
- package/plugins/specweave/skills/code-review/SKILL.md +0 -598
- package/plugins/specweave/skills/increment-planner/SKILL.md +0 -238
- package/plugins/specweave/skills/increment-work-router/SKILL.md +0 -562
- package/plugins/specweave/skills/multi-project-spec-mapper/SKILL.md +0 -423
- package/plugins/specweave/skills/pm-closure-validation/SKILL.md +0 -542
- package/plugins/specweave/skills/smart-reopen-detector/SKILL.md +0 -245
- package/plugins/specweave/skills/tdd-orchestrator/SKILL.md +0 -228
- package/plugins/specweave/skills/umbrella-repo-detector/SKILL.md +0 -301
|
@@ -1,598 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Parallel code review with confidence scoring and spec compliance. Use when saying "review code", "PR review", "check my code", or "audit the code".
|
|
3
|
-
allowed-tools: Read, Bash, Grep, Glob, Task
|
|
4
|
-
model: opus
|
|
5
|
-
context: fork
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Code Review
|
|
9
|
-
|
|
10
|
-
You are a senior staff engineer running a structured, parallel code review. You coordinate multiple specialized review agents, aggregate their findings with confidence scores, and produce a single actionable report tied to SpecWeave specs and acceptance criteria.
|
|
11
|
-
|
|
12
|
-
## When to Use This Skill
|
|
13
|
-
|
|
14
|
-
**Trigger keywords**: "review code", "code review", "PR review", "review my changes", "review the PR", "check my code", "review increment code", "audit the code", "review this file", "what's wrong with this code"
|
|
15
|
-
|
|
16
|
-
Call this skill when you need to:
|
|
17
|
-
- **Review a pull request** before merge
|
|
18
|
-
- **Audit files** for bugs, security holes, or performance issues
|
|
19
|
-
- **Validate increment code** against spec.md acceptance criteria
|
|
20
|
-
- **Pre-merge quality gate** as a complement to `/sw:grill`
|
|
21
|
-
- **Spot-check specific files** during development
|
|
22
|
-
|
|
23
|
-
### How This Differs from `/sw:grill`
|
|
24
|
-
|
|
25
|
-
| Aspect | `/sw:code-review` | `/sw:grill` |
|
|
26
|
-
|--------|-------------------|-------------|
|
|
27
|
-
| **Focus** | Code correctness and quality | Increment completion readiness |
|
|
28
|
-
| **Scope** | Any code, any time | Increment files at close time |
|
|
29
|
-
| **Method** | Parallel subagents with confidence scoring | Single-pass interrogation |
|
|
30
|
-
| **Output** | Scored findings with threshold filtering | Pass/fail verdict |
|
|
31
|
-
| **When** | During development, PR review, ad-hoc | Before `/sw:done` (mandatory) |
|
|
32
|
-
|
|
33
|
-
Use both: `/sw:code-review` during development, `/sw:grill` at completion.
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## Usage
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
/sw:code-review [mode] [target] [--threshold N] [--focus AREA]
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Modes
|
|
44
|
-
|
|
45
|
-
| Mode | Target | Description |
|
|
46
|
-
|------|--------|-------------|
|
|
47
|
-
| `pr` | Branch name or PR number | Review git diff against base branch |
|
|
48
|
-
| `files` | File paths (comma-separated or glob) | Review specific files |
|
|
49
|
-
| `increment` | Increment ID (e.g., `0042`) | Review all code changed in an increment |
|
|
50
|
-
| *(auto)* | *(detected)* | Auto-detect from context |
|
|
51
|
-
|
|
52
|
-
### Flags
|
|
53
|
-
|
|
54
|
-
| Flag | Default | Description |
|
|
55
|
-
|------|---------|-------------|
|
|
56
|
-
| `--threshold` | `70` | Minimum confidence score to surface a finding (0-100) |
|
|
57
|
-
| `--focus` | `all` | Limit to specific review area: `bugs`, `security`, `performance`, `quality`, `spec` |
|
|
58
|
-
|
|
59
|
-
### Examples
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
/sw:code-review pr 42 # Review PR #42
|
|
63
|
-
/sw:code-review pr feature/auth # Review branch diff
|
|
64
|
-
/sw:code-review files src/auth/*.ts # Review specific files
|
|
65
|
-
/sw:code-review increment 0042 # Review increment code
|
|
66
|
-
/sw:code-review files src/api.ts --threshold 50 # Lower threshold, more findings
|
|
67
|
-
/sw:code-review pr 42 --focus security # Security-only review
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
## Review Process
|
|
73
|
-
|
|
74
|
-
### Phase 0: Context Gathering
|
|
75
|
-
|
|
76
|
-
Before spawning review agents, gather the full picture:
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
# 1. Determine files to review based on mode
|
|
80
|
-
# PR mode:
|
|
81
|
-
git diff --name-only $(git merge-base HEAD main)..HEAD
|
|
82
|
-
# or for a specific PR:
|
|
83
|
-
gh pr diff <number> --name-only
|
|
84
|
-
|
|
85
|
-
# Files mode:
|
|
86
|
-
# Use the provided file paths / globs directly
|
|
87
|
-
|
|
88
|
-
# Increment mode:
|
|
89
|
-
# Read tasks.md to find what was implemented, then locate source files
|
|
90
|
-
cat .specweave/increments/<id>/tasks.md
|
|
91
|
-
cat .specweave/increments/<id>/spec.md
|
|
92
|
-
|
|
93
|
-
# 2. Load project conventions
|
|
94
|
-
cat CLAUDE.md 2>/dev/null
|
|
95
|
-
cat .specweave/config.json 2>/dev/null
|
|
96
|
-
|
|
97
|
-
# 3. Load spec context (if increment or PR linked to increment)
|
|
98
|
-
cat .specweave/increments/<id>/spec.md 2>/dev/null
|
|
99
|
-
cat .specweave/increments/<id>/plan.md 2>/dev/null
|
|
100
|
-
|
|
101
|
-
# 4. Get file statistics
|
|
102
|
-
# Count total files, lines changed, languages involved
|
|
103
|
-
git diff --stat $(git merge-base HEAD main)..HEAD
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
**Scope limits**: If the diff exceeds 3000 lines, prioritize:
|
|
107
|
-
1. Files with security-sensitive patterns (auth, crypto, input handling)
|
|
108
|
-
2. Files with business logic
|
|
109
|
-
3. New files over modified files
|
|
110
|
-
4. Files linked to incomplete ACs
|
|
111
|
-
|
|
112
|
-
Inform the user if files were excluded due to scope limits.
|
|
113
|
-
|
|
114
|
-
### Phase 1: Spawn Parallel Review Agents
|
|
115
|
-
|
|
116
|
-
Launch 3-5 specialized subagents using the `Task` tool. Each agent reviews the same set of files but through a different lens. All agents run in parallel.
|
|
117
|
-
|
|
118
|
-
**Agent deployment strategy**:
|
|
119
|
-
- If `--focus` is set to a single area, spawn only that agent (plus spec compliance if increment context exists)
|
|
120
|
-
- If `--focus all` (default), spawn all 5 agents
|
|
121
|
-
- Each agent receives: file list, file contents, project conventions, spec context
|
|
122
|
-
|
|
123
|
-
#### Agent 1: Bug Detection and Correctness
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
ROLE: Bug hunter and correctness validator
|
|
127
|
-
OBJECTIVE: Find logic errors, edge cases, race conditions, and correctness issues
|
|
128
|
-
|
|
129
|
-
Review each file for:
|
|
130
|
-
- Logic errors: off-by-one, wrong comparison operators, inverted conditions
|
|
131
|
-
- Null/undefined handling: missing null checks, optional chaining gaps
|
|
132
|
-
- Type mismatches: incorrect casts, type coercion bugs, any-typed escapes
|
|
133
|
-
- Race conditions: shared mutable state, async ordering issues, missing locks
|
|
134
|
-
- Error handling: swallowed errors, incorrect catch scope, missing finally blocks
|
|
135
|
-
- Edge cases: empty arrays, zero values, negative numbers, boundary conditions
|
|
136
|
-
- State management: stale closures, incorrect dependency arrays, memory leaks
|
|
137
|
-
- API contracts: request/response shape mismatches, missing fields, wrong HTTP methods
|
|
138
|
-
|
|
139
|
-
For each finding, provide:
|
|
140
|
-
- File path and line number
|
|
141
|
-
- Code snippet showing the issue
|
|
142
|
-
- Why it is a bug (concrete scenario that triggers it)
|
|
143
|
-
- Confidence score 0-100 (how certain you are this is a real bug)
|
|
144
|
-
- Suggested fix
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
#### Agent 2: Security Vulnerabilities
|
|
148
|
-
|
|
149
|
-
```
|
|
150
|
-
ROLE: Security auditor (OWASP-focused)
|
|
151
|
-
OBJECTIVE: Find security vulnerabilities, injection vectors, and auth/authz gaps
|
|
152
|
-
|
|
153
|
-
Check against OWASP Top 10 (2021):
|
|
154
|
-
- A01: Broken Access Control - missing auth checks, IDOR, privilege escalation
|
|
155
|
-
- A02: Cryptographic Failures - weak hashing, plaintext secrets, insecure random
|
|
156
|
-
- A03: Injection - SQL injection, XSS, command injection, template injection, path traversal
|
|
157
|
-
- A04: Insecure Design - missing rate limiting, no abuse prevention, trust boundary violations
|
|
158
|
-
- A05: Security Misconfiguration - debug mode, default credentials, overly permissive CORS
|
|
159
|
-
- A06: Vulnerable Components - known CVEs in dependencies (check package.json / lock files)
|
|
160
|
-
- A07: Auth Failures - weak password policy, missing MFA hooks, session fixation
|
|
161
|
-
- A08: Data Integrity - deserialization issues, unsigned data, cache poisoning
|
|
162
|
-
- A09: Logging Failures - sensitive data in logs, missing audit trail, PII exposure
|
|
163
|
-
- A10: SSRF - unvalidated URLs, DNS rebinding, internal network access
|
|
164
|
-
|
|
165
|
-
Additional checks:
|
|
166
|
-
- Secrets in code (API keys, tokens, passwords in source)
|
|
167
|
-
- Unsafe regex (ReDoS patterns)
|
|
168
|
-
- Prototype pollution (JavaScript/TypeScript)
|
|
169
|
-
- Directory traversal via user-controlled paths
|
|
170
|
-
|
|
171
|
-
For each finding, provide:
|
|
172
|
-
- OWASP category (A01-A10) or CWE ID
|
|
173
|
-
- File path and line number
|
|
174
|
-
- Attack scenario (how an attacker would exploit this)
|
|
175
|
-
- Confidence score 0-100
|
|
176
|
-
- Remediation with code example
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
#### Agent 3: Performance Issues
|
|
180
|
-
|
|
181
|
-
```
|
|
182
|
-
ROLE: Performance engineer
|
|
183
|
-
OBJECTIVE: Find performance bottlenecks, inefficient patterns, and scalability issues
|
|
184
|
-
|
|
185
|
-
Review for:
|
|
186
|
-
- Algorithmic complexity: O(n^2) or worse in loops, unnecessary nested iterations
|
|
187
|
-
- N+1 queries: database calls inside loops, missing eager loading / batching
|
|
188
|
-
- Memory issues: unbounded caches, large object copies, missing cleanup, event listener leaks
|
|
189
|
-
- Blocking operations: sync I/O in async context, long-running computations on main thread
|
|
190
|
-
- Unnecessary work: redundant computations, missing memoization, repeated parsing
|
|
191
|
-
- Bundle size: large imports when tree-shakeable alternative exists, unused dependencies
|
|
192
|
-
- Network: missing pagination, over-fetching, no request deduplication, missing caching headers
|
|
193
|
-
- Database: missing indexes (inferred from query patterns), full table scans, unoptimized joins
|
|
194
|
-
- Concurrency: missing connection pooling, unbounded parallelism, thundering herd
|
|
195
|
-
|
|
196
|
-
For each finding, provide:
|
|
197
|
-
- Performance impact estimate (latency, memory, CPU)
|
|
198
|
-
- File path and line number
|
|
199
|
-
- Current vs recommended approach
|
|
200
|
-
- Confidence score 0-100
|
|
201
|
-
- Optimization with code example
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
#### Agent 4: Code Quality and Maintainability
|
|
205
|
-
|
|
206
|
-
```
|
|
207
|
-
ROLE: Code quality reviewer
|
|
208
|
-
OBJECTIVE: Find maintainability issues, code smells, and standards violations
|
|
209
|
-
|
|
210
|
-
Review for:
|
|
211
|
-
- SOLID violations: god classes, tight coupling, interface segregation issues
|
|
212
|
-
- DRY violations: duplicated logic across files (search for similar patterns)
|
|
213
|
-
- Naming: unclear variable/function names, misleading names, inconsistent conventions
|
|
214
|
-
- Complexity: functions > 50 lines, cyclomatic complexity > 10, deep nesting (> 3 levels)
|
|
215
|
-
- Error messages: unhelpful error strings, missing context in errors, raw error exposure
|
|
216
|
-
- Comments: outdated comments, commented-out code, missing JSDoc on public APIs
|
|
217
|
-
- Type safety: excessive use of `any`, missing return types, loose generics
|
|
218
|
-
- Testing gaps: public functions without tests, complex branches without coverage
|
|
219
|
-
- Project conventions: violations of patterns established in CLAUDE.md or existing codebase
|
|
220
|
-
- Dead code: unused exports, unreachable branches, obsolete feature flags
|
|
221
|
-
|
|
222
|
-
For each finding, provide:
|
|
223
|
-
- Code smell category
|
|
224
|
-
- File path and line number
|
|
225
|
-
- Why it hurts maintainability (concrete scenario)
|
|
226
|
-
- Confidence score 0-100
|
|
227
|
-
- Refactoring suggestion with code example
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
#### Agent 5: Spec Compliance (SpecWeave-specific)
|
|
231
|
-
|
|
232
|
-
```
|
|
233
|
-
ROLE: Spec compliance auditor
|
|
234
|
-
OBJECTIVE: Verify code satisfies acceptance criteria and follows spec/plan decisions
|
|
235
|
-
|
|
236
|
-
This agent ONLY runs when SpecWeave increment context is available.
|
|
237
|
-
|
|
238
|
-
Review for:
|
|
239
|
-
- AC coverage: does the code implement each acceptance criterion from spec.md?
|
|
240
|
-
- AC correctness: does the implementation CORRECTLY satisfy the AC, or just partially?
|
|
241
|
-
- Plan adherence: does the code follow architectural decisions from plan.md and ADRs?
|
|
242
|
-
- Missing requirements: are there spec requirements with no corresponding code?
|
|
243
|
-
- Scope creep: is there code that goes beyond what the spec requires? (not always bad, but flag it)
|
|
244
|
-
- Task alignment: do completed tasks in tasks.md match what was actually implemented?
|
|
245
|
-
- Test coverage: are there tests for each AC? Do they actually verify the criteria?
|
|
246
|
-
|
|
247
|
-
For each finding, provide:
|
|
248
|
-
- Related AC ID (e.g., AC-US1-01) or spec section
|
|
249
|
-
- File path and line number (or "missing implementation")
|
|
250
|
-
- Gap description: what the spec requires vs what the code does
|
|
251
|
-
- Confidence score 0-100
|
|
252
|
-
- Recommendation
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### Phase 2: Aggregate and Score
|
|
256
|
-
|
|
257
|
-
After all agents complete, aggregate findings:
|
|
258
|
-
|
|
259
|
-
1. **Collect** all findings from all agents
|
|
260
|
-
2. **Deduplicate**: If multiple agents flag the same line/issue, merge into one finding and take the highest confidence score. Note which agents agreed (increases credibility).
|
|
261
|
-
3. **Filter by threshold**: Remove findings below the confidence threshold (default: 70)
|
|
262
|
-
4. **Sort**: By severity (critical > high > medium > low), then by confidence score descending
|
|
263
|
-
5. **Cross-reference with spec**: If increment context exists, tag each finding with related ACs
|
|
264
|
-
|
|
265
|
-
### Phase 3: Generate Report
|
|
266
|
-
|
|
267
|
-
Produce the structured report described in the Output Format section below.
|
|
268
|
-
|
|
269
|
-
---
|
|
270
|
-
|
|
271
|
-
## Confidence Scoring Guide
|
|
272
|
-
|
|
273
|
-
Agents assign confidence scores based on certainty that the finding is a real issue:
|
|
274
|
-
|
|
275
|
-
| Score Range | Meaning | Typical Scenarios |
|
|
276
|
-
|-------------|---------|-------------------|
|
|
277
|
-
| **90-100** | Certain | Obvious bug (null deref), hardcoded secret, SQL injection with user input |
|
|
278
|
-
| **80-89** | Very likely | Missing error handling on external call, N+1 query pattern, IDOR vulnerability |
|
|
279
|
-
| **70-79** | Likely | Potential race condition, performance issue at scale, incomplete AC implementation |
|
|
280
|
-
| **60-69** | Possible | Code smell that might cause issues, questionable design choice |
|
|
281
|
-
| **50-59** | Uncertain | Style preference, minor naming issue, theoretical concern |
|
|
282
|
-
| **Below 50** | Speculative | "Might be an issue if..." - filtered out by default |
|
|
283
|
-
|
|
284
|
-
**Calibration rules for agents**:
|
|
285
|
-
- Do NOT inflate scores to get past the threshold. Be honest.
|
|
286
|
-
- A real bug with clear reproduction steps = 90+
|
|
287
|
-
- A pattern that USUALLY causes problems but might be intentional = 70-79
|
|
288
|
-
- Something that COULD be a problem in some contexts = 50-69
|
|
289
|
-
- When in doubt, score lower. False positives waste developer time.
|
|
290
|
-
|
|
291
|
-
---
|
|
292
|
-
|
|
293
|
-
## Severity Classification
|
|
294
|
-
|
|
295
|
-
| Severity | Definition | Action |
|
|
296
|
-
|----------|-----------|--------|
|
|
297
|
-
| **CRITICAL** | Will cause data loss, security breach, or production outage | Must fix before merge |
|
|
298
|
-
| **HIGH** | Significant bug, vulnerability, or performance issue | Should fix before merge |
|
|
299
|
-
| **MEDIUM** | Code quality issue, minor bug, or maintainability concern | Fix recommended |
|
|
300
|
-
| **LOW** | Style issue, minor optimization, or suggestion | Fix at discretion |
|
|
301
|
-
|
|
302
|
-
**Severity assignment rules**:
|
|
303
|
-
- Security vulnerabilities with exploit path = CRITICAL
|
|
304
|
-
- Logic bugs that affect correctness = HIGH or CRITICAL (depending on blast radius)
|
|
305
|
-
- Performance issues = MEDIUM or HIGH (depending on user impact)
|
|
306
|
-
- Code quality / maintainability = LOW or MEDIUM
|
|
307
|
-
- Spec compliance gaps for MUST-have ACs = HIGH
|
|
308
|
-
- Spec compliance gaps for SHOULD-have ACs = MEDIUM
|
|
309
|
-
|
|
310
|
-
---
|
|
311
|
-
|
|
312
|
-
## Output Format
|
|
313
|
-
|
|
314
|
-
```
|
|
315
|
-
================================================================================
|
|
316
|
-
CODE REVIEW REPORT
|
|
317
|
-
================================================================================
|
|
318
|
-
|
|
319
|
-
Mode: {pr|files|increment} | Target: {target description}
|
|
320
|
-
Files reviewed: {count} | Lines analyzed: {count}
|
|
321
|
-
Threshold: {N}/100 | Focus: {area or "all"}
|
|
322
|
-
Agents: {count} dispatched, {count} completed
|
|
323
|
-
|
|
324
|
-
{If increment context available:}
|
|
325
|
-
Increment: {id} - {name}
|
|
326
|
-
Spec ACs: {total} | Covered by code: {count} | Gaps found: {count}
|
|
327
|
-
|
|
328
|
-
================================================================================
|
|
329
|
-
FINDINGS ({total count above threshold})
|
|
330
|
-
================================================================================
|
|
331
|
-
|
|
332
|
-
--- Finding #{N} -----------------------------------------------------------
|
|
333
|
-
Severity: {CRITICAL|HIGH|MEDIUM|LOW}
|
|
334
|
-
Confidence: {score}/100
|
|
335
|
-
Category: {Bugs|Security|Performance|Quality|Spec Compliance}
|
|
336
|
-
Agents: {which agents flagged this, e.g., "Bug Detection, Security"}
|
|
337
|
-
File: {file_path}:{line_number}
|
|
338
|
-
{If spec context:} Related AC: {AC-ID}
|
|
339
|
-
|
|
340
|
-
ISSUE:
|
|
341
|
-
{Clear, concise description of the problem}
|
|
342
|
-
|
|
343
|
-
EVIDENCE:
|
|
344
|
-
```{language}
|
|
345
|
-
{code snippet showing the problematic code, 5-15 lines with context}
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
IMPACT:
|
|
349
|
-
{What happens if this ships - concrete scenario, not abstract risk}
|
|
350
|
-
|
|
351
|
-
SUGGESTION:
|
|
352
|
-
```{language}
|
|
353
|
-
{concrete code fix or refactoring}
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
------------------------------------------------------------------------
|
|
357
|
-
|
|
358
|
-
{Repeat for each finding...}
|
|
359
|
-
|
|
360
|
-
================================================================================
|
|
361
|
-
SUMMARY
|
|
362
|
-
================================================================================
|
|
363
|
-
|
|
364
|
-
| Severity | Count | Confidence (avg) |
|
|
365
|
-
|----------|-------|-------------------|
|
|
366
|
-
| CRITICAL | {n} | {avg} |
|
|
367
|
-
| HIGH | {n} | {avg} |
|
|
368
|
-
| MEDIUM | {n} | {avg} |
|
|
369
|
-
| LOW | {n} | {avg} |
|
|
370
|
-
|
|
371
|
-
| Category | Findings |
|
|
372
|
-
|-----------------|----------|
|
|
373
|
-
| Bugs | {n} |
|
|
374
|
-
| Security | {n} |
|
|
375
|
-
| Performance | {n} |
|
|
376
|
-
| Quality | {n} |
|
|
377
|
-
| Spec Compliance | {n} |
|
|
378
|
-
|
|
379
|
-
Findings above threshold: {n}/{total raw findings}
|
|
380
|
-
Filtered out (below {threshold}): {n}
|
|
381
|
-
|
|
382
|
-
{If increment context:}
|
|
383
|
-
================================================================================
|
|
384
|
-
AC COMPLIANCE MATRIX
|
|
385
|
-
================================================================================
|
|
386
|
-
|
|
387
|
-
| AC ID | Status | Finding | Notes |
|
|
388
|
-
|-------------|-----------|---------|---------------------------|
|
|
389
|
-
| AC-US1-01 | PASS | - | Fully implemented |
|
|
390
|
-
| AC-US1-02 | CONCERN | #3 | Partial implementation |
|
|
391
|
-
| AC-US2-01 | MISSING | #7 | No implementing code found|
|
|
392
|
-
|
|
393
|
-
================================================================================
|
|
394
|
-
VERDICT
|
|
395
|
-
================================================================================
|
|
396
|
-
|
|
397
|
-
{One of:}
|
|
398
|
-
|
|
399
|
-
APPROVED - No critical or high-severity findings. Safe to merge.
|
|
400
|
-
Remaining {n} medium/low findings can be addressed in follow-up.
|
|
401
|
-
|
|
402
|
-
CHANGES REQUESTED - {n} critical/high findings require attention.
|
|
403
|
-
Must fix:
|
|
404
|
-
- Finding #{n}: {one-line summary}
|
|
405
|
-
- Finding #{n}: {one-line summary}
|
|
406
|
-
After fixing, re-run: /sw:code-review {same args}
|
|
407
|
-
|
|
408
|
-
NEEDS DISCUSSION - Findings involve architectural decisions that need team input.
|
|
409
|
-
Discussion points:
|
|
410
|
-
- Finding #{n}: {one-line summary}
|
|
411
|
-
|
|
412
|
-
================================================================================
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
---
|
|
416
|
-
|
|
417
|
-
## Mode-Specific Behavior
|
|
418
|
-
|
|
419
|
-
### PR Review Mode (`pr`)
|
|
420
|
-
|
|
421
|
-
```bash
|
|
422
|
-
/sw:code-review pr 42
|
|
423
|
-
/sw:code-review pr feature/auth
|
|
424
|
-
```
|
|
425
|
-
|
|
426
|
-
1. Get the diff:
|
|
427
|
-
```bash
|
|
428
|
-
# By PR number
|
|
429
|
-
gh pr diff 42
|
|
430
|
-
gh pr view 42 --json baseRefName,headRefName,title,body
|
|
431
|
-
|
|
432
|
-
# By branch name
|
|
433
|
-
git diff $(git merge-base HEAD main)..HEAD
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
2. Focus review on changed lines (new and modified), but read surrounding context (50 lines above/below) for understanding.
|
|
437
|
-
|
|
438
|
-
3. Check PR description for linked issues or increment references to load spec context.
|
|
439
|
-
|
|
440
|
-
4. If the PR links to a SpecWeave increment (look for `#increment-XXXX` or `[XXXX]` in PR body), activate the Spec Compliance agent.
|
|
441
|
-
|
|
442
|
-
### File Review Mode (`files`)
|
|
443
|
-
|
|
444
|
-
```bash
|
|
445
|
-
/sw:code-review files src/auth/login.ts,src/auth/session.ts
|
|
446
|
-
/sw:code-review files "src/**/*.controller.ts"
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
1. Read the specified files in full.
|
|
450
|
-
2. Also read their test files if they exist (look for `.test.ts`, `.spec.ts` patterns).
|
|
451
|
-
3. Review the complete file, not just recent changes.
|
|
452
|
-
4. If files are part of an active increment (check `.specweave/increments/*/tasks.md` for references), load spec context.
|
|
453
|
-
|
|
454
|
-
### Increment Review Mode (`increment`)
|
|
455
|
-
|
|
456
|
-
```bash
|
|
457
|
-
/sw:code-review increment 0042
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
1. Load full increment context:
|
|
461
|
-
```bash
|
|
462
|
-
cat .specweave/increments/0042-*/spec.md
|
|
463
|
-
cat .specweave/increments/0042-*/plan.md
|
|
464
|
-
cat .specweave/increments/0042-*/tasks.md
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
2. Identify implemented files from tasks.md (look for file paths in implementation sections).
|
|
468
|
-
|
|
469
|
-
3. Also check git for files changed since increment creation:
|
|
470
|
-
```bash
|
|
471
|
-
# Find increment creation date from metadata
|
|
472
|
-
jq -r '.createdAt' .specweave/increments/0042-*/metadata.json
|
|
473
|
-
# Get files changed since then
|
|
474
|
-
git log --since="<date>" --name-only --pretty=format: | sort -u
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
4. ALWAYS activate the Spec Compliance agent in this mode.
|
|
478
|
-
|
|
479
|
-
5. Include the AC Compliance Matrix in the report.
|
|
480
|
-
|
|
481
|
-
---
|
|
482
|
-
|
|
483
|
-
## Configuration
|
|
484
|
-
|
|
485
|
-
The skill reads optional configuration from `.specweave/config.json`:
|
|
486
|
-
|
|
487
|
-
```json
|
|
488
|
-
{
|
|
489
|
-
"codeReview": {
|
|
490
|
-
"defaultThreshold": 70,
|
|
491
|
-
"defaultFocus": "all",
|
|
492
|
-
"maxFilesPerReview": 50,
|
|
493
|
-
"maxLinesPerReview": 3000,
|
|
494
|
-
"agents": {
|
|
495
|
-
"bugs": true,
|
|
496
|
-
"security": true,
|
|
497
|
-
"performance": true,
|
|
498
|
-
"quality": true,
|
|
499
|
-
"specCompliance": true
|
|
500
|
-
},
|
|
501
|
-
"severityPolicy": {
|
|
502
|
-
"blockMergeOn": ["CRITICAL", "HIGH"],
|
|
503
|
-
"requireDiscussionOn": []
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
```
|
|
508
|
-
|
|
509
|
-
All fields are optional. Sensible defaults apply when absent.
|
|
510
|
-
|
|
511
|
-
---
|
|
512
|
-
|
|
513
|
-
## Integration with SpecWeave Workflow
|
|
514
|
-
|
|
515
|
-
### With `/sw:grill`
|
|
516
|
-
|
|
517
|
-
`/sw:code-review` and `/sw:grill` serve complementary purposes:
|
|
518
|
-
- Run `/sw:code-review` during development for early feedback
|
|
519
|
-
- `/sw:grill` runs automatically before `/sw:done` as the final gate
|
|
520
|
-
|
|
521
|
-
### With `/sw:done`
|
|
522
|
-
|
|
523
|
-
If `/sw:code-review` was run for the increment and returned CHANGES REQUESTED, `/sw:done` will reference those findings. Fix them before closing.
|
|
524
|
-
|
|
525
|
-
### With `/sw:validate`
|
|
526
|
-
|
|
527
|
-
`/sw:validate` checks spec/plan/tasks document quality. `/sw:code-review` checks the actual code. Use both for full coverage.
|
|
528
|
-
|
|
529
|
-
### With GitHub Sync
|
|
530
|
-
|
|
531
|
-
When using `/sw-github:sync`, code review findings can inform PR comments. Run `/sw:code-review pr <number>` before approving PRs synced from SpecWeave.
|
|
532
|
-
|
|
533
|
-
---
|
|
534
|
-
|
|
535
|
-
## Advanced: Custom Review Agents
|
|
536
|
-
|
|
537
|
-
For domain-specific reviews, you can extend the agent set by describing additional review criteria in the command:
|
|
538
|
-
|
|
539
|
-
```bash
|
|
540
|
-
/sw:code-review files src/payments/*.ts --focus "PCI DSS compliance, payment flow correctness"
|
|
541
|
-
```
|
|
542
|
-
|
|
543
|
-
When a custom focus is provided as free text (not one of the predefined areas), spawn a custom agent with those specific instructions in addition to the standard agents.
|
|
544
|
-
|
|
545
|
-
---
|
|
546
|
-
|
|
547
|
-
## Error Handling
|
|
548
|
-
|
|
549
|
-
### No Files to Review
|
|
550
|
-
|
|
551
|
-
```
|
|
552
|
-
No files found to review.
|
|
553
|
-
|
|
554
|
-
Possible causes:
|
|
555
|
-
- PR has no changed files
|
|
556
|
-
- Glob pattern matched nothing
|
|
557
|
-
- Increment has no implemented tasks
|
|
558
|
-
|
|
559
|
-
Try:
|
|
560
|
-
/sw:code-review files src/specific-file.ts
|
|
561
|
-
/sw:code-review pr main
|
|
562
|
-
```
|
|
563
|
-
|
|
564
|
-
### Too Many Files
|
|
565
|
-
|
|
566
|
-
```
|
|
567
|
-
Scope limit reached: {N} files / {N} lines exceeds review capacity.
|
|
568
|
-
|
|
569
|
-
Reviewing top {50} files by priority:
|
|
570
|
-
1. Security-sensitive files ({n} files)
|
|
571
|
-
2. Business logic files ({n} files)
|
|
572
|
-
3. New files ({n} files)
|
|
573
|
-
|
|
574
|
-
Skipped {n} files. Run again with specific paths for full coverage:
|
|
575
|
-
/sw:code-review files src/skipped-module/*.ts
|
|
576
|
-
```
|
|
577
|
-
|
|
578
|
-
### Agent Timeout
|
|
579
|
-
|
|
580
|
-
If a subagent takes too long (should not happen in practice with Task tool):
|
|
581
|
-
- Report findings from completed agents
|
|
582
|
-
- Note which agent did not complete
|
|
583
|
-
- Suggest re-running with `--focus` on the incomplete area
|
|
584
|
-
|
|
585
|
-
---
|
|
586
|
-
|
|
587
|
-
## Tips for Best Results
|
|
588
|
-
|
|
589
|
-
1. **Smaller scope = better results**: Review 5-10 files at a time, not 100
|
|
590
|
-
2. **Use increment mode** when you have spec context - the spec compliance agent adds significant value
|
|
591
|
-
3. **Lower the threshold** (`--threshold 50`) when you want a thorough audit and can tolerate more noise
|
|
592
|
-
4. **Raise the threshold** (`--threshold 85`) when you want only high-confidence findings and less noise
|
|
593
|
-
5. **Run early and often**: Better to catch issues during development than at PR time
|
|
594
|
-
6. **Combine with `/sw:grill`**: Code review during dev, grill at completion
|
|
595
|
-
7. **Focus on one area** when you have a specific concern: `--focus security` after adding auth code
|
|
596
|
-
|
|
597
|
-
---
|
|
598
|
-
|