Closing the Loop
Before you review the code, the AI must perform a holistic self-review of the entire generated snapshot. Why this works: AI is better at reviewing a finished file than it is at writing it line-by-line.The Self-Review Prompt
Ask the AI to identify gaps, assign priority scores, and provide quality assessments.Example Prompt
What You’re Looking For
🚨 Critical Issues (9-10 priority)- Incorrect API paths or endpoints
- Missing error boundaries
- Security vulnerabilities
- Data integrity risks
- Breaking changes to existing APIs
- Missing input validation
- Incomplete error handling
- Performance concerns
- Missing edge case handling
- Code style improvements
- Better variable names
- Additional comments
- Optimization opportunities
Batching Fixes
High-priority issues identified by the AI are addressed in a mini “plan-and-approve” loop.Fix Protocol
For each critical/important issue:- Acknowledge: “I see the issue with [X]”
- Plan: “Here’s how I’ll fix it: [approach]”
- Approve: You review the plan
- Implement: AI makes the fix
- Verify: Confirm the fix works
Automated Cleanup
Once the structure is sound, direct the AI to run a dedicated pass for low-level cleanup.Two-Phase Polish Approach
Phase 1: Structural Fixes (High-level)- Fix logic errors
- Add missing error handling
- Address architectural issues
- Handle edge cases
- Run linting
- Fix type errors
- Clean up imports
- Format code
Why Separate These?
Mixing them confuses the model:- Structural changes require reasoning
- Linting is mechanical pattern-matching
- Trying to do both simultaneously degrades quality
Cleanup Prompt
Quality Score Interpretation
90-100: Excellent
Ready for human review, minimal issues expected75-89: Good
Some issues identified, addressable quickly60-74: Needs Work
Significant gaps, requires attention before human reviewBelow 60: Major Problems
Stop, reassess the plan, likely need to restart Pro tip: If the AI gives itself 100%, that’s a red flag—it’s being overconfident.Key Principle: Separate high-level structural fixes from low-level linting to avoid confusing the model. Review holistically, then polish systematically.