← Back to all posts Short triggers up front, corrections on demand the entry file just tells the agent when to open the rulebook entry file AGENTS.md always loaded every session, every task the trigger list “about to ship / claim done” 130 words of context budget → go open the registry the failure registry PITFALLS.md 115 corrections each dated to the incident loaded only when a trigger fires put those 115 corrections in the box on the left instead, and the agent follows fewer of them

Your AGENTS.md Gets Worse Every Time You Fix It

Sep 4, 2026 · AI & Building

The most common advice about agent instruction files is good advice. When your coding agent repeats a mistake you've already corrected once, write the correction down. Eric Ma puts it this way: “whenever you find yourself giving the same instruction twice, add it to AGENTS.md instead.”

A second piece of advice is also right: these files stop working when they get long. Tian Pan's analysis of instruction files puts reliable compliance at somewhere between 150 and 200 instructions. He finds that effective files cluster around a few hundred words, and that the correlation with length turns negative past about a thousand. You've probably lived the cycle he describes: the agent ignores a rule, so you add a clearer version, then it ignores a different rule, so you add that one too. A few weeks later the file is four hundred lines and the agent ignores more of it than ever.

The two clash somewhere around the fortieth correction. Keep writing corrections down and the file gets too long. Trim it and you lose the lessons that make an agent useful in a working codebase. Most writing on this says to trim, which keeps the file short, but nobody says where the trimmed corrections should go.

Quick answer: keep the corrections in a separate file, and put a short list of triggers in the always-loaded one. A trigger is a moment you can see coming, like “about to claim something is done” or “about to ship anything someone outside will see”, and each one tells the agent to open a separate registry and check it before acting. In my own workspace that trigger block is 11 lines and 130 words, and it points at a registry of 115 dated corrections totaling 17,853 words. All 115 are in force. None of them sit in the context window until a trigger fires.

Three Ways to Split the File, and Only One Handles Corrections

People already split instruction files by folder or by task. Both methods are well covered, and neither one catches repeat mistakes.

Split by directory. This is the AGENTS.md format's own recommendation. You put another AGENTS.md inside each package, agents read the nearest file in the tree, and the closest one wins. It works at scale too: the spec notes that OpenAI's main repository has 88 of them. The lookup key is where the file you're editing lives.

Split by task. This is progressive disclosure, and Tian Pan's piece already proposes it. You keep a small root file and move task guidance into separate documents the agent loads when it needs them. The lookup key is what the agent set out to do: it's about to run the tests, so it opens the testing document.

An agent won't go look up a correction on its own, because it doesn't know it needs it. If it had known the rule applied, it wouldn't have made the mistake that created the rule. A deploy mistake belongs to an action, so the folder key misses it. The task key misses it too: an agent that just finished a page and is about to call it shipped thinks it's done, and that's the moment the correction needs to interrupt.

Split strategyLookup keyGood forFails on corrections because…
By directory
nested AGENTS.md
where the file livesper-package build and style conventionsa mistake belongs to an action, and a folder can't see actions
By task
progressive disclosure
what the agent set out to doreference material the agent knows to go findthe agent doesn't know it needs it, which is why it made the mistake
By trigger
failure registry
a moment the agent is about to pass throughaccumulated corrections(n/a)

A Trigger Names a Moment

The trigger list has to be short enough to load every time and specific enough to fire.

A trigger names an action you can observe. “Be careful with deployments” never fires, because an agent can't tell at any given moment whether it's being careful. “About to claim something is scheduled, sent, confirmed, done, fixed, or validated” does fire, because the agent is about to type one of those words. Listing the exact verbs makes it close to a word match against the agent's own draft.

It also fires before the action. “Deployments must be verified” gets checked at review time, after the damage. “Before you say the word done, go check” gets checked while stepping in is still free. Getting this order wrong is the most common way people write a useless rule.

And it points at exactly one file. “Check the relevant documentation” makes the agent decide what's relevant, on top of the call it already got wrong. With one named file, it runs one grep.

What it looks like. The always-loaded file has a block that reads roughly: fires on draft / dispatch / edit / send, then four short trigger conditions, then one sentence: on any trigger, read the registry and grep for matching entries before acting; treat it as authoritative, it overrides fresh-session recommendations that contradict it. I added that last clause because a capable model with strong priors will work out a recommendation the registry already recorded as a mistake, and then trust its own reasoning over the written record.

What Goes in an Entry, and Why Every Entry Needs a Date

Each entry in mine has five parts: an ID you can grep for, the symptom as it showed up, the condition when it fires, the fix, and the dated incident that caused the entry.

People leave out the date. Without it, every entry looks equally current and equally important, so nobody ever deletes one, and the registry grows until it's as unusable as the four-hundred-line file it replaced. With a date, you can go through entries and ask whether each cause was fixed at the root, and retire the ones that were.

Three Corrections From My Registry

All three happened on my own sites.

“A URL in the sitemap is not evidence the page was deployed.” A deploy shipped the homepage and the sitemap, which both referenced a new post, and never uploaded the post file itself. For three days the homepage linked to a 404, and the sitemap sent that 404 to Google. The file was in the repository the whole time. A second page did the same thing and sat at 404 for two weeks before anyone noticed. The entry says to curl the new page itself after every deploy, because checking the index that links to it proves nothing.

“Corrections propagate to tables; they don't propagate to sentences.” After a measurement audit, I corrected a set of benchmark figures across the tech site. Every table got updated and every page got checked. Three weeks later a new post cited the old numbers in its text, because whoever wrote it pulled them from memory and from an older post. The corrected source was on disk the whole time. The rule that came out of it is narrow. When a new page cites an existing measurement, re-open the source of record and never copy a number from memory or from another page. A later incident added to it, when a page attached made-up settings to a number that had been measured correctly. Now the rule also says to copy the conditions word for word, or write “not logged.”

“Two sessions on one machine race the git index.” This is my favorite. I had a one-writer-per-repository rule, and the agents were following it, but every session on a machine shares the repository's git index. Two agent sessions on the same machine can follow that rule and still collide. One session staged files and its commit command failed, so the work stayed staged. The other session's next commit swept those files into an unrelated message. The second time was worse. A commit included stale staged copies of two files and undid edits it had never touched, with no warning, under a message about something else. The fix is one line: stage and commit in a single command, or use git commit -o <file> -m <msg> to skip the index, so nothing sits staged in between.

A smarter model couldn't have worked out any of these three from first principles. They're facts about one specific setup that I found by breaking it, so a better model wouldn't make the registry unnecessary.

AGENTS.md or CLAUDE.md?

Use both, but keep the actual rules in only one. AGENTS.md is the vendor-neutral format, read by a long list of tools including Codex, Cursor, Gemini CLI, Copilot, Zed, Aider, Windsurf and Devin. CLAUDE.md is Claude Code's version, and GEMINI.md serves some Google tooling. The AGENTS.md spec doesn't mention either of them, so lining them up is your job.

When more than one agent works in a repository, you usually end up with three files that look reasonable and have drifted apart, so the agent's behavior depends on which tool you happened to open. I keep AGENTS.md as the one canonical file and make the others thin shims that import it and add only a pointer or two. Measured this morning, the canonical file is 4,057 words, the Claude shim is 100 words, and the Gemini shim is 161. A change in behavior gets made in one place.

The Numbers

Measured with wc on 2026-09-04:

FileRoleLoadedSize
AGENTS.mdcanonical entry fileevery session153 lines / 4,057 words
↳ trigger blockroutes to the registryevery session11 lines / 130 words
CLAUDE.mdshim, imports the aboveevery Claude session100 words
GEMINI.mdshim, imports the aboveevery Gemini session161 words
PITFALLS.mdfailure registryonly when a trigger fires115 entries / 17,853 words

The registry is 4.0× the byte size of the entry file that points at it, and roughly 137× the size of the trigger block that does the pointing. So 115 corrections cost about 1.1 words each of permanent context. Fold those same 115 entries into the always-loaded file and you'd have something like 22,000 words of standing instructions, far into the range where the published measurements say an agent follows fewer rules.

One catch: my own entry file is still 4,057 words. Tian Pan's data puts effective instruction files at a few hundred words, so mine is about four times too big even after the split. The split kept 17,853 words out of every session, and shrinking the entry file is my next job. If you copy one measurement from this page, copy the trigger block (130 words).

Building with agents in a real repo?

I run a free community for people building data and AI pipelines (warehouse modeling, analytics, AI-augmented workflows). Members trade notes on what they're shipping.

Join the free AI community →

Frequently Asked Questions

Why does my AI coding agent ignore my AGENTS.md or CLAUDE.md?
Usually the file has more rules than the model can follow at once, so the one you care about competes with dozens of others. Published analysis puts reliable compliance at roughly 150–200 instructions, and past about a thousand words, longer files do worse. The rule also loaded at the start of the session, and the moment it applied may have come hundreds of turns later, with much fresher context in the way. Adding a clearer version of the rule makes the file longer and usually makes things worse.
How long should an AGENTS.md file be?
Shorter than most, though what goes in it matters more than line count. Every word loads into every session whether it's relevant or not, so the file should hold only what's true for all work. Anything conditional belongs in a separate file the agent is told to open when a stated condition is met, which costs one line in the main file.
Can a failure registry make things worse?
Yes, through stale entries more than through size. An entry that was true when written and isn't true now is worse than no entry, because the agent trusts it as part of the registry and acts on it without checking. In mine, a maintenance item named four specific pieces of work as the most valuable ones left. When I checked the live state, all four were already done. Re-audit now and then, and date entries so you can tell which ones are overdue for a check.

Related reading: I Ran Claude Code and Codex Head-to-Head: two agents working the same spec in the same repo, which is the situation this file setup is built for. Multi-Model Verification: Catching LLM Hallucinations in Enterprise Reports: the same habit of never trusting a single pass, applied to output instead of instructions. Governing AI Agents' Data Access: the other half of agent governance, limiting what an agent may read instead of how it behaves. AI as an Operations Layer: where these agents run. For the hardware side, see Blendlogic Tech.

What would make this wrong

Get the build notes

My AI experiments: what worked, what didn’t, and how I set them up. Sent to your inbox.

No spam, unsubscribe anytime · Privacy

More in AI & Building →