Run an AI Coding Agent Until Checks Pass—or It Stops Clearly
Use a terminal AI coding agent to write, run project checks, review blockers, and fix code until an evidence-backed Gate returns PASS or a clear non-PASS result.
> 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 preview a concrete acceptance target with --dry-run. Review the proposed current workspace, checks or versioned no-check decision, limits, Gate approval, and provider destination before any headless Loop starts.
curl -fsSL https://wukong.today/install.sh | sh
wukong provider
wukong loop "fix all failing tests" --max-iterations 5 --dry-run
# Review “Headless start flags”, then rerun the same command with those exact flags.- [+]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.
- [+]A bare headless command fails closed when required approvals are missing. --yes, Auto, or YOLO do not replace the workspace-specific flags printed by dry-run.
> 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 pause
/loop stop> What counts as done
The writing agent does not decide that its own work is complete. Wukong evaluates the current workspace with the frozen required checks—or an eligible, explicitly approved no-check decision—bounded risk evidence, and a fresh read-only reviewer. Incomplete or stale evidence cannot produce PASS.
A completed Gate ends with PASS when complete, fresh evidence satisfies the frozen Finish Line, NEEDS_WORK when a blocker or no-progress condition remains, or ERROR when the runtime, provider, permission, record, or check infrastructure cannot produce a trustworthy result. PAUSED and STOPPED_BY_USER are separate lifecycle results, not Gate verdicts.
- [+]PASS exits with code 0.
- [+]NEEDS_WORK exits with code 1 and keeps the remaining blocker visible.
- [+]ERROR exits with code 2; a headless interruption reports STOPPED_BY_USER and exits with code 130.
- [+]TUI Ctrl-C or /loop pause records resumable PAUSED; /loop stop records STOPPED_BY_USER and discards that Loop contract.
> Know the boundary
This is a local coding Loop, not a hosted daemon or a promise that every task will pass. Iteration, provider-call, optional token, reviewer, permission, cancellation, and no-progress limits can end with a clear non-PASS result instead of continuing indefinitely.
Wukong can recover the last provable durable state after a crash, but it will not blindly retry when a provider request outcome is unknown. Inspect the retained workspace changes and the reported next action before continuing.
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]