About the build
I got tired of being the loop.
You know the rhythm. Ask for a feature. Run it. Paste the traceback back in. Run it again. Squint at the diff. Decide — on no particular basis — that this is probably fine. Then discover two versions ago was better and you didn't keep it.
I was doing that by hand, badly, several times a week. The model wasn't the bottleneck. I was — specifically the part of me deciding when something was done, which turned out to correlate mostly with how tired I was.
The why
Self-review is the part that doesn't work.
You can already ask a model to critique its own output. It will. It'll even sound rigorous. But it's grading in the same context that produced the work, which makes it agreeable in exactly the way a reviewer must not be. Ask twice and it starts defending itself.
So the design question wasn't "how do I loop an LLM." It was: which decisions must the model never make? Three of them, it turned out. Whether the code runs — that's tests and lint, deterministic, no opinion involved. Whether the code is any good — that needs a reviewer with no memory of writing it. And whether to stop — that's arithmetic, and it belongs in Python where I can read it.
What's left for the model is the part it's actually good at: writing the thing.
Timeline
Six months, one near-death.
-
February 2026
The itch
Noticed I'd rebuilt the same manual loop three times in a week for three different projects. Wrote maybe forty lines of shell to automate it, which worked exactly until the first failing test.
-
March 2026
Spec before code
Wrote the whole design down first — invariants, stop rules, failure table, the lot. Partly discipline, mostly because I'd already learned that "I'll figure out the loop as I go" is how you end up with a loop that never exits.
-
April 2026
v1: the happy path
One builder, one critic, gates in between, five rounds max. It worked on the first real idea I gave it, which should have made me suspicious sooner than it did.
-
May 2026
The month the gates lied
Watched a round fail on an assertion whose source code said something different from the error message. pytest caches rewritten assertions keyed on file mtime and size — and a builder rewriting a same-size file inside one second gets graded on stale bytecode. The one component I'd called "deterministic ground truth" had been quietly wrong. That was a bad evening. It's a one-line fix and a permanent lesson: the thing you trust most is the thing you should test hardest.
-
June 2026
The tournament
One sequential guess per round became N candidates racing in isolated git worktrees. First attempt ran three identical prompts and picked between three identical answers — technically best-of-N, practically pointless. Giving each candidate a different emphasis is what made it work.
-
July 2026
Testing the untestable, then docs
Built a fake Claude CLI that speaks the real JSON envelope and hands each candidate deliberately different quality, so winner selection could be asserted rather than believed. Twenty-four tests, CI, and the writing you are currently reading.
-
October 2026
2.1: runs you can watch — and a demo that can't cost you
Every run now leaves a self-contained
RUN_REPORT.html, and--demoplays a whole tournament offline against a scripted critic. Its review caught the sharpest bug of the release: the first version found the fake throughPATH, so on a host with a non-executable temp directory a "simulated" run quietly fell through to the real, billed CLI. The demo now launches the fake by absolute path — nothing left to look up — and a test puts a booby-trappedclaudefirst onPATHto prove it.
Interesting problems
The parts that were actually hard.
Solved by making them impossible
Three candidates editing the same files, one has to win. Rather than merging, every candidate branches from trunk's current commit and trunk doesn't move during the round — so the winner is always a fast-forward. No conflict can exist. A test asserts trunk's history stays a straight line, because a tournament that silently merged everyone would still look green.
Parallel builds, serial git
Worktrees keep separate indexes but share one object store and one set of refs. So the builds run in parallel and the controller's own git calls take a lock. The long part is parallel; the millisecond part is safe.
Don't review broken code
Critiquing a build that fails its own tests wastes a call on feedback the gates already gave you for free. Red gates skip the critic entirely and the failure output becomes the next round's brief. With N candidates that saving multiplies.
Minimum, not average
A round scores the lowest of its five dimensions. Averaging lets gorgeous code with hollow tests coast to a pass — and hollow tests were the exact failure mode I was most worried about. A chain is as strong as its weakest link.
N>1 bought fault tolerance free
In v1 a single builder error killed the run. Now a dead candidate is just dropped and the round continues on whoever survived. Only a round where every candidate dies ends things. That wasn't the goal of the tournament — it fell out of it.
Never point at a ref that isn't there
A run that died inside the builder never reached its commit, so the
best tag had nothing to point at — and the report cheerfully
told you to check it out anyway. Now termination verifies the ref exists
and says plainly when there's nothing to see.
Proof
It passed both gates. The critic still gave it 3/10.
All of the above is design talk until you run it. So here's a real run, recorded: build an expense tracker, one candidate, three-dollar cap.
Round 1 gates 2/2 pass min score 3/10 13 must_fix $1.6042
Round 2 gates 2/2 pass min score 6/10 9 must_fix $1.5162
stop reason : budget ($3.1204 over the $3.00 cap)
best : round 2
Round one was green on pytest and ruff and still
drew thirteen blocking defects. The best of them:
-
if amount <= 0doesn't reject NaN or Infinity — every NaN comparison is False, andinf <= 0is False. Soadd nan foodwas quietly accepted. -
save_expenses()truncated the file before writing. A crash mid-dump would take every recorded expense with it. -
return 1was unreachable, becauseadd_subparsers(required=True)makes argparse exit first. -
And it reviewed the tests just as hard:
assert 'Error' in stderrwould pass on any error text at all.
Round two fixed them — math.isfinite, atomic temp-file writes,
allow_nan=False, tests from 14 to 26 — and scored 6. Then the
critic found new, deeper problems in the revision: NaN literals
sneaking back in through json.loads() on the read path, float
rounding losing sub-cent amounts.
That last part matters most. It didn't run out of things to say, and it didn't start agreeing with itself — which is exactly what a model reviewing its own work does. The full run is recorded here.
Tech stack
And why each one.
claude -p gives a real agent with real tools behind a JSON envelope reporting cost, turns and errors — a subprocess I can supervise instead of an API I'd have to build an agent on top of.
Links
See it for yourself.
Want to build something — or break something interesting?
I like both. If you've got a problem that looks like magic in a notebook and falls apart in production, that's roughly my favourite genre.