Code Review Command
Purpose
Perform comprehensive code review of current changes or latest commit. Automatically invokes:
- •code-reviewer agent: Always (code quality, security, maintainability)
- •architect-reviewer agent: Conditionally (architectural impact assessment)
Workflow
1. Determine Review Target
Check for uncommitted changes:
bash
git status --porcelain
Decision:
- •If changes exist: Review uncommitted changes via
git diff - •If no changes: Review latest commit via
git log -1andgit show HEAD
2. Analyze Change Scope
Extract metrics from git output:
Count:
- •Files changed
- •Lines added/removed
- •Directories affected
- •New files vs modifications
Detect:
- •Database migration files (
migrations/,schema.prisma,*.sql) - •API contract files (
*.graphql,openapi.yaml, API route files) - •Configuration files (
package.json,go.mod,docker-compose.yml) - •New directories or modules
3. Invoke code-reviewer Agent
Always execute using Task tool with subagent_type: "code-reviewer":
code
Perform comprehensive code review of the current changes.
Focus areas:
- Code quality: readability, naming, structure
- Security: exposed secrets, input validation, vulnerability patterns
- Error handling: edge cases, error messages, recovery
- Performance: obvious bottlenecks, inefficient patterns
- Testing: coverage for critical paths
- Coding standards compliance
Changes to review:
{paste git diff or git show output}
Provide feedback organized by:
- Critical issues (must fix before merge)
- Warnings (should fix)
- Suggestions (consider improving)
Include specific code examples and fix recommendations.
4. Conditional architect-reviewer Invocation
Scope Classification Criteria (score each criterion met):
| Criterion | Threshold | Score |
|---|---|---|
| Files Modified | ≥ 8 files | +1 |
| Total Lines Changed | ≥ 300 lines | +1 |
| Directories Affected | ≥ 3 directories | +1 |
| New Module/Package | New directory with ≥3 files | +1 |
| API Contract Changes | Modified: schema/, .graphql, api/, route files | +1 |
| Database Schema | Modified: migrations, schema files, ORM models | +1 |
| Config/Infrastructure | Modified: docker-compose, Dockerfile, K8s, CI/CD | +1 |
| Dependency Changes | Modified: package.json, go.mod, requirements.txt | +1 |
Decision:
- •Score < 3 → Invoke
code-revieweronly - •Score ≥ 3 → Invoke both
code-reviewerandarchitect-reviewer
Output Format
Generate consolidated review summary:
markdown
# Code Review Report
**Generated**: {timestamp}
**Scope**: {uncommitted changes / latest commit: {hash}}
**Files Changed**: {count}
**Reviewers Invoked**: code-reviewer{, architect-reviewer if applicable}
---
## Change Summary
- **Lines**: +{added} -{removed}
- **Files**: {count} ({new_count} new, {modified_count} modified)
- **Directories**: {affected directories}
---
## Code Reviewer Feedback
{consolidated output from code-reviewer agent}
---
## Architecture Reviewer Feedback
{if invoked, consolidated output from architect-reviewer agent}
{if not invoked, state: "Architectural review not required for this change scope"}
---
## Review Checklist
Based on agent feedback, generate action items:
### Critical (Must Fix)
- [ ] {issue 1}
- [ ] {issue 2}
### High Priority (Should Fix)
- [ ] {issue 3}
### Suggestions (Consider)
- [ ] {improvement 1}
---
## Next Steps
{recommended actions based on review results}
Important Notes
- •Never modify code directly - this command only performs review
- •Agent autonomy: code-reviewer and architect-reviewer may read files, run tests, or analyze dependencies as needed
- •Coding guidelines: code-reviewer checks for coding standard violations
- •Incremental reviews: For large changes (>20 files), agents may focus on high-impact areas first
- •Git safety: All git commands are read-only (status, diff, log, show)
Example Usage
bash
# Review uncommitted changes /code-review # Review specific commit (pass commit hash in conversation) # User: "Review commit abc123" # Then: /code-review