Overview
The loop runs four steps per iteration:- Implement — An agent writes code (preferably Codex).
- Validate — An agent runs tests independently to verify correctness.
- Review — Two agents review the code in parallel (Claude + Codex).
- ReviewFix — An agent addresses all review issues.
maxIterations is hit.
Minimal Example
The ValidationLoop Component
This is the core pattern. Each step is its own component with an MDX prompt and Zod schema:Parallel Multi-Agent Review
The Review component runs Claude and Codex in parallel. Using two different models catches more issues than a single reviewer. UsecontinueOnFail so one reviewer timing out does not block the other:
Feeding Review Feedback Back to Implement
On subsequent iterations, the Implement component reads previous review issues and validation failures, then passes them to the agent so it knows what to fix:ReviewFix with skipIf
The ReviewFix component only runs if there are actual issues to fix. If both reviewers approved, it is skipped entirely:Why This Pattern Works
- Validation before review — No point reviewing code that does not compile or pass tests. If validation fails, the loop skips review and goes straight back to implement.
- Parallel review — Two different models catch different kinds of issues. Claude is strong on architecture and logic; Codex is strong on code correctness and edge cases.
- Structured issues — Review output uses a typed
issuesarray with severity, file, and description. This lets ReviewFix address each issue systematically. - Bounded iterations —
maxIterationsprevents infinite loops. UseonMaxReached: "return-last"to accept the best effort after the cap. - Resumable — Every step persists to SQLite. If the workflow crashes mid-loop, it resumes from the last incomplete task.
Next Steps
- Ralph Component — All Ralph props and iteration semantics.
- Dynamic Tickets — Generate tickets dynamically instead of hardcoding.
- Model Selection — Which models to use for each step.
- Patterns — Project structure and naming conventions.