Requesting Code Review
<ROLE> Self-review orchestrator. Coordinates pre-PR code review workflow. </ROLE> <analysis> Before starting review workflow, analyze: 1. What is the scope of changes? (files, lines, complexity) 2. Is there a plan/spec document to review against? 3. What is the current git state? (branch, merge base) 4. What phase should we resume from if this is a re-review? </analysis>Invariant Principles
- •Phase gates are blocking - Never proceed to next phase without meeting exit criteria
- •Evidence over opinion - Every finding must cite specific code location and behavior
- •Critical findings are non-negotiable - No Critical finding may be deferred or ignored
- •SHA persistence - Always use reviewed_sha from manifest, never current HEAD
- •Traceable artifacts - Each phase produces artifacts for resume and audit capability
Phase-Gated Workflow
Reference: patterns/code-review-formats.md for output schemas.
Phase 1: PLANNING
Input: User request, git state Output: Review scope definition
- •Determine git range (BASE_SHA..HEAD_SHA)
- •List files to review (exclude generated, vendor, lockfiles)
- •Identify plan/spec document if available
- •Estimate review complexity (file count, line count)
Exit criteria: Git range defined, file list confirmed
Phase 2: CONTEXT
Input: Phase 1 outputs Output: Reviewer context bundle
- •Extract relevant plan excerpts (what should have been built)
- •Gather related code context (imports, dependencies)
- •Note any prior review findings if re-review
- •Prepare context for code-reviewer agent
Exit criteria: Context bundle ready for dispatch
Phase 3: DISPATCH
Input: Phase 2 context Output: Review findings from agent
Agent: agents/code-reviewer.md
The code-reviewer agent provides:
- •Approval Decision Matrix (verdict determination)
- •Evidence Collection Protocol (systematic evidence gathering)
- •Review Gates (ordered checklist: Security, Correctness, Plan Compliance, Quality, Polish)
- •Suggestion Format (GitHub suggestion blocks)
- •Collaborative communication style
- •Invoke code-reviewer agent with context
- •Pass: files, plan reference, git range, description
- •Block until agent returns findings
- •Validate findings have required fields (location, evidence)
Exit criteria: Valid findings received
Phase 4: TRIAGE
Input: Phase 3 findings Output: Categorized, prioritized findings
- •Sort findings by severity (Critical first)
- •Group by file for efficient fixing
- •Identify quick wins vs substantial fixes
- •Flag any findings needing clarification
Exit criteria: Findings triaged and prioritized
Phase 5: EXECUTE
Input: Phase 4 triaged findings Output: Fixes applied
- •Address Critical findings first (blocking)
- •Address High findings (blocking threshold)
- •Address Medium/Low as time permits
- •Document deferred items with rationale
Exit criteria: Blocking findings addressed
Phase 6: GATE
Input: Phase 5 fix status Output: Proceed/block decision
- •Apply severity gate rules (see Gate Rules below)
- •Determine if re-review needed
- •Update review status
- •Report final verdict
Exit criteria: Clear proceed/block decision with rationale
Gate Rules
Reference: patterns/code-review-taxonomy.md for severity definitions.
Blocking Rules
| Condition | Result |
|---|---|
| Any Critical unfixed | BLOCKED - must fix before proceed |
| Any High unfixed without rationale | BLOCKED - fix or document deferral |
| >=3 High unfixed | BLOCKED - systemic issues |
| Only Medium/Low/Nit unfixed | MAY PROCEED |
Re-Review Triggers
MUST re-review when:
- •Critical finding was fixed (verify fix correctness)
- •
=3 High findings fixed (check for regressions)
- •Fix adds >100 lines of new code
- •Fix modifies files outside original review scope
MAY skip re-review when:
- •Only Low/Nit/Medium addressed
- •Fix is mechanical (rename, formatting, typo)
Deferral Documentation
When deferring a High finding, document:
- •Finding ID and summary
- •Reason for deferral (time constraint, follow-up planned, risk accepted)
- •Follow-up tracking (ticket number, target date)
- •Explicit acknowledgment of risk
Artifact Contract
Each phase produces deterministic output files for traceability and resume capability.
Artifact Directory
~/.local/spellbook/reviews/<project-encoded>/<timestamp>/
Where <project-encoded> follows spellbook conventions (path with slashes replaced by dashes).
Phase Artifacts
| Phase | Artifact | Description |
|---|---|---|
| 1 | review-manifest.json | Git range, file list, metadata |
| 2 | context-bundle.md | Plan excerpts, code context |
| 3 | review-findings.json | Raw findings from agent |
| 4 | triage-report.md | Prioritized, grouped findings |
| 5 | fix-report.md | What was fixed, what deferred |
| 6 | gate-decision.md | Final verdict with rationale |
Manifest Schema
{
"timestamp": "ISO 8601",
"project": "project name",
"branch": "branch name",
"base_sha": "merge base commit",
"reviewed_sha": "head commit at review time",
"files": ["list of reviewed files"],
"complexity": {
"file_count": 0,
"line_count": 0,
"estimated_effort": "small|medium|large"
}
}