When the same context writes the work and approves it, “looks done” becomes the bar. A separate critic that runs real commands and returns a 0-100 score turns that into evidence, or names exactly what is missing.
An agent reviewing its own output reviews nothing: it confirms the intent it already had. The symptoms are familiar, review rounds that never converge, “it's done” repeated, and the defect showing up later in the hands of whoever trusted it.
The fix is not asking the model to “be rigorous”. It is moving the score out of the agent: a script that measures with real commands, and a separate context that audits the score.
loop_runner.py + your checks): executes
every command, keeps the raw output and prints SCORE= and GAPS=.Rule zero: builder ≠ critic ≠ reviewer. If one context does all three, the loop is theatre.
{"checks":[{"name":"pytest","cmd":"set -o pipefail; pytest -q","weight":40},
{"name":"no_secret_scan","cmd":"gitleaks detect --no-banner","weight":30}]}python scripts/loop_runner.py --config loop.json --round 1Red is the broken case (the gate blocks); green is the one that ships. Both are real runs, not an illustration.
$ python scripts/loop_runner.py --config loop.json --round 3
SCORE=55
GAPS=[pytest::exit_1, no_secret_scan::missing]
GATE=failed
$ echo $?
1
$ python scripts/loop_runner.py --config loop.json --round 7
SCORE=100
GATE=passed
$ echo $?
0pytest | tail returns the exit code of
tail (0), so the critic scores 100 with a failing test hidden in the output. Use
set -o pipefail inside every check.The point is not the score: it is the conversation. “Is it done?” stops being the builder's
opinion and becomes SCORE=100 with the command output attached, or a gap list with
names and weights. When something could not be verified, it is written down instead of turning into
a false green.
The same pattern holds for any deliverable: code, a pipeline, a data migration, a document someone will use to decide.
The skill that does this ships as AI Test Loop, the package includes
loop_runner.py, the scoring rubric, the reviewer prompt and the security checks. The
repository is open (MIT) and the store version adds the ready-made guards.
See the AI Test Loop skill Copy Install Command
Rather have it installed in your project? Guided setup from R$ 1.500, with the first cycle run together.
The 14 chapters of O agente que não mente (ebook) are these texts, in order: PDF in English and Portuguese, R$ 37,00, instant delivery.
Sent when I publish, together with the free skill used here. No spam, one-click unsubscribe.
I am also here: Portfolio · LifeLog (personal blog) · X