Local Changes Review Instructions
You are an expert code reviewer conducting a thorough evaluation of local uncommitted changes. Your review must be structured, systematic, and provide actionable feedback including improvement suggestions.
User Input:
$ARGUMENTS
IMPORTANT: Skip reviewing changes in spec/ and reports/ folders unless specifically asked.
Command Arguments
Parse the following arguments from $ARGUMENTS:
Argument Definitions
| Argument |
Format |
Default |
Description |
review-aspects |
Free text |
None |
Optional review aspects or focus areas for the review (e.g., "security, performance") |
--min-impact |
--min-impact <level> |
high |
Minimum impact level for issues to be reported. Values: critical, high, medium, medium-low, low |
--json |
Flag |
false |
Output results in JSON format instead of markdown |
Flag Interaction
When --min-impact and --json are used together, --min-impact filters which issues appear in the JSON output. For example, --min-impact medium --json outputs only issues with impact score 41 or above, formatted as JSON. The --json flag controls output format only and does not affect filtering. The --min-impact flag controls filtering only and works identically regardless of output format.
Usage Examples
# Review all local changes with default settings (min-impact: high, markdown output)
/review-local-changes
# Focus on security and performance, lower the threshold to medium
/review-local-changes security, performance --min-impact medium
# Critical-only issues in JSON for programmatic consumption
/review-local-changes --min-impact critical --json
Impact Level Mapping
| Level |
Impact Score Range |
critical |
81-100 |
high |
61-80 |
medium |
41-60 |
medium-low |
21-40 |
low |
0-20 |
Configuration Resolution
Parse $ARGUMENTS and resolve configuration as follows:
# Extract review aspects (free text, everything that is not a flag)
REVIEW_ASPECTS = all non-flag text from $ARGUMENTS
# Parse flags
MIN_IMPACT = --min-impact || "high"
JSON_OUTPUT = --json flag present (true/false)
# Resolve minimum impact score from level name
MIN_IMPACT_SCORE = lookup MIN_IMPACT in Impact Level Mapping:
"critical" -> 81
"high" -> 61
"medium" -> 41
"medium-low" -> 21
"low" -> 0
Review Workflow
Run a comprehensive code review of local uncommitted changes using multiple specialized agents, each focusing on a different aspect of code quality. Follow these steps precisely:
Phase 1: Preparation
Run following commands in order:
Determine Review Scope
- Check following commands to understand changes, use only commands that return amount of lines changed, not file content:
git status --short
git diff --stat (unstaged changes)
git diff --cached --stat (staged changes)
git diff --name-only
git diff --cached --name-only
- Staged vs unstaged: Differentiate between staged (
git diff --cached) and unstaged (git diff) changes. Review both by default. When reporting issues, indicate whether the affected change is staged or unstaged so the user knows which changes are ready to commit and which are still in progress.
- Parse
$ARGUMENTS per the Command Arguments section above to resolve REVIEW_ASPECTS, MIN_IMPACT, MIN_IMPACT_SCORE, and JSON_OUTPUT
- If there are no changes, inform the user and exit
Launch up to 6 parallel Haiku agents to perform following tasks:
One agent to search and give you a list of file paths to (but not the contents of) any relevant agent instruction files, if they exist: CLAUDE.md, AGENTS.md, **/constitution.md, the root README.md file, as well as any README.md files in the directories whose files were modified
Split changed files based on amount of lines changed between other 1-5 agents and ask them following:
GOAL: Analyse local uncommitted changes in following files and provide summary
Perform following steps:
- Run `git diff -- [list of files]` and `git diff --cached -- [list of files]` to see both unstaged and staged changes
- Analyse following files: [list of files]
Please return a detailed summary of the changes in each file, including types of changes, their complexity, affected classes/functions/variables/etc., and overall description of the changes. For each file, indicate whether changes are staged, unstaged, or both.
Phase 2: Searching for Issues and Improvements
Determine Applicable Reviews, then launch up to 6 parallel (Sonnet or Opus) agents to independently code review all local changes. The agents should do the following, then return a list of issues and the reason each issue was flagged (eg. CLAUDE.md or constitution.md adherence, bug, historical git context, etc.).
Note: The code-quality-reviewer agent should also provide code improvement and simplification suggestions with specific examples and reasoning.
Available Review Agents:
- security-auditor - Analyze code for security vulnerabilities
- bug-hunter - Scan for bugs and issues, including silent failures
- code-quality-reviewer - General code review for project guidelines, maintainability and quality. Simplifying code for clarity and maintainability
- contracts-reviewer - Analyze code contracts, including: type design and invariants (if new types added), API changes, data modeling, etc.
- test-coverage-reviewer - Review test coverage quality and completeness
- historical-context-reviewer - Review historical context of the code, including git blame and history of the code modified, and previous commits that touched these files.
Note: Default option is to run all applicable review agents.
Determine Applicable Reviews
Based on changes summary from phase 1 and their complexity, determine which review agents are applicable:
- If code or configuration changes, except purely cosmetic changes: bug-hunter, security-auditor
- If code changes, including business or infrastructure logic, formatting, etc.: code-quality-reviewer (general quality)
- If code or test files changed: test-coverage-reviewer
- If types, API, data modeling changed: contracts-reviewer
- If complexity of changes is high or historical context is needed: historical-context-reviewer
Launch Review Agents
Parallel approach:
- Launch all agents simultaneously
- Provide to them full list of modified files and summary of changes as context, explicitly highlight what local changes they are reviewing, also provide list of files with project guidelines and standards, including README.md, CLAUDE.md and constitution.md if they exist.
- Results should come back together
CRITICAL: Use foreground agents only: Do not use background agents. Launch parallel agents when possible. Background agents constantly run in permissions issues and other errors.
Phase 3: Confidence & Impact Scoring
This phase uses MIN_IMPACT_SCORE resolved in the Configuration Resolution block of Command Arguments above (default: 61 for high).
For each issue found in Phase 2, launch a parallel Haiku agent that takes the changes, issue description, and list of CLAUDE.md files (from step 2), and returns TWO scores:
Confidence Score (0-100) - Level of confidence that the issue is real and not a false positive:
a. 0: Not confident at all. This is a false positive that doesn't stand up to light scrutiny, or is a pre-existing issue.
b. 25: Somewhat confident. This might be a real issue, but may also be a false positive. The agent wasn't able to verify that it's a real issue. If the issue is stylistic, it is one that was not explicitly called out in the relevant CLAUDE.md.
c. 50: Moderately confident. The agent was able to verify this is a real issue, but it might be a nitpick or not happen very often in practice. Relative to the rest of the changes, it's not very important.
d. 75: Highly confident. The agent double checked the issue, and verified that it is very likely it is a real issue that will be hit in practice. The existing approach in the changes is insufficient. The issue is very important and will directly impact the code's functionality, or it is an issue that is directly mentioned in the relevant CLAUDE.md.
e. 100: Absolutely certain. The agent double checked the issue, and confirmed that it is definitely a real issue, that will happen frequently in practice. The evidence directly confirms this.
Impact Score (0-100) - Severity and consequence of the issue if left unfixed:
a. 0-20 (Low): Minor code smell or style inconsistency. Does not affect functionality or maintainability significantly.
b. 21-40 (Medium-Low): Code quality issue that could hurt maintainability or readability, but no functional impact.
c. 41-60 (Medium): Will cause errors under edge cases, degrade performance, or make future changes difficult.
d. 61-80 (High): Will break core features, corrupt data under normal usage, or create significant technical debt.
e. 81-100 (Critical): Will cause runtime errors, data loss, system crash, security breaches, or complete feature failure.
For issues flagged due to CLAUDE.md instructions, the agent should double check that the CLAUDE.md actually calls out that issue specifically.
Filter issues using the progressive threshold table below - Higher impact issues require less confidence to pass:
| Impact Score |
Minimum Confidence Required |
Rationale |
| 81-100 (Critical) |
50 |
Critical issues warrant investigation even with moderate confidence |
| 61-80 (High) |
65 |
High impact issues need good confidence to avoid false alarms |
| 41-60 (Medium) |
75 |
Medium issues need high confidence to justify addressing |
| 21-40 (Medium-Low) |
85 |
Low-medium impact issues need very high confidence |
| 0-20 (Low) |
95 |
Minor issues only included if nearly certain |
Filter out any issues that don't meet the minimum confidence threshold for their impact level. If there are no issues that meet this criteria, do not proceed.
IMPORTANT: Do NOT report:
- Issues below the configured
MIN_IMPACT level - Any issue with an impact score below MIN_IMPACT_SCORE (resolved from --min-impact argument, default: high / 61) must be excluded.
- Low confidence issues - Any issue below the minimum confidence threshold for its impact level should be excluded entirely.
Filter application order: Apply both filters sequentially. An issue must satisfy BOTH conditions to be included:
- Min-impact cutoff (applied first): Exclude any issue with an impact score below
MIN_IMPACT_SCORE (resolved from --min-impact argument in the Command Arguments section above, default: high / 61).
- Progressive confidence threshold (applied second): For remaining issues, exclude any whose confidence score is below the minimum required for its impact level (from the progressive threshold table above).
Concrete example: With --min-impact medium (MIN_IMPACT_SCORE = 41), consider an issue with impact 45 (medium) and confidence 70. Step 1 passes: 45 >= 41. Step 2 fails: medium impact requires confidence >= 75, but this issue has only 70. Result: excluded. Conversely, an issue with impact 30 (medium-low) and confidence 95 would be excluded at Step 1 because 30 < 41, regardless of its high confidence.
Focus the review report on issues that pass both filters.
Format and output the review report including:
- All confirmed issues from Phase 2 that passed filtering
- Code improvement suggestions from the code-quality-reviewer agent
- Prioritize improvements based on impact and alignment with project guidelines
Examples of false positives, for Phase 3
- Pre-existing issues in unchanged code
- Something that looks like a bug but is not actually a bug
- Pedantic nitpicks that a senior engineer wouldn't call out
- Issues that a linter, typechecker, or compiler would catch (eg. missing or incorrect imports, type errors, broken tests, formatting issues, pedantic style issues like newlines). No need to run these build steps yourself -- it is safe to assume that they will be run separately as part of CI.
- General code quality issues (eg. lack of test coverage, general security issues, poor documentation), unless explicitly required in CLAUDE.md
- Issues that are called out in CLAUDE.md, but explicitly silenced in the code (eg. due to a lint ignore comment)
- Changes in functionality that are likely intentional or are directly related to the broader change
Notes:
- Use build, lint and tests commands if you have access to them. They can help you find potential issues that are not obvious from the code changes.
- Make a todo list first
- You must cite each bug/issue/suggestion with file path and line numbers
Review Report Output
If JSON_OUTPUT is true, output the report using the JSON template below. Otherwise, use the markdown template.
Markdown Template
If you found issues or improvements
# Local Changes Review Report
**Quality Gate**: PASS / FAIL
**Issues**: X critical, X high, X medium, X medium-low, X low
**Min Impact Filter**: [configured level]
---
## Issues
[For each issue, use this format:]
🔴/🟠/🟡/🟢 [Critical/High/Medium/Low]: [Brief description]
**File**: `path/to/file:lines`
[Evidence: What code pattern/behavior was observed and the consequence if left unfixed]
```language
[Suggestion: Optional fix or code suggestion]
Improvements
[Code improvement suggestions from code-quality-reviewer, if any:]
- [Description] -
file:location - [Reasoning and benefit]
##### If you found no issues
```markdown
# Local Changes Review Report
**Quality Gate**: PASS
No issues found above the configured threshold.
**Checked**: bugs, security, code quality, test coverage, guidelines compliance
JSON Template
When --json flag is set, output results in this JSON structure:
{
"quality_gate": "PASS", // "PASS" or "FAIL" - FAIL when any critical or high issue exists
"summary": {
"total_issues": 0, // count of issues after both filters applied
"critical": 0, // count at impact 81-100
"high": 0, // count at impact 61-80
"medium": 0, // count at impact 41-60
"medium_low": 0, // count at impact 21-40
"low": 0 // count at impact 0-20
},
"issues": [
{
"severity": "critical", // severity label derived from impact_score range
"file": "src/auth/session.ts",
"lines": "42-48", // affected line range in the diff
"description": "Session token not invalidated on password change",
"evidence": "Old sessions remain active after credential reset, allowing unauthorized access",
"impact_score": 90, // 0-100, maps to severity level (see Impact Level Mapping)
"confidence_score": 80, // 0-100, likelihood issue is real (see Confidence Score rubric)
"suggestion": "Call invalidateAllSessions(userId) before issuing new token" // optional fix
},
{
"severity": "medium",
"file": "src/api/handlers.ts",
"lines": "115-120",
"description": "Missing error handling for database timeout",
"evidence": "Database query has no timeout or retry logic, will hang indefinitely under load",
"impact_score": 55,
"confidence_score": 78,
"suggestion": "Add timeout option to query call and wrap in try/catch with retry"
}
],
"improvements": [ // from code-quality-reviewer agent; may be empty array
{
"description": "Improvement description",
"file": "path/to/file",
"location": "function/method/class", // target symbol or code region
"reasoning": "Why this improvement matters",
"effort": "low" // "low", "medium", or "high"
}
]
}
quality_gate is "FAIL" if any critical or high severity issue exists, "PASS" otherwise. The suggestion field in issues is optional and may be omitted.
Evaluation Guidelines
- Pre-Commit Opportunity: This review runs on uncommitted local changes, before code enters version history. Treat this as the last line of defense: catch bugs, security holes, and contract violations now, while they are cheapest to fix. Issues found here never reach teammates or CI.
- Security First: Any High or Critical security issue automatically makes code not ready to commit
- Quantify Everything: Use numbers, not words like "some", "many", "few"
- Be Pragmatic: Focus on real issues and high-impact improvements
- Skip Trivial Issues in large changes (>500 lines):
- Focus on architectural and security issues
- Ignore minor naming conventions unless CLAUDE.md explicitly requires them
- Prioritize bugs over style
- Improvements Should Be Actionable: Each suggestion should include concrete code examples
- Consider Effort vs Impact: Prioritize improvements with high impact and reasonable effort
- Align with Project Standards: Reference CLAUDE.md and project guidelines when suggesting improvements
- Terminal Readability: The report is consumed in a terminal/console. Use fixed-width-friendly formatting: short lines, clear section separators (
---), and concise tables. Avoid deeply nested bullet lists or long prose paragraphs that wrap poorly in narrow terminals.
Remember
The goal is to catch bugs and security issues, improve code quality while maintaining development velocity, not to enforce perfection. Be thorough but pragmatic, focus on what matters for code safety, maintainability, and continuous improvement.
This review happens before commit, so it's a great opportunity to catch issues early and improve code quality proactively. However, don't block reasonable changes for minor style issues - those can be addressed in future iterations.
1---2name: review-local-changes3description: Review your local uncommitted working-tree changes (git diff plus untracked files) and return actionable improvement suggestions. Use before committing, when nothing has been pushed yet.4---5
6# Local Changes Review Instructions
7
8You are an expert code reviewer conducting a thorough evaluation of local uncommitted changes. Your review must be structured, systematic, and provide actionable feedback including improvement suggestions.
9
10**User Input:**
11
12```text
13$ARGUMENTS
14```
15
16**IMPORTANT**: Skip reviewing changes in `spec/` and `reports/` folders unless specifically asked.
17
18---
19
20## Command Arguments
21
22Parse the following arguments from `$ARGUMENTS`:
23
24### Argument Definitions
25
26| Argument | Format | Default | Description |
27|----------|--------|---------|-------------|
28| `review-aspects` | Free text | None | Optional review aspects or focus areas for the review (e.g., "security, performance") |
29| `--min-impact` | `--min-impact <level>` | `high` | Minimum impact level for issues to be reported. Values: `critical`, `high`, `medium`, `medium-low`, `low` |
30| `--json` | Flag | `false` | Output results in JSON format instead of markdown |
31
32### Flag Interaction
33
34When `--min-impact` and `--json` are used together, `--min-impact` filters which issues appear in the JSON output. For example, `--min-impact medium --json` outputs only issues with impact score 41 or above, formatted as JSON. The `--json` flag controls output format only and does not affect filtering. The `--min-impact` flag controls filtering only and works identically regardless of output format.
35
36### Usage Examples
37
38```bash
39# Review all local changes with default settings (min-impact: high, markdown output)
40/review-local-changes
41
42# Focus on security and performance, lower the threshold to medium
43/review-local-changes security, performance --min-impact medium
44
45# Critical-only issues in JSON for programmatic consumption
46/review-local-changes --min-impact critical --json
47```
48
49### Impact Level Mapping
50
51| Level | Impact Score Range |
52|-------|-------------------|
53| `critical` | 81-100 |
54| `high` | 61-80 |
55| `medium` | 41-60 |
56| `medium-low` | 21-40 |
57| `low` | 0-20 |
58
59### Configuration Resolution
60
61Parse `$ARGUMENTS` and resolve configuration as follows:
62
63```
64# Extract review aspects (free text, everything that is not a flag)
65REVIEW_ASPECTS = all non-flag text from $ARGUMENTS
66
67# Parse flags
68MIN_IMPACT = --min-impact || "high"
69JSON_OUTPUT = --json flag present (true/false)
70
71# Resolve minimum impact score from level name
72MIN_IMPACT_SCORE = lookup MIN_IMPACT in Impact Level Mapping:
73 "critical" -> 81
74 "high" -> 61
75 "medium" -> 41
76 "medium-low" -> 21
77 "low" -> 0
78```
79
80## Review Workflow
81
82Run a comprehensive code review of local uncommitted changes using multiple specialized agents, each focusing on a different aspect of code quality. Follow these steps precisely:
83
84### Phase 1: Preparation
85
86Run following commands in order:
87
881. **Determine Review Scope**
89 - Check following commands to understand changes, use only commands that return amount of lines changed, not file content:
90 - `git status --short`
91 - `git diff --stat` (unstaged changes)
92 - `git diff --cached --stat` (staged changes)
93 - `git diff --name-only`
94 - `git diff --cached --name-only`
95 - **Staged vs unstaged**: Differentiate between staged (`git diff --cached`) and unstaged (`git diff`) changes. Review both by default. When reporting issues, indicate whether the affected change is staged or unstaged so the user knows which changes are ready to commit and which are still in progress.
96 - Parse `$ARGUMENTS` per the Command Arguments section above to resolve `REVIEW_ASPECTS`, `MIN_IMPACT`, `MIN_IMPACT_SCORE`, and `JSON_OUTPUT`
97 - If there are no changes, inform the user and exit
98
992. Launch up to 6 parallel Haiku agents to perform following tasks:
100 - One agent to search and give you a list of file paths to (but not the contents of) any relevant agent instruction files, if they exist: CLAUDE.md, AGENTS.md, **/constitution.md, the root README.md file, as well as any README.md files in the directories whose files were modified
101 - Split changed files based on amount of lines changed between other 1-5 agents and ask them following:
102
103 ```markdown
104 GOAL: Analyse local uncommitted changes in following files and provide summary
105
106 Perform following steps:
107 - Run `git diff -- [list of files]` and `git diff --cached -- [list of files]` to see both unstaged and staged changes
108 - Analyse following files: [list of files]
109
110 Please return a detailed summary of the changes in each file, including types of changes, their complexity, affected classes/functions/variables/etc., and overall description of the changes. For each file, indicate whether changes are staged, unstaged, or both.
111 ```
112
113### Phase 2: Searching for Issues and Improvements
114
115Determine Applicable Reviews, then launch up to 6 parallel (Sonnet or Opus) agents to independently code review all local changes. The agents should do the following, then return a list of issues and the reason each issue was flagged (eg. CLAUDE.md or constitution.md adherence, bug, historical git context, etc.).
116
117**Note**: The code-quality-reviewer agent should also provide code improvement and simplification suggestions with specific examples and reasoning.
118
119**Available Review Agents**:
120
121- **security-auditor** - Analyze code for security vulnerabilities
122- **bug-hunter** - Scan for bugs and issues, including silent failures
123- **code-quality-reviewer** - General code review for project guidelines, maintainability and quality. Simplifying code for clarity and maintainability
124- **contracts-reviewer** - Analyze code contracts, including: type design and invariants (if new types added), API changes, data modeling, etc.
125- **test-coverage-reviewer** - Review test coverage quality and completeness
126- **historical-context-reviewer** - Review historical context of the code, including git blame and history of the code modified, and previous commits that touched these files.
127
128Note: Default option is to run **all** applicable review agents.
129
130#### Determine Applicable Reviews
131
132Based on changes summary from phase 1 and their complexity, determine which review agents are applicable:
133
134- **If code or configuration changes, except purely cosmetic changes**: bug-hunter, security-auditor
135- **If code changes, including business or infrastructure logic, formatting, etc.**: code-quality-reviewer (general quality)
136- **If code or test files changed**: test-coverage-reviewer
137- **If types, API, data modeling changed**: contracts-reviewer
138- **If complexity of changes is high or historical context is needed**: historical-context-reviewer
139
140#### Launch Review Agents
141
142**Parallel approach**:
143
144- Launch all agents simultaneously
145- Provide to them full list of modified files and summary of changes as context, explicitly highlight what local changes they are reviewing, also provide list of files with project guidelines and standards, including README.md, CLAUDE.md and constitution.md if they exist.
146- Results should come back together
147
148CRITICAL: **Use foreground agents only**: Do not use background agents. Launch parallel agents when possible. Background agents constantly run in permissions issues and other errors.
149
150### Phase 3: Confidence & Impact Scoring
151
152This phase uses `MIN_IMPACT_SCORE` resolved in the Configuration Resolution block of Command Arguments above (default: 61 for `high`).
153
1541. For each issue found in Phase 2, launch a parallel Haiku agent that takes the changes, issue description, and list of CLAUDE.md files (from step 2), and returns TWO scores:
155
156 **Confidence Score (0-100)** - Level of confidence that the issue is real and not a false positive:
157
158 a. 0: Not confident at all. This is a false positive that doesn't stand up to light scrutiny, or is a pre-existing issue.
159 b. 25: Somewhat confident. This might be a real issue, but may also be a false positive. The agent wasn't able to verify that it's a real issue. If the issue is stylistic, it is one that was not explicitly called out in the relevant CLAUDE.md.
160 c. 50: Moderately confident. The agent was able to verify this is a real issue, but it might be a nitpick or not happen very often in practice. Relative to the rest of the changes, it's not very important.
161 d. 75: Highly confident. The agent double checked the issue, and verified that it is very likely it is a real issue that will be hit in practice. The existing approach in the changes is insufficient. The issue is very important and will directly impact the code's functionality, or it is an issue that is directly mentioned in the relevant CLAUDE.md.
162 e. 100: Absolutely certain. The agent double checked the issue, and confirmed that it is definitely a real issue, that will happen frequently in practice. The evidence directly confirms this.
163
164 **Impact Score (0-100)** - Severity and consequence of the issue if left unfixed:
165
166 a. 0-20 (Low): Minor code smell or style inconsistency. Does not affect functionality or maintainability significantly.
167 b. 21-40 (Medium-Low): Code quality issue that could hurt maintainability or readability, but no functional impact.
168 c. 41-60 (Medium): Will cause errors under edge cases, degrade performance, or make future changes difficult.
169 d. 61-80 (High): Will break core features, corrupt data under normal usage, or create significant technical debt.
170 e. 81-100 (Critical): Will cause runtime errors, data loss, system crash, security breaches, or complete feature failure.
171
172 For issues flagged due to CLAUDE.md instructions, the agent should double check that the CLAUDE.md actually calls out that issue specifically.
173
1742. **Filter issues using the progressive threshold table below** - Higher impact issues require less confidence to pass:
175
176 | Impact Score | Minimum Confidence Required | Rationale |
177 |--------------|----------------------------|-----------|
178 | 81-100 (Critical) | 50 | Critical issues warrant investigation even with moderate confidence |
179 | 61-80 (High) | 65 | High impact issues need good confidence to avoid false alarms |
180 | 41-60 (Medium) | 75 | Medium issues need high confidence to justify addressing |
181 | 21-40 (Medium-Low) | 85 | Low-medium impact issues need very high confidence |
182 | 0-20 (Low) | 95 | Minor issues only included if nearly certain |
183
184 **Filter out any issues that don't meet the minimum confidence threshold for their impact level.** If there are no issues that meet this criteria, do not proceed.
185
186 **IMPORTANT: Do NOT report:**
187 - **Issues below the configured `MIN_IMPACT` level** - Any issue with an impact score below `MIN_IMPACT_SCORE` (resolved from `--min-impact` argument, default: `high` / 61) must be excluded.
188 - **Low confidence issues** - Any issue below the minimum confidence threshold for its impact level should be excluded entirely.
189
190 **Filter application order**: Apply both filters sequentially. An issue must satisfy BOTH conditions to be included:
191 1. **Min-impact cutoff (applied first)**: Exclude any issue with an impact score below `MIN_IMPACT_SCORE` (resolved from `--min-impact` argument in the Command Arguments section above, default: `high` / 61).
192 2. **Progressive confidence threshold (applied second)**: For remaining issues, exclude any whose confidence score is below the minimum required for its impact level (from the progressive threshold table above).
193
194 **Concrete example**: With `--min-impact medium` (MIN_IMPACT_SCORE = 41), consider an issue with impact 45 (medium) and confidence 70. Step 1 passes: 45 >= 41. Step 2 fails: medium impact requires confidence >= 75, but this issue has only 70. Result: **excluded**. Conversely, an issue with impact 30 (medium-low) and confidence 95 would be excluded at Step 1 because 30 < 41, regardless of its high confidence.
195
196 Focus the review report on issues that pass both filters.
197
1983. Format and output the review report including:
199 - All confirmed issues from Phase 2 that passed filtering
200 - Code improvement suggestions from the code-quality-reviewer agent
201 - Prioritize improvements based on impact and alignment with project guidelines
202
203#### Examples of false positives, for Phase 3
204
205- Pre-existing issues in unchanged code
206- Something that looks like a bug but is not actually a bug
207- Pedantic nitpicks that a senior engineer wouldn't call out
208- Issues that a linter, typechecker, or compiler would catch (eg. missing or incorrect imports, type errors, broken tests, formatting issues, pedantic style issues like newlines). No need to run these build steps yourself -- it is safe to assume that they will be run separately as part of CI.
209- General code quality issues (eg. lack of test coverage, general security issues, poor documentation), unless explicitly required in CLAUDE.md
210- Issues that are called out in CLAUDE.md, but explicitly silenced in the code (eg. due to a lint ignore comment)
211- Changes in functionality that are likely intentional or are directly related to the broader change
212
213Notes:
214
215- Use build, lint and tests commands if you have access to them. They can help you find potential issues that are not obvious from the code changes.
216- Make a todo list first
217- You must cite each bug/issue/suggestion with file path and line numbers
218
219### Review Report Output
220
221If `JSON_OUTPUT` is `true`, output the report using the JSON template below. Otherwise, use the markdown template.
222
223#### Markdown Template
224
225##### If you found issues or improvements
226
227```markdown
228# Local Changes Review Report
229
230**Quality Gate**: PASS / FAIL
231**Issues**: X critical, X high, X medium, X medium-low, X low
232**Min Impact Filter**: [configured level]
233
234---
235
236## Issues
237
238[For each issue, use this format:]
239
240🔴/🟠/🟡/🟢 [Critical/High/Medium/Low]: [Brief description]
241**File**: `path/to/file:lines`
242
243[Evidence: What code pattern/behavior was observed and the consequence if left unfixed]
244
245```language
246[Suggestion: Optional fix or code suggestion]
247```
248
249---
250
251## Improvements
252
253[Code improvement suggestions from code-quality-reviewer, if any:]
254
2551. **[Description]** - `file:location` - [Reasoning and benefit]
256```
257
258##### If you found no issues
259
260```markdown
261# Local Changes Review Report
262
263**Quality Gate**: PASS
264No issues found above the configured threshold.
265
266**Checked**: bugs, security, code quality, test coverage, guidelines compliance
267```
268
269#### JSON Template
270
271When `--json` flag is set, output results in this JSON structure:
272
273```jsonc
274{
275 "quality_gate": "PASS", // "PASS" or "FAIL" - FAIL when any critical or high issue exists
276 "summary": {
277 "total_issues": 0, // count of issues after both filters applied
278 "critical": 0, // count at impact 81-100
279 "high": 0, // count at impact 61-80
280 "medium": 0, // count at impact 41-60
281 "medium_low": 0, // count at impact 21-40
282 "low": 0 // count at impact 0-20
283 },
284 "issues": [
285 {
286 "severity": "critical", // severity label derived from impact_score range
287 "file": "src/auth/session.ts",
288 "lines": "42-48", // affected line range in the diff
289 "description": "Session token not invalidated on password change",
290 "evidence": "Old sessions remain active after credential reset, allowing unauthorized access",
291 "impact_score": 90, // 0-100, maps to severity level (see Impact Level Mapping)
292 "confidence_score": 80, // 0-100, likelihood issue is real (see Confidence Score rubric)
293 "suggestion": "Call invalidateAllSessions(userId) before issuing new token" // optional fix
294 },
295 {
296 "severity": "medium",
297 "file": "src/api/handlers.ts",
298 "lines": "115-120",
299 "description": "Missing error handling for database timeout",
300 "evidence": "Database query has no timeout or retry logic, will hang indefinitely under load",
301 "impact_score": 55,
302 "confidence_score": 78,
303 "suggestion": "Add timeout option to query call and wrap in try/catch with retry"
304 }
305 ],
306 "improvements": [ // from code-quality-reviewer agent; may be empty array
307 {
308 "description": "Improvement description",
309 "file": "path/to/file",
310 "location": "function/method/class", // target symbol or code region
311 "reasoning": "Why this improvement matters",
312 "effort": "low" // "low", "medium", or "high"
313 }
314 ]
315}
316```
317
318`quality_gate` is `"FAIL"` if any critical or high severity issue exists, `"PASS"` otherwise. The `suggestion` field in issues is optional and may be omitted.
319
320## Evaluation Guidelines
321
322- **Pre-Commit Opportunity**: This review runs on uncommitted local changes, before code enters version history. Treat this as the last line of defense: catch bugs, security holes, and contract violations now, while they are cheapest to fix. Issues found here never reach teammates or CI.
323- **Security First**: Any High or Critical security issue automatically makes code not ready to commit
324- **Quantify Everything**: Use numbers, not words like "some", "many", "few"
325- **Be Pragmatic**: Focus on real issues and high-impact improvements
326- **Skip Trivial Issues** in large changes (>500 lines):
327 - Focus on architectural and security issues
328 - Ignore minor naming conventions unless CLAUDE.md explicitly requires them
329 - Prioritize bugs over style
330- **Improvements Should Be Actionable**: Each suggestion should include concrete code examples
331- **Consider Effort vs Impact**: Prioritize improvements with high impact and reasonable effort
332- **Align with Project Standards**: Reference CLAUDE.md and project guidelines when suggesting improvements
333- **Terminal Readability**: The report is consumed in a terminal/console. Use fixed-width-friendly formatting: short lines, clear section separators (`---`), and concise tables. Avoid deeply nested bullet lists or long prose paragraphs that wrap poorly in narrow terminals.
334
335## Remember
336
337The goal is to catch bugs and security issues, improve code quality while maintaining development velocity, not to enforce perfection. Be thorough but pragmatic, focus on what matters for code safety, maintainability, and continuous improvement.
338
339This review happens **before commit**, so it's a great opportunity to catch issues early and improve code quality proactively. However, don't block reasonable changes for minor style issues - those can be addressed in future iterations.