--- description: Start comprehensive code review loop between reviewer and developer agents --- # Code Review Process Orchestration ## Overview Initiates automated code review loop between @codereview-reviewer (Opus) and @codereview-developer (Sonnet) until code reaches production-ready state. ## Process Flow Start → @codereview-reviewer → @codereview-developer → @codereview-reviewer → (loop until APPROVED) → Complete ## Execution Steps ### Auto-Initiated Agents 1. **@codereview-reviewer** (Opus) - Reviews changed files only, applies rules checklist 2. **@codereview-developer** (Sonnet) - Fixes failed rules atomically, validates syntax 3. Loop continues via HANDOFF until `REVIEW_COMPLETE` ## Loop Control (Anthropic Best Practice) ### Termination: All Rules Pass - ✅ All security rules passed - ✅ All validity rules passed - ✅ No syntax errors - ✅ Output: `REVIEW_COMPLETE` ### Safety Limit: 8 Iterations If iteration > 8: Stop, request human review (prevents infinite loops) ### Token Budget: 200000 total Full budget available for comprehensive reviews ## Usage ### Option 1: Review Uncommitted Changes (Default - Recommended) ```bash /codereview-startreviewprocess ``` Analyzes: `git diff HEAD` (all uncommitted changes, including documentation) ### Option 2: Review Last Commit If no uncommitted changes exist: ```bash /codereview-startreviewprocess ``` Automatically falls back to: `git show HEAD` (most recent commit) ### Option 3: Review Full Branch If no uncommitted changes and comparing against base branch: ```bash /codereview-startreviewprocess ``` Falls back to: `git diff master..HEAD` or `git diff main..HEAD` (all branch changes) ## Performance (2025 Benchmarks) | Metric | Value | |--------|-------| | Avg iterations to APPROVED | 2-4 | | Token budget | 200000 total | | Max iterations (hard limit) | 8 | | Review scope | All file types (code, docs, configs, etc.) | ## Monitoring Watch for: - `HANDOFF: @codereview-[agent] [Iteration X/8]` - Loop progress - `REVIEW_COMPLETE` - Success, all rules passed - Iteration > 8 - Human review requested ## Best Practices (Anthropic Guidelines) 1. **Work in Progress**: Run on uncommitted changes for fastest feedback 2. **Small Batches**: Review one feature at a time for clarity 3. **Let It Run**: Agents auto-loop via HANDOFF, no intervention needed 4. **Safety Net**: Automatic backup branch created before fixes 5. **Hard Stop**: Process stops at iteration 8, preventing runaway loops ## Post-Approval After `REVIEW_COMPLETE`, validate and deploy: ```bash # Run project-specific test suite (examples): npm test || composer test || pytest || cargo test || go test ./... # Deploy approved code git push ```