Review Verification Protocol
This protocol MUST be followed before reporting any code review finding. Skipping these steps leads to false positives that waste developer time and erode trust in reviews.
Hard gates (sequence)
Complete gates in order for each finding (or finding class). A gate passes only when the pass condition is objectively met—internal confidence is not enough.
- Read scope — PASS when: You cite the full enclosing unit you judged (e.g. function, method, or class): file path plus start–end line range or symbol name. Diff-only context without full-unit read fails this gate.
- Reference check (required for “unused”, “dead code”, “orphaned export”, “never called”) — PASS when: You ran a workspace-wide search for the symbol (ripgrep, IDE references, or
find_referencing_symbols-style lookup) and noted whether non-definition matches exist. If use may be dynamic (decorators, getattr, entry points, plugins), PASS when: you state that and name the registration or import path that could justify the symbol.
- Upstream / downstream (required for “missing validation”, “no error handling”, “race”, “leak”) — PASS when: You checked at least one of: caller, route/middleware, parent task, framework hook, or lifecycle (e.g. teardown, signal), and recorded whether responsibility already sits there.
- Evidence line — PASS when: The finding includes
[FILE:LINE] to the line that shows the issue (same requirement as Before Submitting Review).
If any gate fails, do not report the issue; gather evidence or drop it.
Pre-Report Verification Checklist
Before flagging ANY issue, verify (after Hard gates above):
Verification by Issue Type
"Unused Variable/Function"
Before flagging, you MUST:
- Search for ALL references in the codebase (grep/find)
- Check if it's exported and used by external consumers
- Check if it's used via reflection, decorators, or dynamic dispatch
- Verify it's not a callback passed to a framework
Common false positives:
- State setters in React (may trigger re-renders even if value appears unused)
- Variables used in templates/JSX
- Exports used by consuming packages
"Missing Validation/Error Handling"
Before flagging, you MUST:
- Check if validation exists at a higher level (caller, middleware, route handler)
- Check if the framework provides validation (Pydantic, Zod, TypeScript)
- Verify the "missing" check isn't present in a different form
Common false positives:
- Framework already validates (FastAPI + Pydantic, React Hook Form)
- Parent component validates before passing props
- Error boundary catches at higher level
"Type Assertion/Unsafe Cast"
Before flagging, you MUST:
- Confirm it's actually an assertion, not an annotation
- Check if the type is narrowed by runtime checks before the point
- Verify if framework guarantees the type (loader data, form data)
Valid patterns often flagged incorrectly:
# Type annotation, NOT cast
data: UserData = await load_user()
# Type narrowing with isinstance
if isinstance(data, User):
data.name # Mypy knows this is User
"Potential Memory Leak/Race Condition"
Before flagging, you MUST:
- Verify cleanup function is actually missing (not just in a different location)
- Check if AbortController signal is checked after awaits
- Confirm the component can actually unmount during the async operation
Common false positives:
- Cleanup exists in useEffect return
- Signal is checked (code reviewer missed it)
- Operation completes before unmount is possible
"Performance Issue"
Before flagging, you MUST:
- Confirm the code runs frequently enough to matter (render vs click handler)
- Verify the optimization would have measurable impact
- Check if the framework already optimizes this (React compiler, memoization)
Do NOT flag:
- Functions created in click handlers (runs once per click)
- Array methods on small arrays (< 100 items)
- Object creation in event handlers
Severity Calibration
Critical (Block Merge)
ONLY use for:
- Security vulnerabilities (injection, auth bypass, data exposure)
- Data corruption bugs
- Crash-causing bugs in happy path
- Breaking changes to public APIs
Major (Should Fix)
Use for:
- Logic bugs that affect functionality
- Missing error handling that causes poor UX
- Performance issues with measurable impact
- Accessibility violations
Minor (Consider Fixing)
Use for:
- Code clarity improvements
- Documentation gaps
- Inconsistent style (within reason)
- Non-critical test coverage gaps
Informational (No Action Required)
Use for:
- Improvements that require adding new dependencies or modules
- Suggestions for net-new code that didn't exist in the codebase before (new modules, test suites, abstractions)
- Architectural ideas for future consideration
- Test infrastructure suggestions (new mock libraries, behaviour extraction)
- Optimizations without measurable impact in the current context
These are NOT review blockers. They should be noted for the author's awareness but must not appear in the actionable issue count. The Verdict should ignore informational items entirely.
Do NOT Flag At All
- Style preferences where both approaches are valid
- Optimizations with no measurable benefit
- Test code not meeting production standards (intentionally simpler)
- Library/framework internal code (shadcn components, generated code)
- Hypothetical issues that require unlikely conditions
Valid Patterns (Do NOT Flag)
Python
| Pattern |
Why It's Valid |
dict.get(key, []) |
Returns default for missing keys, not error suppression |
Optional[T] return type |
Standard way to express nullable in Python typing |
assert in test code |
pytest uses assertions, not try/except |
| Type annotation on variable |
Not a cast, just a hint for type checkers |
typing.cast() with prior validation |
Valid after runtime check confirms type |
FastAPI
| Pattern |
Why It's Valid |
Depends() without explicit type |
FastAPI infers dependency type from function signature |
async def endpoint without await |
May use sync DB calls or simple returns |
| Response model different from DB model |
Separation of concerns between API and persistence |
BackgroundTasks parameter |
Valid for fire-and-forget operations |
Direct request.state access |
Standard pattern for middleware-injected data |
Testing
| Pattern |
Why It's Valid |
assert without message |
pytest rewrites assertions to show detailed diffs |
@pytest.fixture without explicit scope |
Default function scope is correct for most fixtures |
monkeypatch over unittest.mock |
Simpler API, pytest-native |
| Fixture returning mutable state |
Each test gets fresh fixture invocation by default |
General
| Pattern |
Why It's Valid |
+? lazy quantifier in regex |
Prevents over-matching, correct for many patterns |
| Direct string concatenation |
Simpler than template literals for simple cases |
| Multiple returns in function |
Can improve readability |
| Comments explaining "why" |
Better than no comments |
Context-Sensitive Rules
Type Annotations
Flag missing type annotation ONLY IF ALL of these are true:
Exception Handling
Flag bare except ONLY IF:
Error Handling
Flag missing try/except ONLY IF:
Before Submitting Review
Final verification:
- Re-read each finding and ask: "Did I verify this is actually an issue?"
- For each finding, can you point to the specific line that proves the issue exists?
- Would a domain expert agree this is a problem, or is it a style preference?
- Does fixing this provide real value, or is it busywork?
- Format every finding as:
[FILE:LINE] ISSUE_TITLE
- For each finding, ask: "Does this fix existing code, or does it request entirely new code that didn't exist before?" If the latter, downgrade to Informational.
- If this is a re-review: ONLY verify previous fixes. Do not introduce new findings.
If uncertain about any finding, either:
- Remove it from the review
- Mark it as a question rather than an issue
- Verify by reading more code context
1---2name: review-verification-protocol-43description: Mandatory verification steps for all code reviews to reduce false positives. Load this skill before reporting ANY code review findings.4---5
6# Review Verification Protocol
7
8This protocol MUST be followed before reporting any code review finding. Skipping these steps leads to false positives that waste developer time and erode trust in reviews.
9
10## Hard gates (sequence)
11
12Complete gates **in order** for each finding (or finding class). A gate **passes** only when the pass condition is objectively met—internal confidence is not enough.
13
141. **Read scope** — **PASS when:** You cite the **full** enclosing unit you judged (e.g. function, method, or class): file path plus **start–end line range** or symbol name. Diff-only context without full-unit read **fails** this gate.
152. **Reference check** (required for “unused”, “dead code”, “orphaned export”, “never called”) — **PASS when:** You ran a **workspace-wide search** for the symbol (ripgrep, IDE references, or `find_referencing_symbols`-style lookup) and noted whether non-definition matches exist. If use may be dynamic (decorators, `getattr`, entry points, plugins), **PASS when:** you state that and name the registration or import path that could justify the symbol.
163. **Upstream / downstream** (required for “missing validation”, “no error handling”, “race”, “leak”) — **PASS when:** You checked at least one of: caller, route/middleware, parent task, framework hook, or lifecycle (e.g. teardown, signal), and recorded whether responsibility already sits there.
174. **Evidence line** — **PASS when:** The finding includes **`[FILE:LINE]`** to the line that **shows** the issue (same requirement as *Before Submitting Review*).
18
19If any gate fails, **do not** report the issue; gather evidence or drop it.
20
21## Pre-Report Verification Checklist
22
23Before flagging ANY issue, verify (after **Hard gates** above):
24
25- [ ] **I read the actual code** - Not just the diff context, but the full function/class
26- [ ] **I searched for usages** - Before claiming "unused", searched all references
27- [ ] **I checked surrounding code** - The issue may be handled elsewhere (guards, earlier checks)
28- [ ] **I verified syntax against current docs** - Framework syntax evolves (Tailwind v4, TS 5.x, React 19)
29- [ ] **I distinguished "wrong" from "different style"** - Both approaches may be valid
30- [ ] **I considered intentional design** - Checked comments, CLAUDE.md, architectural context
31
32## Verification by Issue Type
33
34### "Unused Variable/Function"
35
36**Before flagging**, you MUST:
371. Search for ALL references in the codebase (grep/find)
382. Check if it's exported and used by external consumers
393. Check if it's used via reflection, decorators, or dynamic dispatch
404. Verify it's not a callback passed to a framework
41
42**Common false positives:**
43- State setters in React (may trigger re-renders even if value appears unused)
44- Variables used in templates/JSX
45- Exports used by consuming packages
46
47### "Missing Validation/Error Handling"
48
49**Before flagging**, you MUST:
501. Check if validation exists at a higher level (caller, middleware, route handler)
512. Check if the framework provides validation (Pydantic, Zod, TypeScript)
523. Verify the "missing" check isn't present in a different form
53
54**Common false positives:**
55- Framework already validates (FastAPI + Pydantic, React Hook Form)
56- Parent component validates before passing props
57- Error boundary catches at higher level
58
59### "Type Assertion/Unsafe Cast"
60
61**Before flagging**, you MUST:
621. Confirm it's actually an assertion, not an annotation
632. Check if the type is narrowed by runtime checks before the point
643. Verify if framework guarantees the type (loader data, form data)
65
66**Valid patterns often flagged incorrectly:**
67```python
68# Type annotation, NOT cast
69data: UserData = await load_user()
70
71# Type narrowing with isinstance
72if isinstance(data, User):
73 data.name # Mypy knows this is User
74```
75
76### "Potential Memory Leak/Race Condition"
77
78**Before flagging**, you MUST:
791. Verify cleanup function is actually missing (not just in a different location)
802. Check if AbortController signal is checked after awaits
813. Confirm the component can actually unmount during the async operation
82
83**Common false positives:**
84- Cleanup exists in useEffect return
85- Signal is checked (code reviewer missed it)
86- Operation completes before unmount is possible
87
88### "Performance Issue"
89
90**Before flagging**, you MUST:
911. Confirm the code runs frequently enough to matter (render vs click handler)
922. Verify the optimization would have measurable impact
933. Check if the framework already optimizes this (React compiler, memoization)
94
95**Do NOT flag:**
96- Functions created in click handlers (runs once per click)
97- Array methods on small arrays (< 100 items)
98- Object creation in event handlers
99
100## Severity Calibration
101
102### Critical (Block Merge)
103
104**ONLY use for:**
105- Security vulnerabilities (injection, auth bypass, data exposure)
106- Data corruption bugs
107- Crash-causing bugs in happy path
108- Breaking changes to public APIs
109
110### Major (Should Fix)
111
112**Use for:**
113- Logic bugs that affect functionality
114- Missing error handling that causes poor UX
115- Performance issues with measurable impact
116- Accessibility violations
117
118### Minor (Consider Fixing)
119
120**Use for:**
121- Code clarity improvements
122- Documentation gaps
123- Inconsistent style (within reason)
124- Non-critical test coverage gaps
125
126### Informational (No Action Required)
127
128**Use for:**
129- Improvements that require adding new dependencies or modules
130- Suggestions for net-new code that didn't exist in the codebase before (new modules, test suites, abstractions)
131- Architectural ideas for future consideration
132- Test infrastructure suggestions (new mock libraries, behaviour extraction)
133- Optimizations without measurable impact in the current context
134
135**These are NOT review blockers.** They should be noted for the author's awareness but must not appear in the actionable issue count. The Verdict should ignore informational items entirely.
136
137### Do NOT Flag At All
138
139- Style preferences where both approaches are valid
140- Optimizations with no measurable benefit
141- Test code not meeting production standards (intentionally simpler)
142- Library/framework internal code (shadcn components, generated code)
143- Hypothetical issues that require unlikely conditions
144
145## Valid Patterns (Do NOT Flag)
146
147### Python
148
149| Pattern | Why It's Valid |
150|---------|----------------|
151| `dict.get(key, [])` | Returns default for missing keys, not error suppression |
152| `Optional[T]` return type | Standard way to express nullable in Python typing |
153| `assert` in test code | pytest uses assertions, not try/except |
154| Type annotation on variable | Not a cast, just a hint for type checkers |
155| `typing.cast()` with prior validation | Valid after runtime check confirms type |
156
157### FastAPI
158
159| Pattern | Why It's Valid |
160|---------|----------------|
161| `Depends()` without explicit type | FastAPI infers dependency type from function signature |
162| `async def` endpoint without await | May use sync DB calls or simple returns |
163| Response model different from DB model | Separation of concerns between API and persistence |
164| `BackgroundTasks` parameter | Valid for fire-and-forget operations |
165| Direct `request.state` access | Standard pattern for middleware-injected data |
166
167### Testing
168
169| Pattern | Why It's Valid |
170|---------|----------------|
171| `assert` without message | pytest rewrites assertions to show detailed diffs |
172| `@pytest.fixture` without explicit scope | Default `function` scope is correct for most fixtures |
173| `monkeypatch` over `unittest.mock` | Simpler API, pytest-native |
174| Fixture returning mutable state | Each test gets fresh fixture invocation by default |
175
176### General
177
178| Pattern | Why It's Valid |
179|---------|----------------|
180| `+?` lazy quantifier in regex | Prevents over-matching, correct for many patterns |
181| Direct string concatenation | Simpler than template literals for simple cases |
182| Multiple returns in function | Can improve readability |
183| Comments explaining "why" | Better than no comments |
184
185## Context-Sensitive Rules
186
187### Type Annotations
188
189Flag missing type annotation **ONLY IF ALL** of these are true:
190- [ ] Function is public API (not prefixed with `_`)
191- [ ] Types are not obvious from context (e.g., `x = 5` is clearly `int`)
192- [ ] Not a test function or fixture
193- [ ] Codebase has existing typing conventions
194
195### Exception Handling
196
197Flag bare `except` **ONLY IF**:
198- [ ] Not in a top-level error boundary / middleware
199- [ ] The caught exception is actually swallowed (not logged/re-raised)
200- [ ] Specific exception types are known and available
201- [ ] Not in cleanup/teardown code where any error should be caught
202
203### Error Handling
204
205Flag missing try/except **ONLY IF**:
206- [ ] No middleware or error handler catches this at a higher level
207- [ ] The framework doesn't handle errors (FastAPI exception handlers)
208- [ ] The error would cause a crash, not just a failed operation
209- [ ] User needs specific feedback for this error type
210
211## Before Submitting Review
212
213Final verification:
2141. Re-read each finding and ask: "Did I verify this is actually an issue?"
2152. For each finding, can you point to the specific line that proves the issue exists?
2163. Would a domain expert agree this is a problem, or is it a style preference?
2174. Does fixing this provide real value, or is it busywork?
2185. Format every finding as: `[FILE:LINE] ISSUE_TITLE`
2196. For each finding, ask: "Does this fix existing code, or does it request entirely new code that didn't exist before?" If the latter, downgrade to Informational.
2207. If this is a re-review: ONLY verify previous fixes. Do not introduce new findings.
221
222If uncertain about any finding, either:
223- Remove it from the review
224- Mark it as a question rather than an issue
225- Verify by reading more code context