How to Run an AI Coding Agent Until Tests Pass
Use a terminal AI coding agent to write, run project checks, review blockers, and fix code until the verification gate passes or a safety limit stops the Loop.
> Why one coding-agent turn is not enough
A coding agent can edit the right files and still stop before the repository is ready. Tests may fail, a formatter may reject the change, or a read-only reviewer may find a blocker that the writer missed.
Wukong Code treats completion as a loop instead of a final sentence from the model: keep one goal fixed, make a change, run the project checks, review the result, and feed any blocking evidence into the next iteration.
> Run the Loop from the terminal
Install Wukong, configure your model provider, then give the headless Loop a concrete acceptance target. The objective should describe the result you want, not merely ask the agent to inspect the problem.
curl -fsSL https://wukong.today/install.sh | sh
wukong provider
wukong loop "fix all failing tests" --max-iterations 5- [+]Use --max-iterations to set an explicit per-run budget. The default is 10 iterations.
- [+]Use --model and --review-model when the writer and reviewer should use different configured model aliases.
- [+]Use --dry-run to inspect the writer model, reviewer model, goal, and limits before the Loop starts.
> Run the same workflow in the TUI
The interactive TUI exposes the same local Loop with commands for status and cancellation. You stay in control while Wukong carries failed checks and reviewer blockers into the next turn.
wukong
/loop fix all failing tests
/loop status
/loop stop> What counts as done
The writing agent does not decide that its own work is complete. Wukong runs the repository checks it can discover and then asks a fresh, read-only reviewer to evaluate the current workspace. Blocking evidence prevents completion and becomes input to the next iteration.
A Loop ends with PASS when the delivery gate accepts the current change, NEEDS_WORK when a blocker or no-progress condition remains, or ERROR when the runtime, provider, or check infrastructure cannot produce a trustworthy result.
- [+]PASS exits with code 0.
- [+]NEEDS_WORK exits with code 1 and keeps the remaining blocker visible.
- [+]ERROR exits with code 2; an interrupted process exits with code 130.
> Know the boundary
This is a local, process-owned coding loop, not a cloud daemon. Closing the process stops it. Iteration limits, reviewer step and time limits, cancellation, and no-progress detection are intentional safety boundaries rather than hidden usage quotas.
For jobs that wait on an external CI system, --every can add a minimum delay between iterations. It remains owned by the active Goal and is cancelled when the Loop passes, stops, or is interrupted.
> Related guides
Try the workflow in your repository
Wukong Code is free and BYOK for macOS, Linux, and Windows.
[DOWNLOAD_WUKONG]