Perform a comprehensive code review workflow on the current branch changes.
Arguments
- •
$ARGUMENTS: Base branch to compare against (default:master)- •Example:
/code-review mainor/code-review develop
- •Example:
Workflow Steps
Step 1: Gather Business Context
- •
Read context file (if exists):
- •Check for
.claude/context.mdin the project root - •This file contains business logic, specs, and system design prepared by the developer
- •Use this context to verify implementation alignment
- •Check for
- •
Scan CLAUDE.md for relevant docs:
- •Read the project's
CLAUDE.md(documentation TOC) - •Based on the changed files/features, identify relevant docs mentioned
- •Read those docs to understand related requirements and design decisions
- •Read the project's
- •
Check for testing philosophy (if test files changed):
- •Look for
docs/rails_testing_philosophy.mdin the project root - •If found, read it and use as additional criteria for reviewing test changes
- •Apply these project-specific testing standards alongside general test review
- •Look for
- •
Keep this context in mind for subsequent review steps to verify:
- •Implementation aligns with business requirements
- •Edge cases from specs are handled
- •Design decisions are followed
- •Test changes follow project's testing philosophy (if available)
Step 1.5: Read Reviewer Feedback (if exists)
- •Check for
.claude/reviewer-feedback.md - •If exists:
- •Parse all reviewer items (they have structured format from
/process-reviewer-feedback) - •Store items for merging in Step 3
- •Reviewer items take priority for overlapping concerns
- •Parse all reviewer items (they have structured format from
- •If not exists:
- •Continue with AI-only review (no reviewer feedback to merge)
Step 2: Get the Diff
- •Determine base branch: Use
$ARGUMENTSif provided, otherwisemaster - •Run
git diff <base-branch>...HEADto get all changes on this branch - •If empty, try
git diff HEAD~1for the latest commit - •If still no diff found, STOP and report error:
code
Error: No changes found to review. - No diff between current branch and <base-branch> - No changes in the latest commit Please ensure you have uncommitted or committed changes to review.
Step 3: Code Review & Merge
Apply the review criteria defined in ~/.claude/skills/code-review-criteria.md.
Merging with reviewer feedback (if .claude/reviewer-feedback.md exists):
- •Start with all reviewer items (preserve exactly, mark as
👤 Reviewer) - •Perform AI review and add AI items (mark as
🤖 AI) - •For overlapping concerns (same file/area, similar issue):
- •Keep reviewer's version as primary
- •Add AI's additional context if valuable
- •Mark as
🤖 AI + 👤 Reviewer
- •Number items sequentially within each priority section
Write the review directly to .claude/code-review.md using this structure:
markdown
# Code Review Summary **Branch:** <current-branch> **Base:** <base-branch> **Files Changed:** <count> **Lines:** +<additions> / -<deletions> ## Taste Rating 🟢/🟡/🔴 **<Rating>** - <One line explanation> ## Decision Options - **Accept**: Will fix this issue - **Drop**: Issue is incorrect or not applicable (explain why) - **Won't Fix**: Valid issue but intentionally not addressing (explain why) ## Approach Options - **Suggested fix**: Use the recommended fix as-is - **Alternative**: Your different approach (describe in Notes) --- ## Findings ### 🔴 Blocking (Must Fix) #### 1. `<file_path:line>` - <brief title> - **Source:** 🤖 AI / 👤 Reviewer / 🤖 AI + 👤 Reviewer - **Issue:** <description of the problem> - **Suggestion:** <recommended fix> - **Status:** [ ] Pending - **Decision:** _Accept / Drop / Won't Fix_ - **Approach:** _Suggested fix / Alternative_ - **Notes:** _[Your response, alternative approach details, or discussion points]_ --- ### 🟡 Important (Should Fix) #### 1. `<file_path:line>` - <brief title> - **Source:** 🤖 AI / 👤 Reviewer / 🤖 AI + 👤 Reviewer - **Issue:** <description> - **Suggestion:** <recommended fix> - **Status:** [ ] Pending - **Decision:** _Accept / Drop / Won't Fix_ - **Approach:** _Suggested fix / Alternative_ - **Notes:** _[Your response, alternative approach details, or discussion points]_ --- ### 🟢 Nit (Nice to Have) #### 1. `<file_path:line>` - <brief title> - **Source:** 🤖 AI / 👤 Reviewer / 🤖 AI + 👤 Reviewer - **Issue:** <description> - **Suggestion:** <recommended fix> - **Status:** [ ] Pending - **Decision:** _Accept / Drop / Won't Fix_ - **Approach:** _Suggested fix / Alternative_ - **Notes:** _[Your response, alternative approach details, or discussion points]_ --- ### 💡 Suggestions #### 1. `<file_path:line>` - <brief title> - **Source:** 🤖 AI / 👤 Reviewer / 🤖 AI + 👤 Reviewer - **Issue:** <description> - **Suggestion:** <recommended fix> - **Status:** [ ] Pending - **Decision:** _Accept / Drop / Won't Fix_ - **Approach:** _Suggested fix / Alternative_ - **Notes:** _[Your response, alternative approach details, or discussion points]_ --- ## 🔗 Issue Relationships <!-- Added by Step 3.5 - see that step for format --> --- ## Verdict ✅/❌ **<Verdict>** - <Summary explanation> ## Key Insight <One sentence summary of the most important observation>
Step 3.5: Dependency & Conflict Analysis
After generating findings, analyze relationships between issues:
- •Same-location issues: Items targeting the same file/method
- •Cascading fixes: Fixing one issue may resolve another
- •Conflicting solutions: Fixes that contradict or interfere with each other
- •Merge candidates: Issues that should be addressed together
Add this section to .claude/code-review.md before Verdict:
markdown
--- ## 🔗 Issue Relationships ### Cascading Fixes <!-- Issues where fixing one resolves another --> - **#X resolves #Y**: <explanation> ### Conflicts <!-- Fixes that may interfere with each other --> - **#X vs #Y**: <describe conflict and recommended resolution> ### Same-Location Changes <!-- Issues modifying the same code area - coordinate fixes --> - **#X, #Y, #Z** (`file:lines`): <coordination notes> ### Recommended Fix Order <!-- Optimal sequence considering dependencies --> 1. #X - <reason> 2. #Y - <reason>
If no relationships found, add:
markdown
## 🔗 Issue Relationships No dependencies or conflicts detected between findings.
Step 4: Commit Review
- •
Stage the review file:
codegit add .claude/code-review.md
- •
Commit with message:
codeAdd code review for <current-branch>
Output Files
- •
.claude/code-review.md- Code review with actionable findings