planflow-ai 1.3.0 → 1.3.4
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/commands/brainstorm.md +2 -2
- package/.claude/commands/discovery-plan.md +11 -0
- package/.claude/commands/execute-plan.md +26 -2
- package/.claude/commands/flow.md +5 -0
- package/.claude/commands/heartbeat.md +1 -1
- package/.claude/commands/learn.md +4 -6
- package/.claude/commands/{brain.md → note.md} +12 -12
- package/.claude/commands/review-code.md +61 -1
- package/.claude/commands/review-pr.md +61 -1
- package/.claude/commands/setup.md +11 -1
- package/.claude/resources/core/_index.md +102 -2
- package/.claude/resources/core/compaction-guide.md +111 -0
- package/.claude/resources/core/discovery-sub-agents.md +266 -0
- package/.claude/resources/core/phase-isolation.md +222 -0
- package/.claude/resources/core/resource-capture.md +1 -1
- package/.claude/resources/core/review-adaptive-depth.md +217 -0
- package/.claude/resources/core/review-multi-agent.md +289 -0
- package/.claude/resources/core/review-severity-ranking.md +149 -0
- package/.claude/resources/core/review-verification.md +158 -0
- package/.claude/resources/core/session-scratchpad.md +105 -0
- package/.claude/resources/patterns/review-code-templates.md +315 -2
- package/.claude/resources/skills/_index.md +108 -42
- package/.claude/resources/skills/brain-skill.md +3 -3
- package/.claude/resources/skills/discovery-skill.md +50 -6
- package/.claude/resources/skills/execute-plan-skill.md +14 -6
- package/.claude/resources/skills/review-code-skill.md +73 -0
- package/.claude/resources/skills/review-pr-skill.md +58 -0
- package/README.md +38 -3
- package/dist/cli/commands/heartbeat.js.map +1 -1
- package/dist/cli/daemon/heartbeat-daemon.js +31 -1
- package/dist/cli/daemon/heartbeat-daemon.js.map +1 -1
- package/dist/cli/daemon/heartbeat-parser.d.ts.map +1 -1
- package/dist/cli/daemon/heartbeat-parser.js +6 -0
- package/dist/cli/daemon/heartbeat-parser.js.map +1 -1
- package/dist/cli/handlers/claude.js +20 -12
- package/dist/cli/handlers/claude.js.map +1 -1
- package/dist/cli/types.d.ts +1 -0
- package/dist/cli/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/rules/skills/brain-skill.mdc +4 -4
- package/skills/plan-flow/SKILL.md +1 -1
- package/skills/plan-flow/brain/SKILL.md +1 -1
- package/templates/shared/AGENTS.md.template +1 -1
- package/templates/shared/CLAUDE.md.template +11 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
|
|
2
|
+
# Review Adaptive Depth
|
|
3
|
+
|
|
4
|
+
## Purpose
|
|
5
|
+
|
|
6
|
+
Scale review depth based on changeset size. Small changes get a fast lightweight pass, large changes get a deeper multi-category review with severity-grouped output and executive summary. Medium changes use the standard review (no behavior change).
|
|
7
|
+
|
|
8
|
+
**Scope**: `/review-code` (Step 1b) and `/review-pr` (Step 1b). Applied after identifying changed files, before loading patterns.
|
|
9
|
+
|
|
10
|
+
**Goal**: Save tokens on trivial PRs and improve quality on complex ones. A 5-line typo fix shouldn't get the same depth as a 2000-line refactor.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Size Detection
|
|
15
|
+
|
|
16
|
+
### Line Counting Rules
|
|
17
|
+
|
|
18
|
+
Count total lines changed (additions + deletions) from the diff.
|
|
19
|
+
|
|
20
|
+
**Exclude** from the count:
|
|
21
|
+
- Lock files: `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `Gemfile.lock`, `poetry.lock`, `Cargo.lock`, `go.sum`
|
|
22
|
+
- Generated files: any path containing `.generated.`, `dist/`, `build/`, `.min.js`, `.min.css`
|
|
23
|
+
- Pure whitespace/formatting changes (lines where only indentation changed)
|
|
24
|
+
|
|
25
|
+
**For review-code**: Use `git diff --stat` to get line counts, then subtract excluded files.
|
|
26
|
+
|
|
27
|
+
**For review-pr**: Use PR diff stats from `gh pr diff --stat` or Azure DevOps diff API, then subtract excluded files.
|
|
28
|
+
|
|
29
|
+
### Display Format
|
|
30
|
+
|
|
31
|
+
Always show the detected mode before starting the review:
|
|
32
|
+
|
|
33
|
+
```markdown
|
|
34
|
+
**Review mode**: {Lightweight|Standard|Deep} ({N} lines changed across {M} files)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Tier Definitions
|
|
40
|
+
|
|
41
|
+
| Tier | Lines Changed | Review Mode |
|
|
42
|
+
|------|--------------|-------------|
|
|
43
|
+
| **Small** | < 50 | Lightweight |
|
|
44
|
+
| **Medium** | 50–500 | Standard (current behavior, no changes) |
|
|
45
|
+
| **Large** | 500+ | Deep |
|
|
46
|
+
|
|
47
|
+
Thresholds are hardcoded. No configuration needed.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Lightweight Review Mode (Small, < 50 lines)
|
|
52
|
+
|
|
53
|
+
For changesets under 50 lines, perform a focused quick-scan review.
|
|
54
|
+
|
|
55
|
+
### What to Check (ONLY these)
|
|
56
|
+
|
|
57
|
+
1. **Security issues** — hardcoded secrets, injection vulnerabilities, auth bypass, exposed credentials
|
|
58
|
+
2. **Obvious logic bugs** — wrong condition, off-by-one, null/undefined access, infinite loops
|
|
59
|
+
3. **Breaking changes** — API signature changes, removed exports, changed return types
|
|
60
|
+
|
|
61
|
+
### What to Skip
|
|
62
|
+
|
|
63
|
+
- Naming suggestions
|
|
64
|
+
- Pattern compliance
|
|
65
|
+
- Performance optimization
|
|
66
|
+
- Test coverage analysis
|
|
67
|
+
- Similar implementation search
|
|
68
|
+
- Pattern conflict detection
|
|
69
|
+
|
|
70
|
+
### Verification Pass
|
|
71
|
+
|
|
72
|
+
**Skip entirely.** Lightweight reviews produce few findings — verification adds overhead with minimal value on small changesets.
|
|
73
|
+
|
|
74
|
+
### Output
|
|
75
|
+
|
|
76
|
+
If no issues found, output a short **LGTM review**:
|
|
77
|
+
|
|
78
|
+
```markdown
|
|
79
|
+
## Review Summary
|
|
80
|
+
|
|
81
|
+
| Metric | Value |
|
|
82
|
+
|--------|-------|
|
|
83
|
+
| **Review Mode** | Lightweight (< 50 lines) |
|
|
84
|
+
| **Total Findings** | 0 |
|
|
85
|
+
| **Status** | LGTM |
|
|
86
|
+
|
|
87
|
+
## Positive Highlights
|
|
88
|
+
|
|
89
|
+
- {Highlight 1}
|
|
90
|
+
- {Highlight 2}
|
|
91
|
+
- {Highlight 3}
|
|
92
|
+
|
|
93
|
+
## Commit Readiness
|
|
94
|
+
|
|
95
|
+
| Status | Ready to Commit |
|
|
96
|
+
|--------|-----------------|
|
|
97
|
+
| Reason | No issues found in lightweight review |
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
If issues ARE found, use the standard finding format but keep the compact template (no Reference Implementations, no Pattern Conflicts sections).
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Deep Review Mode (Large, 500+ lines)
|
|
105
|
+
|
|
106
|
+
For changesets over 500 lines, perform a structured multi-pass review.
|
|
107
|
+
|
|
108
|
+
### Step 1: Categorize Changed Files
|
|
109
|
+
|
|
110
|
+
Group all changed files by type:
|
|
111
|
+
|
|
112
|
+
| Category | Heuristics |
|
|
113
|
+
|----------|-----------|
|
|
114
|
+
| **Core Logic** | `src/`, `lib/`, `app/` (excluding UI paths), service files, utility files, business logic |
|
|
115
|
+
| **Infrastructure** | Config files, CI/CD (`.github/`, `.gitlab-ci`), build config, Docker, env files |
|
|
116
|
+
| **UI/Presentation** | Components, pages, layouts, styles, templates — detected by path (`components/`, `pages/`, `views/`) or extension (`.tsx`, `.jsx`, `.vue`, `.svelte`, `.css`, `.scss`) |
|
|
117
|
+
| **Tests** | Any file in `__tests__/`, `test/`, `tests/`, `spec/`, or files ending in `.test.*`, `.spec.*` |
|
|
118
|
+
|
|
119
|
+
Files that don't match any heuristic → default to **Core Logic**.
|
|
120
|
+
|
|
121
|
+
### Step 2: Prioritize Review Order
|
|
122
|
+
|
|
123
|
+
Review in this order: **Core Logic → Infrastructure → UI → Tests**
|
|
124
|
+
|
|
125
|
+
Core logic gets the deepest review. Tests get a quick coverage-adequacy scan.
|
|
126
|
+
|
|
127
|
+
### Step 3: Focused Passes per Category
|
|
128
|
+
|
|
129
|
+
| Category | Focus Areas |
|
|
130
|
+
|----------|-------------|
|
|
131
|
+
| **Core Logic** | Bugs, edge cases, security, error handling, null safety |
|
|
132
|
+
| **Infrastructure** | Security (secrets, permissions), breaking changes, compatibility |
|
|
133
|
+
| **UI/Presentation** | Accessibility, performance (re-renders, large bundles), state management |
|
|
134
|
+
| **Tests** | Coverage adequacy, test quality (quick scan only — not a full analysis) |
|
|
135
|
+
|
|
136
|
+
### Step 4: Always Run Verification Pass
|
|
137
|
+
|
|
138
|
+
All findings from deep review must go through the standard verification pass (see `review-verification.md`).
|
|
139
|
+
|
|
140
|
+
### Step 5: Severity-Grouped Output
|
|
141
|
+
|
|
142
|
+
Group findings by severity instead of by file:
|
|
143
|
+
|
|
144
|
+
```markdown
|
|
145
|
+
## Critical Findings
|
|
146
|
+
### Finding 1: ...
|
|
147
|
+
### Finding 2: ...
|
|
148
|
+
|
|
149
|
+
## Major Findings
|
|
150
|
+
### Finding 3: ...
|
|
151
|
+
|
|
152
|
+
## Minor Findings
|
|
153
|
+
### Finding 4: ...
|
|
154
|
+
|
|
155
|
+
## Suggestions
|
|
156
|
+
### Finding 5: ...
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Step 6: Executive Summary
|
|
160
|
+
|
|
161
|
+
Add an executive summary at the top of the review document, before the findings:
|
|
162
|
+
|
|
163
|
+
```markdown
|
|
164
|
+
## Executive Summary
|
|
165
|
+
|
|
166
|
+
### Files Changed by Category
|
|
167
|
+
|
|
168
|
+
| Category | Files | Lines Changed |
|
|
169
|
+
|----------|-------|--------------|
|
|
170
|
+
| Core Logic | {N} | +{add}/-{del} |
|
|
171
|
+
| Infrastructure | {N} | +{add}/-{del} |
|
|
172
|
+
| UI/Presentation | {N} | +{add}/-{del} |
|
|
173
|
+
| Tests | {N} | +{add}/-{del} |
|
|
174
|
+
|
|
175
|
+
### Risk Assessment
|
|
176
|
+
|
|
177
|
+
**Overall Risk**: {Low | Medium | High}
|
|
178
|
+
|
|
179
|
+
{1-2 sentence justification based on scope, categories affected, and finding severity distribution}
|
|
180
|
+
|
|
181
|
+
### Top 3 Findings
|
|
182
|
+
|
|
183
|
+
1. **[{Severity}]** {Finding title} — {one-line description} (`{file}:{line}`)
|
|
184
|
+
2. **[{Severity}]** {Finding title} — {one-line description} (`{file}:{line}`)
|
|
185
|
+
3. **[{Severity}]** {Finding title} — {one-line description} (`{file}:{line}`)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Insertion Points
|
|
191
|
+
|
|
192
|
+
### For review-code-skill.md
|
|
193
|
+
|
|
194
|
+
Insert as **Step 1b: Determine Review Depth** — after Step 1 (Identify Changed Files), before Step 2 (Load Review Patterns).
|
|
195
|
+
|
|
196
|
+
**Lightweight shortcut**: If Small tier, skip Steps 2-5 (pattern loading, similar implementations, full analysis, pattern conflicts). Perform abbreviated analysis checking only security/logic/breaking changes. Skip verification pass. Generate lightweight template.
|
|
197
|
+
|
|
198
|
+
**Deep expansion**: If Large tier, in Step 3 categorize files by type. In Step 4 run focused passes per category. In Step 5b apply verification to all findings. In Step 6 use deep template with severity grouping + executive summary.
|
|
199
|
+
|
|
200
|
+
### For review-pr-skill.md
|
|
201
|
+
|
|
202
|
+
Insert as **Step 1b: Determine Review Depth** — after Step 1 (Fetch PR Information), before Step 2 (Load Review Patterns).
|
|
203
|
+
|
|
204
|
+
Same lightweight shortcut and deep expansion logic as review-code.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## Related Files
|
|
209
|
+
|
|
210
|
+
| File | Purpose |
|
|
211
|
+
|------|---------|
|
|
212
|
+
| `.claude/resources/skills/review-code-skill.md` | Add Step 1b (Determine Review Depth) |
|
|
213
|
+
| `.claude/resources/skills/review-pr-skill.md` | Add Step 1b (Determine Review Depth) |
|
|
214
|
+
| `.claude/resources/patterns/review-code-templates.md` | Add lightweight and deep templates |
|
|
215
|
+
| `.claude/resources/core/review-verification.md` | Verification pass (skipped for lightweight, required for deep) |
|
|
216
|
+
| `.claude/commands/review-code.md` | Add Adaptive Depth section |
|
|
217
|
+
| `.claude/commands/review-pr.md` | Add Adaptive Depth section |
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
|
|
2
|
+
# Review Multi-Agent Parallel Review
|
|
3
|
+
|
|
4
|
+
## Purpose
|
|
5
|
+
|
|
6
|
+
For large changesets (500+ lines, Deep mode), split the review into specialized subagents running in parallel. Each subagent focuses on a single concern, producing deeper findings than a single-pass review. A coordinator merges, deduplicates, verifies, and ranks the results.
|
|
7
|
+
|
|
8
|
+
**Scope**: `/review-code` and `/review-pr` — activated only when adaptive depth selects **Deep** mode (500+ lines).
|
|
9
|
+
|
|
10
|
+
**Goal**: Higher quality reviews for large PRs by eliminating context-switching between security, logic, performance, and pattern compliance concerns.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## When to Activate
|
|
15
|
+
|
|
16
|
+
| Review Mode | Multi-Agent? |
|
|
17
|
+
|-------------|-------------|
|
|
18
|
+
| Lightweight (< 50 lines) | No |
|
|
19
|
+
| Standard (50–500 lines) | No |
|
|
20
|
+
| Deep (500+ lines) | **Yes** |
|
|
21
|
+
|
|
22
|
+
Multi-agent is part of the Deep mode pipeline. It replaces the single-pass analysis steps with parallel subagent execution.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Architecture
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
Coordinator (main agent)
|
|
30
|
+
│
|
|
31
|
+
├─► Subagent: Security Review (parallel)
|
|
32
|
+
├─► Subagent: Logic & Bugs Review (parallel)
|
|
33
|
+
├─► Subagent: Performance Review (parallel)
|
|
34
|
+
└─► Subagent: Pattern Compliance (parallel)
|
|
35
|
+
│
|
|
36
|
+
▼
|
|
37
|
+
Coordinator: Collect → Deduplicate → Verify → Re-Rank → Output
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Subagent Definitions
|
|
43
|
+
|
|
44
|
+
### 1. Security Review Agent
|
|
45
|
+
|
|
46
|
+
**Focus**: Vulnerabilities, hardcoded secrets, auth bypass, injection (SQL/XSS/command), OWASP top 10, exposed credentials, insecure deserialization, missing CSRF protection.
|
|
47
|
+
|
|
48
|
+
**Model**: sonnet
|
|
49
|
+
|
|
50
|
+
**Prompt template**:
|
|
51
|
+
```
|
|
52
|
+
You are a security-focused code reviewer. Analyze the provided diff ONLY for security vulnerabilities.
|
|
53
|
+
|
|
54
|
+
Check for:
|
|
55
|
+
- Hardcoded secrets, API keys, tokens
|
|
56
|
+
- SQL/NoSQL injection
|
|
57
|
+
- XSS vulnerabilities
|
|
58
|
+
- Command injection
|
|
59
|
+
- Authentication/authorization bypass
|
|
60
|
+
- Insecure deserialization
|
|
61
|
+
- Missing CSRF protection
|
|
62
|
+
- Exposed sensitive data in logs or responses
|
|
63
|
+
- Insecure cryptographic practices
|
|
64
|
+
|
|
65
|
+
IGNORE: code style, performance, naming conventions, test coverage.
|
|
66
|
+
|
|
67
|
+
Return findings as a JSON array. Each finding must have:
|
|
68
|
+
- file: string (file path)
|
|
69
|
+
- line: number (line number)
|
|
70
|
+
- severity: "Critical" | "Major" | "Minor"
|
|
71
|
+
- title: string (short finding name)
|
|
72
|
+
- description: string (detailed explanation)
|
|
73
|
+
- suggested_fix: string (code suggestion)
|
|
74
|
+
- confidence: number (0.0-1.0)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 2. Logic & Bugs Review Agent
|
|
78
|
+
|
|
79
|
+
**Focus**: Edge cases, null/undefined handling, off-by-one errors, race conditions, incorrect boolean logic, infinite loops, unreachable code, wrong return types, missing error handling.
|
|
80
|
+
|
|
81
|
+
**Model**: sonnet
|
|
82
|
+
|
|
83
|
+
**Prompt template**:
|
|
84
|
+
```
|
|
85
|
+
You are a logic-focused code reviewer. Analyze the provided diff ONLY for logic bugs and edge cases.
|
|
86
|
+
|
|
87
|
+
Check for:
|
|
88
|
+
- Null/undefined access without guards
|
|
89
|
+
- Off-by-one errors in loops and slicing
|
|
90
|
+
- Race conditions in async code
|
|
91
|
+
- Incorrect boolean logic (wrong operator, inverted condition)
|
|
92
|
+
- Infinite loops or recursion without base case
|
|
93
|
+
- Unreachable code paths
|
|
94
|
+
- Wrong return types or missing returns
|
|
95
|
+
- Unhandled promise rejections
|
|
96
|
+
- Missing error handling on fallible operations
|
|
97
|
+
|
|
98
|
+
IGNORE: security vulnerabilities, performance, code style, naming.
|
|
99
|
+
|
|
100
|
+
Return findings as a JSON array. Each finding must have:
|
|
101
|
+
- file: string (file path)
|
|
102
|
+
- line: number (line number)
|
|
103
|
+
- severity: "Critical" | "Major" | "Minor"
|
|
104
|
+
- title: string (short finding name)
|
|
105
|
+
- description: string (detailed explanation)
|
|
106
|
+
- suggested_fix: string (code suggestion)
|
|
107
|
+
- confidence: number (0.0-1.0)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 3. Performance Review Agent
|
|
111
|
+
|
|
112
|
+
**Focus**: N+1 queries, memory leaks, unnecessary re-renders, blocking I/O on main thread, excessive allocations, missing pagination, inefficient algorithms, large bundle impacts.
|
|
113
|
+
|
|
114
|
+
**Model**: sonnet
|
|
115
|
+
|
|
116
|
+
**Prompt template**:
|
|
117
|
+
```
|
|
118
|
+
You are a performance-focused code reviewer. Analyze the provided diff ONLY for performance issues.
|
|
119
|
+
|
|
120
|
+
Check for:
|
|
121
|
+
- N+1 database queries
|
|
122
|
+
- Memory leaks (event listeners not removed, unclosed resources)
|
|
123
|
+
- Unnecessary re-renders (React) or recomputations
|
|
124
|
+
- Blocking I/O on main thread
|
|
125
|
+
- Excessive object/array allocations in hot paths
|
|
126
|
+
- Missing pagination on unbounded queries
|
|
127
|
+
- O(n²) or worse algorithms where O(n) is possible
|
|
128
|
+
- Large synchronous operations that should be async
|
|
129
|
+
- Bundle size impacts (large imports that could be lazy-loaded)
|
|
130
|
+
|
|
131
|
+
IGNORE: security vulnerabilities, logic bugs, code style, naming.
|
|
132
|
+
|
|
133
|
+
Return findings as a JSON array. Each finding must have:
|
|
134
|
+
- file: string (file path)
|
|
135
|
+
- line: number (line number)
|
|
136
|
+
- severity: "Major" | "Minor" | "Suggestion"
|
|
137
|
+
- title: string (short finding name)
|
|
138
|
+
- description: string (detailed explanation)
|
|
139
|
+
- suggested_fix: string (code suggestion)
|
|
140
|
+
- confidence: number (0.0-1.0)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 4. Pattern Compliance Review Agent
|
|
144
|
+
|
|
145
|
+
**Focus**: Violations of `forbidden-patterns.md`, deviations from `allowed-patterns.md`, naming inconsistencies, structural pattern conflicts with existing codebase.
|
|
146
|
+
|
|
147
|
+
**Model**: haiku
|
|
148
|
+
|
|
149
|
+
**Prompt template**:
|
|
150
|
+
```
|
|
151
|
+
You are a pattern compliance reviewer. Analyze the provided diff against the project's coding standards.
|
|
152
|
+
|
|
153
|
+
Forbidden patterns to check (violations of these are findings):
|
|
154
|
+
{contents of forbidden-patterns.md Project Anti-Patterns section}
|
|
155
|
+
|
|
156
|
+
Allowed patterns to verify (deviations from these are findings):
|
|
157
|
+
{contents of allowed-patterns.md Project Patterns section}
|
|
158
|
+
|
|
159
|
+
Also check for:
|
|
160
|
+
- Naming inconsistencies with existing codebase conventions
|
|
161
|
+
- Import organization deviations
|
|
162
|
+
- Error handling pattern deviations
|
|
163
|
+
- Export pattern inconsistencies
|
|
164
|
+
|
|
165
|
+
IGNORE: security vulnerabilities, logic bugs, performance issues.
|
|
166
|
+
|
|
167
|
+
Return findings as a JSON array. Each finding must have:
|
|
168
|
+
- file: string (file path)
|
|
169
|
+
- line: number (line number)
|
|
170
|
+
- severity: "Minor" | "Suggestion"
|
|
171
|
+
- title: string (short finding name)
|
|
172
|
+
- description: string (detailed explanation with pattern reference)
|
|
173
|
+
- suggested_fix: string (code suggestion)
|
|
174
|
+
- confidence: number (0.0-1.0)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Subagent Input
|
|
180
|
+
|
|
181
|
+
Each subagent receives:
|
|
182
|
+
|
|
183
|
+
1. **The diff** — For review-code: output of `git diff`. For review-pr: output of `gh pr diff` or Azure DevOps diff.
|
|
184
|
+
2. **File categorization** — The file-to-category mapping from adaptive depth Step 1 (Core Logic, Infrastructure, UI, Tests)
|
|
185
|
+
3. **Category-specific context** — Only the pattern files relevant to the subagent's focus
|
|
186
|
+
4. **Instructions** — The subagent-specific prompt template above
|
|
187
|
+
|
|
188
|
+
For very large diffs (2000+ lines), the coordinator may split the diff by file category and send each subagent only its most relevant files:
|
|
189
|
+
- Security agent → all files (security issues can be anywhere)
|
|
190
|
+
- Logic agent → Core Logic + Infrastructure files
|
|
191
|
+
- Performance agent → Core Logic + UI files
|
|
192
|
+
- Pattern agent → all files
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Coordinator Behavior
|
|
197
|
+
|
|
198
|
+
The coordinator (main agent) orchestrates the entire flow:
|
|
199
|
+
|
|
200
|
+
### Step 1: Spawn Subagents
|
|
201
|
+
|
|
202
|
+
Launch all 4 subagents in parallel using the Agent tool. Each subagent uses `subagent_type: "general-purpose"` with the appropriate model override.
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
Launch in parallel:
|
|
206
|
+
- Agent(model: "sonnet", prompt: security_prompt)
|
|
207
|
+
- Agent(model: "sonnet", prompt: logic_prompt)
|
|
208
|
+
- Agent(model: "sonnet", prompt: performance_prompt)
|
|
209
|
+
- Agent(model: "haiku", prompt: patterns_prompt)
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Step 2: Collect Results
|
|
213
|
+
|
|
214
|
+
Wait for all subagents to complete. Parse the JSON findings arrays from each.
|
|
215
|
+
|
|
216
|
+
### Step 3: Deduplicate
|
|
217
|
+
|
|
218
|
+
Scan for overlapping findings (same file + line range within ±5 lines + similar description):
|
|
219
|
+
|
|
220
|
+
| Overlap Type | Resolution |
|
|
221
|
+
|-------------|------------|
|
|
222
|
+
| Exact match (same file, same line, same issue) | Merge into one finding, note both categories |
|
|
223
|
+
| Near match (same file, ±5 lines, similar issue) | Merge if clearly the same root cause |
|
|
224
|
+
| Different aspects of same code | Keep as separate findings |
|
|
225
|
+
|
|
226
|
+
When merging:
|
|
227
|
+
- Use the **higher severity** from the overlapping findings
|
|
228
|
+
- Use the **higher confidence** score
|
|
229
|
+
- Combine descriptions from both agents
|
|
230
|
+
- Note all contributing categories in the finding
|
|
231
|
+
|
|
232
|
+
### Step 4: Verify
|
|
233
|
+
|
|
234
|
+
Run the standard verification pass on all deduplicated findings. See `.claude/resources/core/review-verification.md`.
|
|
235
|
+
|
|
236
|
+
### Step 5: Re-Rank and Group
|
|
237
|
+
|
|
238
|
+
Run the standard severity re-ranking. See `.claude/resources/core/review-severity-ranking.md`.
|
|
239
|
+
|
|
240
|
+
### Step 6: Generate Output
|
|
241
|
+
|
|
242
|
+
Use the deep review template with severity-grouped findings and executive summary. Add a Multi-Agent Summary section after Review Information:
|
|
243
|
+
|
|
244
|
+
```markdown
|
|
245
|
+
## Review Agents
|
|
246
|
+
|
|
247
|
+
| Agent | Model | Findings | After Dedup |
|
|
248
|
+
|-------|-------|----------|-------------|
|
|
249
|
+
| Security | sonnet | {N} | {N} |
|
|
250
|
+
| Logic & Bugs | sonnet | {N} | {N} |
|
|
251
|
+
| Performance | sonnet | {N} | {N} |
|
|
252
|
+
| Pattern Compliance | haiku | {N} | {N} |
|
|
253
|
+
| **Total** | | **{N}** | **{N}** |
|
|
254
|
+
|
|
255
|
+
Duplicates removed: {N}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Insertion Points
|
|
261
|
+
|
|
262
|
+
### For review-code-skill.md
|
|
263
|
+
|
|
264
|
+
In the **Deep mode** path of Step 1b, replace the instruction "Proceed with all steps" with:
|
|
265
|
+
|
|
266
|
+
> **If Deep**: Activate multi-agent parallel review. See `.claude/resources/core/review-multi-agent.md`. Spawn 4 specialized subagents (security, logic, performance, patterns) in parallel. Coordinator collects results, deduplicates, then proceeds to Step 5b (verification), Step 5c (re-ranking), Step 6b (pattern review), and Step 6 (output using deep template).
|
|
267
|
+
|
|
268
|
+
Steps 2–5 (pattern loading, similar implementations, analysis, pattern conflicts) are handled by the subagents instead of the main agent.
|
|
269
|
+
|
|
270
|
+
### For review-pr-skill.md
|
|
271
|
+
|
|
272
|
+
In the **Deep mode** path of Step 1b, replace the instruction "Proceed with all steps" with:
|
|
273
|
+
|
|
274
|
+
> **If Deep**: Activate multi-agent parallel review. See `.claude/resources/core/review-multi-agent.md`. Spawn 4 specialized subagents (security, logic, performance, patterns) in parallel. Coordinator collects results, deduplicates, then proceeds to Step 3b (verification), Step 3c (re-ranking), and Step 4 (output using deep template with severity grouping and executive summary).
|
|
275
|
+
|
|
276
|
+
Steps 2–3 (pattern loading, analysis) are handled by the subagents instead of the main agent.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Related Files
|
|
281
|
+
|
|
282
|
+
| File | Purpose |
|
|
283
|
+
|------|---------|
|
|
284
|
+
| `.claude/resources/core/review-adaptive-depth.md` | Triggers Deep mode (prerequisite) |
|
|
285
|
+
| `.claude/resources/core/review-verification.md` | Verification pass (run by coordinator after dedup) |
|
|
286
|
+
| `.claude/resources/core/review-severity-ranking.md` | Re-ranking (run by coordinator after verification) |
|
|
287
|
+
| `.claude/resources/skills/review-code-skill.md` | Update Deep mode path in Step 1b |
|
|
288
|
+
| `.claude/resources/skills/review-pr-skill.md` | Update Deep mode path in Step 1b |
|
|
289
|
+
| `.claude/resources/patterns/review-code-templates.md` | Deep template gets Review Agents section |
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
|
|
2
|
+
# Review Severity Re-Ranking
|
|
3
|
+
|
|
4
|
+
## Purpose
|
|
5
|
+
|
|
6
|
+
After all findings are collected and verified, re-rank them by actual impact rather than listing in file order. Group related findings across files and present critical issues first. This applies to **all review modes** (lightweight findings are already minimal, but if multiple issues are found, they should still be severity-ordered).
|
|
7
|
+
|
|
8
|
+
**Scope**: `/review-code` (Step 5c) and `/review-pr` (Step 3c). Applied after verification, before generating the output document.
|
|
9
|
+
|
|
10
|
+
**Goal**: Ensure the most impactful findings appear first. Reviewers should never have to scan past 10 minor style issues to find a critical security bug.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Ranking Algorithm
|
|
15
|
+
|
|
16
|
+
After verification classifies findings as Confirmed or Likely, sort using this priority:
|
|
17
|
+
|
|
18
|
+
1. **Severity** (primary): Critical → Major → Minor → Suggestion
|
|
19
|
+
2. **Confidence** (secondary, within same severity): Confirmed → Likely
|
|
20
|
+
3. **Fix complexity** (tertiary, within same confidence): Lower complexity first (quick wins surface earlier)
|
|
21
|
+
|
|
22
|
+
This ranking applies regardless of which file the finding came from.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Grouping Related Findings
|
|
27
|
+
|
|
28
|
+
Before final output, scan the sorted findings for groupable patterns:
|
|
29
|
+
|
|
30
|
+
| Pattern | Group Condition | Example Group Title |
|
|
31
|
+
|---------|----------------|---------------------|
|
|
32
|
+
| Same issue type in multiple files | ≥ 2 findings with matching issue category | "Missing input validation in 3 API endpoints" |
|
|
33
|
+
| Same root cause | ≥ 2 findings traceable to one underlying problem | "Inconsistent error handling (5 occurrences)" |
|
|
34
|
+
| Causal chain | Findings where one enables/causes another | "Auth bypass: missing check → unprotected route → data exposure" |
|
|
35
|
+
|
|
36
|
+
### Grouping Rules
|
|
37
|
+
|
|
38
|
+
- **Only group when genuinely related** — don't force-group unrelated findings just because they share a severity level
|
|
39
|
+
- **Small reviews (1-3 findings)**: No grouping. Keep findings individual.
|
|
40
|
+
- **Use the highest severity in the group** as the group's severity level
|
|
41
|
+
- **Show individual occurrences** within the group with `file:line` references
|
|
42
|
+
- **Provide a single suggested fix** that addresses all occurrences when possible
|
|
43
|
+
|
|
44
|
+
### Grouped Finding Format
|
|
45
|
+
|
|
46
|
+
```markdown
|
|
47
|
+
### Finding N: {Group Title} ({count} occurrences)
|
|
48
|
+
|
|
49
|
+
| Field | Value |
|
|
50
|
+
| -------------- | ------------------------------------------------ |
|
|
51
|
+
| Severity | {Highest severity in group} |
|
|
52
|
+
| Fix Complexity | {Average complexity}/10 - {Level} |
|
|
53
|
+
| Pattern | {Reference to pattern from rules, if applicable} |
|
|
54
|
+
|
|
55
|
+
**Occurrences**:
|
|
56
|
+
|
|
57
|
+
| # | File | Line | Status |
|
|
58
|
+
|---|------|------|--------|
|
|
59
|
+
| 1 | `{file_path}` | {line} | {Confirmed/Likely} |
|
|
60
|
+
| 2 | `{file_path}` | {line} | {Confirmed/Likely} |
|
|
61
|
+
| 3 | `{file_path}` | {line} | {Confirmed/Likely} |
|
|
62
|
+
|
|
63
|
+
**Description**:
|
|
64
|
+
{Explanation of the shared issue pattern}
|
|
65
|
+
|
|
66
|
+
**Suggested Fix**:
|
|
67
|
+
\`\`\`{language}
|
|
68
|
+
// Single fix pattern that addresses all occurrences
|
|
69
|
+
\`\`\`
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Executive Summary Trigger
|
|
75
|
+
|
|
76
|
+
| Review Mode | Trigger |
|
|
77
|
+
|-------------|---------|
|
|
78
|
+
| **Lightweight** | Never (too few findings to warrant) |
|
|
79
|
+
| **Standard** | When total findings ≥ 5 |
|
|
80
|
+
| **Deep** | Always (built into deep template) |
|
|
81
|
+
|
|
82
|
+
When triggered in standard mode, prepend this before the findings section:
|
|
83
|
+
|
|
84
|
+
```markdown
|
|
85
|
+
## Executive Summary
|
|
86
|
+
|
|
87
|
+
**Risk level**: {Low | Medium | High}
|
|
88
|
+
|
|
89
|
+
**Top issues to address**:
|
|
90
|
+
|
|
91
|
+
1. {Finding title} ({Severity}) — `{file}:{line}`
|
|
92
|
+
2. {Finding title} ({Severity}) — `{file}:{line}`
|
|
93
|
+
3. {Finding title} ({Severity}) — `{file}:{line}`
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Show up to 3 top findings. Derive risk level from:
|
|
97
|
+
- **High**: Any Critical finding, or ≥ 3 Major findings
|
|
98
|
+
- **Medium**: Any Major finding, or ≥ 5 Minor findings
|
|
99
|
+
- **Low**: Only Minor/Suggestion findings, fewer than 5 total
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Output Structure
|
|
104
|
+
|
|
105
|
+
All review modes now use severity-grouped output instead of per-file ordering:
|
|
106
|
+
|
|
107
|
+
```markdown
|
|
108
|
+
## Critical Findings
|
|
109
|
+
### 1. {Finding title}
|
|
110
|
+
...
|
|
111
|
+
|
|
112
|
+
## Major Findings
|
|
113
|
+
### 2. {Finding title}
|
|
114
|
+
...
|
|
115
|
+
|
|
116
|
+
## Minor Findings
|
|
117
|
+
### 3. {Finding title}
|
|
118
|
+
...
|
|
119
|
+
|
|
120
|
+
## Suggestions
|
|
121
|
+
### 4. {Finding title}
|
|
122
|
+
...
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Empty sections**: Omit severity sections that have no findings (e.g., if no Critical findings, skip the "Critical Findings" heading entirely).
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Insertion Points
|
|
130
|
+
|
|
131
|
+
### For review-code-skill.md
|
|
132
|
+
|
|
133
|
+
Insert as **Step 5c: Re-Rank and Group Findings** — after Step 5b (Verify Findings), before Step 6b (Pattern Review).
|
|
134
|
+
|
|
135
|
+
### For review-pr-skill.md
|
|
136
|
+
|
|
137
|
+
Insert as **Step 3c: Re-Rank and Group Findings** — after Step 3b (Verify Findings), before Step 4 (Generate Document).
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## Related Files
|
|
142
|
+
|
|
143
|
+
| File | Purpose |
|
|
144
|
+
|------|---------|
|
|
145
|
+
| `.claude/resources/skills/review-code-skill.md` | Add Step 5c (Re-Rank and Group) |
|
|
146
|
+
| `.claude/resources/skills/review-pr-skill.md` | Add Step 3c (Re-Rank and Group) |
|
|
147
|
+
| `.claude/resources/patterns/review-code-templates.md` | Standard template uses severity grouping |
|
|
148
|
+
| `.claude/resources/core/review-adaptive-depth.md` | Deep mode already severity-groups; this extends to standard |
|
|
149
|
+
| `.claude/resources/core/review-verification.md` | Verification runs before re-ranking |
|