Beagle review-verification-protocol
Mandatory verification steps for all code reviews to reduce false positives. Load this skill before reporting ANY code review findings.
git clone https://github.com/existential-birds/beagle
T=$(mktemp -d) && git clone --depth=1 https://github.com/existential-birds/beagle "$T" && mkdir -p ~/.claude/skills && cp -r "$T/plugins/beagle-elixir/skills/review-verification-protocol" ~/.claude/skills/existential-birds-beagle-review-verification-protocol-e1e91c && rm -rf "$T"
plugins/beagle-elixir/skills/review-verification-protocol/SKILL.mdReview 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.
Pre-Report Verification Checklist
Before flagging ANY issue, verify:
- I read the actual code - Not just the diff context, but the full function/class
- I searched for usages - Before claiming "unused", searched all references
- I checked surrounding code - The issue may be handled elsewhere (guards, earlier checks)
- I verified syntax against current docs - Framework syntax evolves (Tailwind v4, TS 5.x, React 19)
- I distinguished "wrong" from "different style" - Both approaches may be valid
- I considered intentional design - Checked comments, CLAUDE.md, architectural context
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:
# Pattern matching, NOT type casting %UserData{} = data = load_user() # Guard clauses narrow the type safely def process(%User{name: name} = user) do name # Elixir knows this is a User struct end
"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)
Elixir
| Pattern | Why It's Valid |
|---|---|
with multiple clauses | Standard pattern matching, not excessive branching |
chains | Idiomatic for sequential operations that may fail |
Pipe operator () chains | Elixir's core composition pattern |
without Dialyzer enforcement | Documentation value even without static analysis |
private functions | Proper encapsulation, not hidden complexity |
Phoenix/LiveView
| Pattern | Why It's Valid |
|---|---|
in | Standard LiveView state initialization |
returning | Correct for UI-triggered state updates |
sigil for inline templates | Valid for small components |
hooks | Correct lifecycle pattern for auth/setup |
| PubSub broadcasts in handle_info | Standard real-time communication pattern |
Testing
| Pattern | Why It's Valid |
|---|---|
without message | ExUnit provides clear diff output |
block for test context | Standard ExUnit fixture pattern |
blocks for grouping | Idiomatic test organization |
pipeline in controller tests | Phoenix test helper convention |
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
Pattern Matching
Flag missing pattern match ONLY IF ALL of these are true:
- Function receives structured data that should be destructured
- Not a pass-through function that forwards data unchanged
- Pattern match would prevent actual runtime errors
- Not a GenServer callback with standard signature
Process Architecture
Flag missing supervision ONLY IF:
- Process is long-lived (not a Task)
- Crash would affect system stability
- No supervisor already manages this process
- Not a test-only process
Error Handling
Flag missing error handling ONLY IF:
- No
clause handles the error casewith - No supervision tree restarts the process
- The error would cascade beyond the current process
- User needs specific feedback for this error type
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