跪拜 Guibai
← All articles
AI Coding · Claude

Designing AI Coding Loops That Actually Converge

By plainGeek ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Most AI coding workflows stall because developers give feedback like "make it better" and let the same model grade its own work. This method replaces that with a mechanical review loop that any team can script, cutting the iteration tax that makes autonomous coding feel like babysitting.

Summary

A login module build shows how to design a coding loop that avoids the three classic failure modes: false passes, endless refactoring, and structural drift. The core mechanism is three cards—pass criteria, feedback format, and stop conditions—each defined before generation begins. Pass criteria must be machine-verifiable (compilation, state observation, persistence tests), never adjectives like "good." Feedback must cite file, line, problem, and severity so the agent knows exactly what to fix. Stop conditions combine a quality gate, a convergence check, and a hard round limit so the loop always terminates. An independent review agent, not the generating agent, judges compliance to prevent self-grading blind spots. A tiered deliverable checklist locks core file structure while allowing justified additions, stopping the structural drift that makes each round a rewrite of the last.

Takeaways
Pass criteria must be verifiable—compilation commands, state checks, persistence tests—never adjectives like "good" or "robust."
Feedback to the AI needs a file location, a specific problem, and a severity level; vague feedback causes the agent to spin on the same issue.
Stop conditions combine three rules: all criteria met, two consecutive rounds with no new issues, or a hard cap of five rounds.
An independent review agent must judge output, because a generating agent checking its own work has fixed blind spots and produces false passes.
A deliverable checklist with core required files plus optional justified additions prevents structural drift without over-constraining the agent.
Calibration means running the loop and fixing the design where it breaks—tightening criteria, separating review, or lowering the bar—rather than blaming the agent.
Conclusions

The self-review blind spot is the same failure mode as letting a student grade their own exam; separating generation and review is the cheapest way to raise output quality without touching the model.

Structural drift—where each round rearranges the codebase—is a convergence killer that most loop designs ignore, but a simple file checklist stops it.

The calibration mindset flips the typical debugging instinct: when the loop fails, the design is wrong, not the AI. The criteria contain clauses the model cannot satisfy, and those clauses need rewriting.

Concepts & terms
Loop Engineering
A paradigm where developers design autonomous coding loops with pre-defined pass criteria, structured feedback, and termination conditions, rather than prompting AI step by step.
False Pass
When an AI agent claims its output meets all criteria but a human reviewer can see obvious flaws—typically caused by loose criteria or self-review.
Structural Drift
A failure mode in iterative AI coding where each round rearranges the file structure or architecture, causing the agent to refactor endlessly instead of converging on a solution.
Independent Review Agent
A separate AI instance that judges the output of a generating agent against fixed criteria, avoiding the blind spots inherent in self-assessment.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗