Run a retro on a buggy agent session and turn it into a test and hook

AI Dive had Claude Code run Matt Pocock's /retro skill on a session that burned an invoice number, turned the lessons into a test and a pre-commit hook, and the re-run passed a finance check 5 of 5 times.

Done withClaude Code· Oct 29, 2026

What they did

The author gave a plain Claude Code session a task on ledgerly, a small Node and TypeScript invoicing API with vitest and no CLAUDE.md: add credit notes numbered CN-0001, CN-0002 in order. The session came back with 42 green tests, but a hidden finance check found that a rejected request had used up a number, because the handler took the next number before validating, a pattern it copied from the existing issue route. The author then ran Matt Pocock's /retro skill (v1.3.1, project scope), which reads the session log and ranks what would have prevented the trouble. They ran it twice, the second time with the finance failure described, and asked it to point at the transcript moment behind each candidate so untraceable ones could be dropped. Each surviving lesson went into its own file: a pre-commit hook running typecheck and tests, a vitest test for numbering after a rejected request, one line in CODING_STANDARDS.md and a doc comment on the counter function.

How it went

The first retro called the session smooth and never mentioned numbering, since the log held no failure. Told about the failure, it found the cause in its own code and predicted the same leak in the issue route, which the author confirmed. Four of five candidates survived the trace step on that pass. Both passes advised against adding a CLAUDE.md line. The new test failed as expected, and the hook refused the author's own commit until the agent moved number allocation after validation. A fresh session given the same request read the standards file and the red test first, shipped with 37 tests passing and passed the finance check 5 of 5 times.

Worth knowing

The retro only sees failures that happened inside the session, so tell it what broke. The author is clear this is one re-run, the fresh session was handed the lesson, and the bug only showed up in one of two bare runs before the retro. Only the hook is enforced; the standards line and comment work only if the agent chooses to read them.

Try it

With Claude Code· 4 parts to fill in

My last session in [repo] shipped a bug that its own tests missed: [what failed, e.g. a rejected request still used up a sequence number]. Review that session's log and tell me what in the repo would have prevented it. For each candidate, quote the exact moment in the session that supports it, and drop any you cannot trace. Then propose where each lesson should live: a failing test, a pre-commit hook running [my check commands], a line in [my standards file] or a code comment, and avoid steering-file lines unless nothing else fits. Show me the list and wait for my approval before editing any file.

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

Where they said it

Related