Turn coding agent mistakes into hooks and regression tests

Piotr runs a judge every two hours over his all-day Claude Code assistant's transcript; a subagent turned 174 strikes into hooks and tools with tests, and 31 of those mistakes came back anyway.

Done withClaude CodeCodexinSlack· Oct 23, 2026

What they did

Piotr uses a Claude Code session as an all-day assistant, wired to Slack, mail, a calendar and TaskWarrior, with 86 hooks, 50 skills and 231 scripts. Tired of the agent apologising and then repeating the same error, in October 2026 he built a loop around it. A cron job cuts the transcript since the last run every two hours and sends it to a judge from another model family, run through the Codex CLI in a read-only sandbox. The judge must quote the transcript for every strike or praise and suggests up to three fixes. A reflect subagent then picks a fix, writes a regression test built from the quoted strike, commits it locally and records it in an append-only ledger in git. Fixes must be mechanisms (a context-injecting hook, an enforcing hook, a script or a small-model check), not new lines of instruction text. Anything touching permissions, spending or external writes goes to his board instead.

How it went

Across two agent sessions the judge logged 299 strikes. 174 were closed with a committed fix: 92 changed a tool, 52 the harness, and 29 were text edits made before he stopped accepting text. Of those 174, 36 stayed quiet for a day, 107 were too new to tell, and 31 saw the same family of mistake return. One example: after the agent kept answering questions that a form or announcement should have answered, a hook now asks it to propose that edit, and the next day brought three praises and no repeat. He calls none of it proven yet.

Worth knowing

A loop that edits its own harness can quietly weaken its guardrails or game its judge. He pins the rubric to a frozen day of 26 of his own complaints, treats lines from email or Slack as untrusted, and counts only text he typed himself. His real metric is his own complaints per week, not the strike count. An earlier attempt that only added rules to CLAUDE.md failed: the agent repeated the mistake while the test that the rule existed kept passing.

Try it

With Claude Code· 4 parts to fill in

Every [two hours], read my session transcript since the last run and find each place where I corrected you or complained, quoting my exact words. Group the mistakes into families. For each new family, propose a fix that is a mechanism, not more instruction text: a hook that injects the right fact at the right moment, a hook that blocks or automates the behaviour, or a script in [my scripts folder]. Write a regression test from the quoted mistake, commit the fix locally with the ledger id, and append it to [ledger file]. If a family comes back after a fix, try the next fix. Never change permissions, guard hooks, the judge's rubric or anything that spends money; put those on [my task board] and wait for me.

Square brackets are the parts to fill in. The prompt is ours; the story is theirs.

Where they said it

Related