Code Review
This skill reviews code changes in the current git repository with a fresh context.
Instructions
When this skill is invoked:
- •
Verify git repository: Confirm the current directory is a git repository.
- •
Present diff options menu: Ask the user to select one of these options:
codeSelect diff type to review: 1. Unstaged changes (working directory vs staged/HEAD) 2. Branch changes against local master/main 3. Branch changes against remote origin/master or origin/main
- •
Get the diff based on selection:
- •
Option 1 - Unstaged changes:
bashgit diff
If empty, also check staged changes:
bashgit diff --cached
- •
Option 2 - Branch vs local master/main:
bash# Detect default branch git rev-parse --verify main 2>/dev/null && DEFAULT=main || DEFAULT=master git diff $DEFAULT...HEAD
- •
Option 3 - Branch vs remote master/main:
bash# Fetch latest git fetch origin # Detect default branch git rev-parse --verify origin/main 2>/dev/null && DEFAULT=origin/main || DEFAULT=origin/master git diff $DEFAULT...HEAD
- •
- •
Also gather context:
bash# List changed files git diff --name-only [appropriate args based on selection] # Check for new dependencies git diff [appropriate args] -- package.json Cargo.toml requirements.txt go.mod pom.xml build.gradle Gemfile pyproject.toml # Check for test files in changes git diff --name-only [appropriate args] | grep -E "(test|spec|_test\.|\.test\.)"
- •
Perform the review analyzing the diff for:
Simplification Opportunities
- •Overly complex functions (high cyclomatic complexity)
- •Nested conditionals that could be flattened
- •Repeated code patterns that could be abstracted
- •Functions doing too many things (violating single responsibility)
- •Complex state management that could be simplified
Untested Domain Logic
- •New business logic without corresponding tests
- •Modified logic paths without test coverage
- •Edge cases that should have tests
- •Error handling paths without tests
Documentation Gaps
- •New public APIs without documentation
- •Changed behavior not reflected in README
- •New configuration options undocumented
- •Breaking changes not called out
- •New features missing from docs
New Dependencies
- •List any new packages/libraries added
- •Note the purpose of each new dependency
- •Flag if a dependency seems unnecessary or duplicative
- •Warn about dependencies with known issues or that are unmaintained
- •
Format the review as:
markdown# Code Review Summary **Diff type**: [selected option] **Files changed**: [count] **Insertions/Deletions**: +X / -Y ## 🔧 Simplification Opportunities [List findings or "None identified"] ## 🧪 Untested Domain Logic [List findings or "All new logic appears tested"] ## 📚 Documentation Updates Needed [List findings or "Documentation appears up to date"] ## 📦 New Dependencies [List new deps with notes, or "No new dependencies"] ## General Observations [Any other noteworthy items]
Notes
- •If the diff is very large, focus on the most significant changes
- •For binary files, just note they were changed
- •Be constructive in feedback, not just critical
- •Prioritize findings by impact