Skip to main content
Goal: Have the AI review its own work holistically before the human reviews it.

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

Please perform a comprehensive self-review of all changes:

1. List all files modified
2. For each file, identify:
   - Potential issues or gaps
   - Missing error handling
   - Edge cases not covered
   - Code quality concerns

3. Assign priority scores (0-10) to each issue:
   - 9-10: Critical, must fix
   - 6-8: Important, should fix
   - 3-5: Nice to have
   - 0-2: Optional polish

4. Give an overall quality score (0-100) for the implementation

5. List anything that deviates from our original plan

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
⚠️ Important Issues (6-8 priority)
  • Missing input validation
  • Incomplete error handling
  • Performance concerns
  • Missing edge case handling
✨ Nice to Have (3-5 priority)
  • 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:
  1. Acknowledge: “I see the issue with [X]”
  2. Plan: “Here’s how I’ll fix it: [approach]”
  3. Approve: You review the plan
  4. Implement: AI makes the fix
  5. Verify: Confirm the fix works
Don’t batch-fix everything at once: Review plan for each high-priority issue individually.

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
Phase 2: Automated Cleanup (Low-level)
  • 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

Now that the structure is solid, please run a cleanup pass:

1. Run the linter and fix all warnings
2. Run type checking and fix all errors
3. Remove unused imports
4. Format code to match project style
5. Remove debug statements and console.logs

Quality Score Interpretation

90-100: Excellent

Ready for human review, minimal issues expected

75-89: Good

Some issues identified, addressable quickly

60-74: Needs Work

Significant gaps, requires attention before human review

Below 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.