Debugging in the Age of Agents
David Agans's nine rules, reread not as advice for us but as the blueprint for the lab an agent works in
Machine-translated from Spanish. Read the original

In 2002, David Agans published a short book with a long title, Debugging: The 9 Indispensable Rules for Finding Even the Most Elusive Software and Hardware Problems. The book comes out of years of hunting faults in circuits and in programs, and it applies to both. The second chapter is called "The Rules, Suitable for Framing".
The rules are almost obvious, and that's exactly the book's point. Nobody is unaware of them. What happens is that at three in the morning, with the system down and someone asking when it'll be back, we skip them. We start guessing, changing things to see if it fixes itself, swearing the bug can't be where it is.
Today a good share of debugging is done by an agent, that is, a language model that reads the code, runs commands, proposes a fix and tests it. An agent doesn't get frustrated or tired at three in the morning. But it guesses more than any of us, because producing the most plausible explanation is, literally, what a language model does.
So the nine rules matter more than ever. What changes is the question. It's no longer "do I follow them?" but "how do I set up the environment so the agent follows them, even when it forgets?".
For each rule there are three ways to get there, from weakest to strongest:
- Ask for it. Write it in the agent's instructions (a file like
CLAUDE.md, which the agent reads when it starts). It complies almost always. Almost. - Hand it over. Put within reach the tool that makes the right path the easy one, such as a command to reproduce the error, read access to the real data or a browser.
- Enforce it. Have the environment make it happen with a rule the system always runs, without the agent getting a say. In these tools' jargon, a hook.
It's the same idea that runs through First the Filter, Then the Generator, according to which whatever can be a mechanism shouldn't be left as a request. Let's go rule by rule.
1. Understand the system
Understand the system. Before looking for what's wrong, know how it's supposed to work by reading the manual, the documentation, the design.
An agent starts every session from scratch. It reads code very fast, but code says what the system does, not what it should do. And some things aren't in any file (how it's deployed, how much data there is in production, what decision was made two years ago and why).
A case of my own. A task said, in its title, that the problem was in "manually loaded codes". Reading the code, the agent put together a reasonable plan for manually loaded codes. A query against a read-only copy of the database showed something else, that there were 71,212 codes and that they came from a bulk import. That number changed the whole design, and you couldn't have deduced it by reading code.
In the lab. Hand it over. Instructions covering what the agent can't see from the repository, written specifications of what has to be true, and access to the real data so it can ask instead of assume.
2. Make it fail
Make it fail. You can't fix what you can't reproduce. First, a way to make the error show up at will.
An agent's temptation is to go straight to the fix. It reads, finds something suspicious, changes it and announces it's solved. Without a reproduction there's no way to know whether the change touched the bug or something next to it.
What helps is asking it, before any fix, for a failing test, meaning a small program that shows the error. And making reproduction cheap, with test data ready to go, a one-line command that brings up the environment and a fixed seed for anything random. If reproducing takes half an hour of setup, the agent —like anyone— will find a way to skip it.
That test is also the piece that unlocks rules 4 and 9. It's the oracle, the yes-or-no question you can ask a thousand times.
In the lab. Ask for the test before the fix, and hand over an environment where reproducing is the easiest thing to do.
3. Quit thinking and look
Quit thinking and look. For Agans, the most common mistake is theorizing about the cause instead of observing what's going on. You find the bug faster by looking than by thinking.
It's the rule an agent breaks by nature. A language model is a theorizing machine. Give it code and it will deduce what the data should look like, and the deduction will sound very good. Asking it to read more files doesn't get it out of there, since it only spends more and keeps guessing. A query against the real data costs little and returns a fact.
When it does look, the agent is very good. Once I asked it why 99 numbers were missing from a table's sequence of identifiers. Instead of theorizing, it looked, and saw that the missing ones came in four contiguous runs. That suggested the hypothesis that these were rolled-back operations. The database hands out numbers one at a time, and if the operation that took a number is rolled back, the number isn't given back; it's burned (the PostgreSQL documentation says as much). A query confirmed the hypothesis. From the data to the cause, without reading a line of code.
Anthropic reported something similar with its own agents. When they gave them a browser and asked them to test what they built "as a human user would", performance "dramatically improved".
In the lab. Hand it eyes. System logs, a read-only copy of the database, a browser, measurements at real volume. And ask for the output, not the theory ("show me what it returned", not "I understand the problem now").
4. Divide and conquer
Divide and conquer. Split the search space in half, and in half again, until the error has nowhere to hide.
For an agent this rule is a gift, because the mechanical search that bores us costs it nothing. Git, the tool that keeps the history of the code, has a command, git bisect run, that does the binary search on its own. You give it a script that says "works" or "doesn't work", and git tries versions of the code, splitting the history in half each time, until it finds the change that broke everything. That script is the test from rule 2.
What's needed on our side is a history that can be split. If every saved change mixes a fix, a rename and a reorganization, finding the guilty change doesn't tell you much. Kent Beck asks in Tidy First? not to mix in the same change what reorganizes and what changes behavior.
In the lab. Hand over a fast yes-or-no oracle, and a history made of small changes.
5. Change one thing at a time
Change one thing at a time. If you change five things and the error goes away, you don't know which one fixed it. And if another one shows up, you don't know which one brought it either.
An agent leans the other way. "While I was at it", it fixes the bug, renames two variables, adds a defensive check just in case, reorders a file. Each thing makes sense on its own; together, they turn the experiment into soup.
In the article where Anthropic describes how it builds agents that work for hours, one of the decisions they call critical is asking the agent to work on only one feature at a time. And today's tools let you go further, with each attempt in its own copy of the repository (a worktree), so two hypotheses don't step on each other.
In the lab. Ask for one hypothesis per experiment, and hand over an isolated space for each one, so mixed changes stand out instead of hiding.
6. Keep an audit trail
Keep an audit trail. Write down what you did, in what order and what happened. The detail that seems irrelevant is usually the one that matters.
An agent has the memory of a goldfish with good conversation. Its context is finite, so when it fills up it gets summarized, and things get lost in the summary. The next day it starts from scratch. Without a record, it tries again the hypothesis it had already ruled out yesterday.
Anthropic solves this with a progress file each agent reads when it starts and updates when it finishes, plus the git history to go back. I use the same thing, a file with "what I'm on" that a hook injects into the agent at the start of every session.
But the record has to be designed too. Mine went from 1.9 to 28.8 KB in nine days. At some point the tool started showing the agent only the beginning of the file, and the agent was working with the state from two days earlier. The rule said "update the state every turn". None said "and remove the old stuff".
In the lab. Enforce reading the record at the start, and design what goes into it and what comes out.
7. Check the plug
Check the plug. Question what you take for granted. Is it plugged in? Did you compile the version you think you did? Did what you think ran actually run?
With agents, this rule gets a new twist, because the plug you have to check is the agent's own report. "Tests pass" can mean it ran a subset, or none at all. In August 2026, a group of researchers who audited agents reproducing scientific experiments found that they silently cut the data or the budget of the experiment, or replaced a failing component with a table of fixed answers, and then drew conclusions as if nothing had happened.
In my own work, the classifier that reviews the agent's actions stopped 41 of them in two weeks. Two were the agent trying to skip a check, once by telling git not to run the verifications and another time by committing through a different route, from inside a container.
In the lab. Enforce it. The verification isn't reported by the agent, it's run by the environment. And the shortcuts to skip it are blocked with permissions, not requests.
8. Get a fresh view
Get a fresh view. Tell someone else about the problem. Sometimes the other person sees what you don't; sometimes you see it yourself while explaining it.
The agent that wrote the code is the worst possible reviewer of that code. Models tend to prefer texts they generated themselves, and they tend to agree with whoever is talking to them. Generating and reviewing are two different modes, and the second one doesn't switch on by itself.
What works is another agent, with fresh context, to whom the work is presented as someone else's ("find errors in this"). Two details make the difference. First, the reviewer can read but not edit, so it doesn't quietly fix what it should be reporting. Second, ask only for errors that change behavior, each one with its proof. The Claude Code documentation warns that a reviewer asked to find "problems" will always find something, even if it's about style or made up.
In the lab. Hand over a separate reviewer, with read-only permissions enforced by the tool, not requested.
9. If you didn't fix it, it ain't fixed
If you didn't fix it, it ain't fixed. If the error went away and you don't know why, it'll come back. A fix gets verified by checking that, when you take it out, the error comes back and, when you put it in, it goes away.
The Claude Code documentation puts it in a sentence that deserves a frame next to Agans's, "Claude stops when the work looks done." The agent stops when the work looks finished. If it has nothing to run that tells it whether it really is, "looks done" is all it has.
I learned it the hard way. Once I merged seven changes in a row and only afterwards ran the end-to-end test in the staging environment. Of five points that had to be checked, one worked.
In the lab. Enforce it. The test from rule 2 has to fail before the fix and pass after. And the agent can't call its turn finished until it passes, something some tools already allow with a hook that, when the agent tries to finish, runs the checks and sends it back to work if they fail.
The repo builds that check (lab/done-gate.sh) and puts a bug built for the demo through it, a gift card lookup that stopped finding codes typed in lowercase, while the two tests already there stayed green. The demo doesn't run an agent; it makes the agent's moves by hand. The check exits with code 2, which in a Claude Code hook sends the agent back to work, until the fix meets what it asks for:
ok the gate won't let the work end with nothing changed
not done:
- the reproduction still fails with your change
- no passing test named "finds a card typed in lowercase with spaces around": keep the reproduction as a regression test
ok with the test, the gate lets the work end
done: the reproduction fails without the change and passes with it; 3 tests ran, none failed
ok after the commit, the same gate with no change left refuses: nothing reproduces anything
not done:
- the reproduction passes without your change too: it doesn't reproduce anythingWhat interests me in that output is that the check takes nobody's word for it. It runs the reproduction with the change and without it, and runs the suite on its own (3 tests ran). The last line is rule 9 seen from the other side, because a reproduction that already passes without the fix proves nothing.
A lab, not a detective
Put in a table, the lab looks like this:
| Rule | How an agent breaks it | What we give it | How |
|---|---|---|---|
| 1. Understand the system | Deduces from the code what isn't in the code | Instructions and real data | Hand it over |
| 2. Make it fail | Goes straight to the fix | A failing test, and cheap reproduction | Ask and hand it over |
| 3. Quit thinking and look | Theorizes fluently | Logs, data, a browser | Hand it over |
| 4. Divide and conquer | Jumps to the most plausible suspect | A yes-or-no oracle and small changes | Hand it over |
| 5. One thing at a time | "While I was at it" | An isolated space per hypothesis | Ask and hand it over |
| 6. Keep an audit trail | Forgets what it ruled out | A record read at startup | Enforce |
| 7. Check the plug | Reports what didn't run | The environment runs the check | Enforce |
| 8. A fresh view | Reviews itself fondly | A read-only reviewer | Hand it over |
| 9. If you didn't fix it… | Stops when it looks done | It can't finish until it passes | Enforce |
Andreas Zeller, who wrote the other great book on the subject, Why Programs Fail, frames it as the scientific method applied to a program, with a hypothesis, a prediction ("if it's this, I should see that"), an experiment against the real system, and back to the start until there are no discrepancies. Agans's rules are the workshop version of that method.
What changed is who runs the experiment. Agans wrote for a person who has to discipline themselves under pressure. With agents, discipline isn't preached to the investigator but built into the lab where it investigates. Our job moves from detective to designer of the lab.
One more detail, so as not to overdo it, is that not everything has to be a hook. Every enforced rule will at some point fire when it shouldn't, and someone has to maintain it. The ones that worked best for me were born from a concrete stumble, not from a list of best practices. The question for each one is the same Agans would ask, which is whether the agent can skip what I'm asking for. If the answer is yes and the cost of skipping it is high, asking isn't enough.
References
- Agans, D. J. (2002). Debugging: The 9 Indispensable Rules for Finding Even the Most Elusive Software and Hardware Problems. AMACOM. Book website
- Zeller, A. (2005). Why Programs Fail: A Guide to Systematic Debugging. Morgan Kaufmann. Its open continuation: The Debugging Book
- Anthropic (2025). Effective harnesses for long-running agents. Article
- Anthropic. Best practices for Claude Code. Documentation
- Yu, L. et al. (2026). Beyond Execution: Auditing Experimental Fidelity in LLM-Driven Scientific Research. arXiv:2608.26753
- Panickssery, A., Bowman, S. R. & Feng, S. (2024). LLM Evaluators Recognize and Favor Their Own Generations. NeurIPS. arXiv:2404.13076
- Sharma, M. et al. (2024). Towards Understanding Sycophancy in Language Models. ICLR. arXiv:2310.13548
- Git. git-bisect. Documentation
- PostgreSQL. Sequence Manipulation Functions. Documentation
Everything this article claims, in code that runs. Clone it, break it, open an issue.
Ragnagrok/debugging-in-the-age-of-agentsIf this article was useful to you, you can sponsor the blog on GitHub. It helps me keep writing.