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:
git status --porcelain
Decision:
- If changes exist: Review uncommitted changes via
git diff HEAD (staged + unstaged)
- If no changes: Review latest commit via
git log -1 and git show HEAD
- If user specified a commit hash: Review that commit via
git show <hash>
Empty diff guard: If no diff output is produced, report "No changes to review" and stop.
2. Exclusion Patterns
Filter out the following from diff analysis and agent prompts:
- Lock files:
package-lock.json, pnpm-lock.yaml, yarn.lock, go.sum, Cargo.lock
- Generated/build:
dist/, build/, *.generated.*, *.min.*
- Source maps:
*.map
- Binary/media: images, fonts, compiled artifacts
Use git diff HEAD -- . ':!package-lock.json' ':!pnpm-lock.yaml' ':!yarn.lock' ':!go.sum' ':!Cargo.lock' ':!dist' ':!build' to exclude these.
3. 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, *.proto, API route files)
- Configuration files (
package.json, go.mod, pyproject.toml, Cargo.toml, build.gradle, docker-compose.yml)
- Infrastructure files (
*.tf, Dockerfile, K8s manifests, CI/CD configs)
- Security-sensitive files (
auth/, **/middleware/auth*, *.pem, *.key)
- New directories or modules
4. Invoke code-reviewer Agent
Always execute using Task tool with subagent_type: "code-reviewer":
Provide structured context to avoid redundant discovery:
## Review Context
- **Target**: {uncommitted changes / commit <hash>}
- **Work Type**: {feature/bugfix/refactor/chore/prototype}
- **Commit Message**: {message from git log or commit_message.md}
## Scope Boundary
Architecture concerns (component boundaries, module coupling, system scalability, deployment architecture) are out of scope. Do NOT review these.
## Diff
{see diff size rules below}
Diff size rules:
- ≤ 500 lines: Include full diff inline
- > 500 lines: Include
git diff --stat summary only, and instruct: "Read specific files using Read tool as needed for detailed review."
5. 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, .proto, api/, routes |
+2 |
| Database Schema |
Modified: migrations, schema files, ORM models |
+2 |
| Config/Infrastructure |
Modified: docker-compose, Dockerfile, K8s, CI/CD, .tf |
+1 |
| Dependency Changes |
Modified: package.json, go.mod, requirements.txt |
+1 |
| Security-Sensitive |
Modified: auth/, middleware/auth*, *.pem, *.key |
+2 |
Decision:
- Score < 3 → Invoke
code-reviewer only
- Score ≥ 3 → Invoke both
code-reviewer and architect-reviewer in parallel (two Task calls in one message)
architect-reviewer structured context:
## Review Context
- **Target**: {uncommitted changes / commit <hash>}
- **Work Type**: {feature/bugfix/refactor/chore/prototype}
- **Commit Message**: {message}
- **Scope Score**: {score} (triggered: {list of criteria met})
- **Key Change Areas**: {directories/modules with most impact}
## Scope Boundary
Line-level code quality (naming, formatting, individual function logic, test coverage) is out of scope. Do NOT review these.
## Diff
{same diff size rules as code-reviewer}
Error Handling
- Empty diff → Report "No changes to review" and stop
- Git command failure → Report the error with the failed command
- Agent failure → Include partial results from successful agent + note which agent failed
- Agent reports no issues → Include "No issues found" in the relevant section
Output Format
Generate consolidated review summary:
# 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}
### Warning (Should Fix)
- [ ] {issue 3}
### Suggestion (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
# Review uncommitted changes
/code-review
# Review specific commit (pass commit hash in conversation)
# User: "Review commit abc123"
# Then: /code-review
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: code-review-1393description: Review current git changes or latest commit using code-reviewer and architect-reviewer agents. Use after completing code changes to get comprehensive quality feedback. Use when this capability is needed.4---56# Code Review Command78## Purpose910Perform comprehensive code review of current changes or latest commit. Automatically invokes:1112- **code-reviewer agent**: Always (code quality, security, maintainability)13- **architect-reviewer agent**: Conditionally (architectural impact assessment)1415---1617## Workflow1819### 1. Determine Review Target2021**Check for uncommitted changes:**2223```bash24git status --porcelain25```2627**Decision:**2829- If changes exist: Review uncommitted changes via `git diff HEAD` (staged + unstaged)30- If no changes: Review latest commit via `git log -1` and `git show HEAD`31- If user specified a commit hash: Review that commit via `git show <hash>`3233**Empty diff guard:** If no diff output is produced, report "No changes to review" and stop.3435### 2. Exclusion Patterns3637Filter out the following from diff analysis and agent prompts:3839- Lock files: `package-lock.json`, `pnpm-lock.yaml`, `yarn.lock`, `go.sum`, `Cargo.lock`40- Generated/build: `dist/`, `build/`, `*.generated.*`, `*.min.*`41- Source maps: `*.map`42- Binary/media: images, fonts, compiled artifacts4344Use `git diff HEAD -- . ':!package-lock.json' ':!pnpm-lock.yaml' ':!yarn.lock' ':!go.sum' ':!Cargo.lock' ':!dist' ':!build'` to exclude these.4546### 3. Analyze Change Scope4748**Extract metrics from git output:**4950Count:5152- Files changed53- Lines added/removed54- Directories affected55- New files vs modifications5657Detect:5859- Database migration files (`migrations/`, `schema.prisma`, `*.sql`)60- API contract files (`*.graphql`, `openapi.yaml`, `*.proto`, API route files)61- Configuration files (`package.json`, `go.mod`, `pyproject.toml`, `Cargo.toml`, `build.gradle`, `docker-compose.yml`)62- Infrastructure files (`*.tf`, `Dockerfile`, K8s manifests, CI/CD configs)63- Security-sensitive files (`auth/`, `**/middleware/auth*`, `*.pem`, `*.key`)64- New directories or modules6566### 4. Invoke code-reviewer Agent6768**Always execute using Task tool with subagent_type: "code-reviewer":**6970Provide structured context to avoid redundant discovery:7172```73## Review Context7475- **Target**: {uncommitted changes / commit <hash>}76- **Work Type**: {feature/bugfix/refactor/chore/prototype}77- **Commit Message**: {message from git log or commit_message.md}7879## Scope Boundary8081Architecture concerns (component boundaries, module coupling, system scalability, deployment architecture) are out of scope. Do NOT review these.8283## Diff8485{see diff size rules below}86```8788**Diff size rules:**8990- **≤ 500 lines**: Include full diff inline91- **> 500 lines**: Include `git diff --stat` summary only, and instruct: "Read specific files using Read tool as needed for detailed review."9293### 5. Conditional architect-reviewer Invocation9495**Scope Classification Criteria** (score each criterion met):9697| Criterion | Threshold | Score |98| --------------------- | ----------------------------------------------------- | ----- |99| Files Modified | ≥ 8 files | +1 |100| Total Lines Changed | ≥ 300 lines | +1 |101| Directories Affected | ≥ 3 directories | +1 |102| New Module/Package | New directory with ≥3 files | +1 |103| API Contract Changes | Modified: schema/, .graphql, .proto, api/, routes | +2 |104| Database Schema | Modified: migrations, schema files, ORM models | +2 |105| Config/Infrastructure | Modified: docker-compose, Dockerfile, K8s, CI/CD, .tf | +1 |106| Dependency Changes | Modified: package.json, go.mod, requirements.txt | +1 |107| Security-Sensitive | Modified: auth/, middleware/auth*, *.pem, \*.key | +2 |108109**Decision**:110111- **Score < 3** → Invoke `code-reviewer` only112- **Score ≥ 3** → Invoke both `code-reviewer` and `architect-reviewer` **in parallel** (two Task calls in one message)113114**architect-reviewer structured context:**115116```117## Review Context118119- **Target**: {uncommitted changes / commit <hash>}120- **Work Type**: {feature/bugfix/refactor/chore/prototype}121- **Commit Message**: {message}122- **Scope Score**: {score} (triggered: {list of criteria met})123- **Key Change Areas**: {directories/modules with most impact}124125## Scope Boundary126127Line-level code quality (naming, formatting, individual function logic, test coverage) is out of scope. Do NOT review these.128129## Diff130131{same diff size rules as code-reviewer}132```133134---135136## Error Handling137138- **Empty diff** → Report "No changes to review" and stop139- **Git command failure** → Report the error with the failed command140- **Agent failure** → Include partial results from successful agent + note which agent failed141- **Agent reports no issues** → Include "No issues found" in the relevant section142143---144145## Output Format146147**Generate consolidated review summary:**148149```markdown150# Code Review Report151152**Generated**: {timestamp}153**Scope**: {uncommitted changes / latest commit: {hash}}154**Files Changed**: {count}155**Reviewers Invoked**: code-reviewer{, architect-reviewer if applicable}156157---158159## 📊 Change Summary160161- **Lines**: +{added} -{removed}162- **Files**: {count} ({new_count} new, {modified_count} modified)163- **Directories**: {affected directories}164165---166167## 🔍 Code Reviewer Feedback168169{consolidated output from code-reviewer agent}170171---172173## 🏗️ Architecture Reviewer Feedback174175{if invoked, consolidated output from architect-reviewer agent}176{if not invoked, state: "Architectural review not required for this change scope"}177178---179180## ✅ Review Checklist181182Based on agent feedback, generate action items:183184### Critical (Must Fix)185186- [ ] {issue 1}187- [ ] {issue 2}188189### Warning (Should Fix)190191- [ ] {issue 3}192193### Suggestion (Consider)194195- [ ] {improvement 1}196197---198199## 📝 Next Steps200201{recommended actions based on review results}202```203204---205206## Important Notes207208- **Never modify code directly** - this command only performs review209- **Agent autonomy**: code-reviewer and architect-reviewer may read files, run tests, or analyze dependencies as needed210- **Coding guidelines**: code-reviewer checks for coding standard violations211- **Incremental reviews**: For large changes (>20 files), agents may focus on high-impact areas first212- **Git safety**: All git commands are read-only (status, diff, log, show)213214---215216## Example Usage217218```bash219# Review uncommitted changes220/code-review221222# Review specific commit (pass commit hash in conversation)223# User: "Review commit abc123"224# Then: /code-review225```226227---228> Converted and distributed by [TomeVault](https://tomevault.io/claim/kubrickcode) — claim your Tome and manage your conversions.229<!-- tomevault:4.0:skill_md:2026-04-13 -->