Build → critique → rebuild
One idea in, working repo out.
CRUCIBLE runs Claude Code in a loop. Several builders race the same problem, deterministic gates judge the result, a critic that has never seen the build scores it, and plain Python decides whether it's actually done. "Good enough" is a rule here, not a feeling.
The problem
Ask a model if its own code is good and it will tell you yes.
That's the whole trouble with looping an LLM on its own output. It grades its work in the same context that produced it, gets agreeable, and converges on something that reads well and doesn't run. You end up as the loop — pasting errors back in, deciding when to stop, losing track of which version was actually the good one.
CRUCIBLE takes those three jobs away from the model. Tests and lint decide correctness. A separate session with read-only tools and no memory of the build does the reviewing. A controller written in ordinary Python decides when to stop — and it never asks anyone's opinion.
How it works
Every round is a tournament.
N builders fork from the same commit into isolated git worktrees and work in parallel. Each gets a different emphasis, because independent samples of one prompt just cluster around one answer. Only gates-green candidates reach the critic. The winner fast-forwards onto trunk; the losers stay as branches.
trunk @ a1b2c3d
│
┌─────────────┼─────────────┐
▼ ▼ ▼
candidate 1 candidate 2 candidate 3 fresh session each,
straight simplest robustness own worktree, parallel
│ │ │
▼ ▼ ▼
gates ✗ gates ✓ gates ✓ pytest + ruff, by the
│ │ │ controller — never a model
✕ ▼ ▼
not reviewed critic 7/10 critic 9/10 read-only tools, no
│ │ memory of the build
└──────┬──────┘
▼
winner → trunk ff-only, tagged round-N
Fresh context, every round
No --resume. The repo on disk is the state; the prompt carries the idea and the latest feedback. No context rot, and every round debugs independently.
The controller is code
Stop decisions are rules: pass, round cap, stall, budget. First match wins. No model gets a vote on whether it's finished.
The critic is a stranger
Separate invocation, read-only tools, adversarial rubric, and a stronger model than the builder — so it isn't grading its own homework.
Best ≠ last
Every round is a commit and a tag. The run hands back the highest-scoring round, not whatever happened to come out of the final one.
A chain is its weakest link
A round scores min() across correctness, completeness, robustness, code quality and test quality. Brilliant code with hollow tests does not pass.
Losers are kept
Every candidate that ever built survives as a branch. The rejected approach is often the more interesting diff.
The rule, interactive
An average forgives. min() doesn't.
Drag the critic's five scores. A round's score is the lowest of them, and a round passes only when every dimension clears 8. Try making four of them perfect and leaving the tests hollow.
Weakest: robustness at 4. An average would call this 6.0/10 — CRUCIBLE calls it 4, and goes another round.
The gaming problem
Any gate you can automate, a model can satisfy dishonestly.
Tell something to make pytest pass and it can write
assert True and go home. So test_quality is a scored
dimension in its own right, with instructions to cap it at 4 for tests that
are vacuous or tautological. Green tests are necessary. They were never
sufficient.
The gates also run with bytecode caching disabled — because pytest keys its assertion-rewrite cache on file mtime and size, and a builder that rewrites a same-size file inside one second can get graded on stale bytecode. A gate that lies is worse than no gate at all.
New in 2.1
Every run explains itself.
A run now leaves RUN_REPORT.html beside the markdown: one
self-contained page that opens offline, years later.
- Score progression per round — every candidate, the winners joined, the pass line drawn
- Spend against the budget cap, round by round
- Each candidate's five dimensions, with the weakest link lit
- The critic's must-fix list, and why anything went unscored
- Re-render any past run with
--report runs/<id>
Quickstart
Watch it work in seconds. Then point it at your idea.
--demo runs the real controller — real worktrees, real pytest and
ruff gates, real promotion and stop rules — against a scripted builder and
critic. No API key, no cost, about ten seconds.
# watch a whole tournament, offline
git clone https://github.com/charanreddy-27/CRUCIBLE && cd CRUCIBLE
pip install -r requirements.txt
python crucible.py --demo
# the real thing — needs the Claude Code CLI on PATH
python crucible.py "CLI expense tracker: add, list, summary. JSON storage."
python crucible.py IDEA.md -n 5 # five candidates per round
python crucible.py IDEA.md -n 1 --budget 3 # sequential, capped spend
python crucible.py --report runs/<run-id> # re-render a past run's report
A run leaves behind a git repo where best is tagged on the
highest-scoring round, every candidate is a branch, and the reports show the
whole tournament — who ran, who went green, who won, and what it cost.
cd runs/<run-id>/workspace
git checkout best
git branch --list 'cand-*' # the roads not taken
git diff round-2 cand-r2-1 # what a loser did differently
It refuses to start if a gate tool, prompt template or the critic schema is missing. A skipped gate is a lie about the result, so it would rather not run.
Read the code
One Python file, three markdown prompts, one JSON schema. No framework, no dependencies beyond the gate tools themselves — the component deciding when to stop should be the most boring code in the repo.
Or the story
Why it exists, the month it nearly died, how you test a system whose entire job is being unpredictable — and a recorded live run where the critic failed code that passed every gate.