Back to articles

Turn every agent mistake into a guardrail

A few months ago I changed how I work with coding agents. Instead of correcting the same mistakes in every session, I started treating each mistake as something missing from the project. Then Lauren Tan gave a talk about shipping 2,000 pull requests in a month, and it described almost exactly what I had been doing.

This is how I set up my projects, with the parts of her talk that match it.

The bottleneck is trust

Most of us run a few agents and babysit every conversation. We read every diff, correct, and re-prompt. Nothing good happens while we are away.

Lauren says you cannot go from five agents to a hundred until you trust their work. Spawn more agents without that trust and you only get more slop to review.

Better prompts will not get you there. The environment the agent works in will. The more guardrails around an agent, the fewer unwanted results you get.

Every mistake is a missing guardrail

The first rule on my projects: be aware of what the agents get wrong. I mean the mistakes that come back, like calling print instead of the logger, a feature importing the HTTP client directly, or a hardcoded colour.

Correcting it in chat fixes one session. The next agent makes the same mistake tomorrow. So when I catch myself correcting an agent, I turn the failure into something that runs without me: a lint rule, a unit test, an end-to-end test, or an automation.

Lauren had a slide for this that she said was the one thing to remember. When you correct an agent, fix the problem at the strongest level you can, in this order:

1. Codebase. Make the mistake impossible through architecture, data structures, or types.

2. Static analysis. Lint rules, compiler diagnostics, and CI checks that fail when the mistake comes back.

3. Rules and review bots. Guidance the agent usually follows, but can skip or forget.

4. Skills. Playbooks that teach the agent how your team works.

5. Style guide. Only enforced by humans in code review, which does not scale.

That order is why I built agent_lints. A line in AGENTS.md is level three at best. A lint rule is level two, and the agent fixes it before it says it is done.

Your codebase is memory

Agents copy what they see. The files they read become their context, and they rarely refactor on their own. Lauren calls the codebase the best form of memory you can give an agent.

That includes the bad parts. One workaround gets copied, and a few weeks later it is the pattern everywhere. Her team went as far as banning code comments, because agents used them as an excuse to paper over problems instead of fixing them.

So I keep one obvious way to do each common thing, and I clean up bad patterns before an agent finds them. When I cannot clean something up right away, a lint rule at least stops it from spreading.

Let agents verify their own work

Lint rules catch bad code. They do not tell you the feature works. For that the agent needs a way to run the app and check the result itself.

On my projects that is the job of tests. Unit tests for the logic, end-to-end tests for the flows that matter. An agent that can run them knows when its change works, and I only review pull requests that pass.

Lauren went further with a verification skill: a CLI the agent uses to run the app and capture performance traces, plus a map of every feature and how a user reaches it. Both give the agent a repeatable way to check its own work.

Watch your skills fail

Skills are easy for an agent to get wrong. An agent can skip one, load the wrong one, or follow it halfway. When that happens I treat it like a bug: I look at why the skill was missed or misread, and I fix the skill right away, not next week.

The same goes for the whole workflow. Pay attention to where the agent still needs you, and remove that need one fix at a time.

At some point it stops needing handholding. As Lauren put it: it is not really a secret, it is a lot of hard work.

© 2026 Pedro Massango