When should you use it?
- Coding agents open many of your pull requests and human review cannot keep up
- You have already seen an agent write a test that could never fail, or quietly skip one
- You want rules that hold even when nobody remembers why they were added
Not for: Solo scripts and throwaway prototypes, where the overhead outweighs the benefit; Teams without a CI pipeline that can block a merge; Replacing human review of security-sensitive changes
What do you need, and what do you get?
You need
- A repository where coding agents submit pull requests
- A CI pipeline that can fail a build and block the merge
- A short log of agent mistakes you have caught so far
You get
- A failure-to-check table kept in the repository
- One automated gate per failure mode, wired into CI or git hooks
- A small set of planted bad changes used to test each new gate
How does it work, step by step?
- Write down each failureEvery time an agent change causes harm or nearly does, record what happened in one line, such as a test that copies the logic it checks.
- Turn it into a gatePick the cheapest automatic check that would have caught it: a lint rule, a grep over the diff, a duplicate-code scan or a hook that refuses writes outside the working folder.
- Test with recorded dataHave agents capture real responses from the live service as fixtures, and refuse hand-written fakes and tests that skip when a dependency is missing.
- Attack the new gateBefore a gate goes live, feed it a few deliberately sneaky changes and make sure it blocks them.
- Keep the always-loaded guide smallCap the instructions loaded into every agent call at a couple of kilobytes and move detail into topic files the agent opens only when needed.
The prompt
Our own prompt, inspired by u/alexmarquardt on r/ClaudeCode and written to work in Claude Code and Custom agent. Values in lime are placeholders.
Fill in the blanks (optional; the copied prompt uses your values)
You are helping me harden a repository where coding agents open pull requests. Our stack: {stack}. Our CI: {ci_system}. Here are the agent mistakes we have caught so far, one per line: {incident_list} For each mistake, propose the cheapest automated check that would have blocked the merge (lint rule, diff grep, duplicate-code scan, git hook, test naming rule or recorded-fixture rule). Give the exact rule or script, where it runs, and what message it prints when it fails. Then write one deliberately sneaky change for each check that tries to get past it, and say whether the check as written would catch it. Do not change any files. Present everything as a table followed by the scripts.
Inspired by u/alexmarquardt on r/ClaudeCode: Reddit post: the ways coding agents broke our codebase, and the check we added for each one. The prompt above is written by playbooks.bot in our own words; nothing from the original is quoted.
What can go wrong?
- A gate that nobody tested against an evasion is a suggestion. The author found that most planted evasions got past a brand-new gate.
- Long contributor guides backfire. Agents miss the one rule that matters when it is buried among fifty others.
- Flaky tests teach everyone to rerun until green. Treat a flaky test as a serious bug rather than noise.
- Checks do not remove rework. Expect a fix round on many pull requests and budget review time for it.
Our take
Most advice about coding agents is about better prompts. This post is about something more durable: treating every agent mistake as a missing test of the process, then writing that test. What makes the list useful is how specific it is. Hollow tests, fixtures nobody recorded from the real system, a silenced type error on exactly the line with the bug, an agent deleting more than a hundred files it never made. Each has a cheap, mechanical answer, and none of them depends on the model behaving well next week. We especially like two habits. Running every new gate against a set of planted evasions before trusting it, and capping the always-loaded guidance so the important rules stay visible. Our caution is about scale. This team merges well over a thousand pull requests a month, so heavy gating pays for itself. A small business with one agent should copy the method, a log of failures turned into checks, without trying to copy the whole toolchain. In our dry run, the adapted prompt turned five fictional incident notes into five matching gates and one planted evasion for each.
Where the time goes back: Each failure mode gets caught by a machine at merge time instead of by a reviewer who has to spot it in a long diff, or by a customer after release.
FAQ
How much testing does this take?
Do I need all of these checks on day one?
Does this work with agents other than Claude Code?
Source and credit
Inspired by u/alexmarquardt on r/ClaudeCode. We describe the idea in our own words, link to the original, and wrote the prompt ourselves; nothing is quoted.
- Inspired by
- Reddit post: the ways coding agents broke our codebase, and the check we added for each one
- Creator
- u/alexmarquardt on r/ClaudeCode
- Published on
- Original date
- Nov 10, 2026
- License
- Not openly licensed (the poster keeps all rights), so we quote nothing and link to the original
- Originally for
- Claude Code
- AI dry run
- Nov 10, 2026: passed. Dry-run tested by our AI test agent on sample input. Five incidents became five gates with fail messages; five planted evasions tested, one gap reported rather than hidden.
AI dry run on sample data; not run with live connected accounts. The playbooks.bot test agent filled the prompt with synthetic inputs, produced the output and checked it against the page's stated outputs and guardrails. - Verified
- Nov 10, 2026: source link resolves to the original, the credited creator published it, our excerpt or prompt matches it, and the license allows our use.
Are you the creator? Claim or correct this page.