ai

AGENTS.md, or writing for a reader that forgets

AGENTS.md, or writing for a reader that forgets

Somewhere in the last twelve months every coding assistant acquired a file it reads before it does anything. Claude Code arrived in February looking for CLAUDE.md. Cursor has its rules directory. Copilot reads .github/copilot-instructions.md. Gemini CLI wants GEMINI.md. Codex read AGENTS.md from the start, and in August a group of the vendors put a site behind that name and proposed it as the one file everybody reads.

I don't much care which filename wins. What I do care about is that I've now written and rewritten one of these for a service repository at work three times since spring, and each rewrite removed more than it added. Documentation usually goes the other way, so I wanted to know why.

The reader arrives fresh every time

The mental model I started with was "a README for the robot". It's wrong in one specific way, and that one matters more than anything else. A person reads the README once and after that carries the repository around in their head. The assistant reads the file at the start of every session and carries nothing over. Whatever it learned yesterday about how migrations work here it learned by reading the code, and it'll learn it again tomorrow the same way - unless the file tells it.

So the file isn't really documentation. Documentation is a reference you go back to when you've forgotten something. This is a briefing for someone who has forgotten everything, delivered before every shift and read in full every time. Total amnesia and guaranteed attention pull in opposite directions, and most of the work on the file is managing that.

What went in

The first draft was what you'd expect. How to run the thing, how the tests are laid out, the folder structure. Most of that survived, because it's the kind of fact the assistant otherwise spends its first five minutes rediscovering by running ls and reading package.json, and telling it once is cheaper than watching it find out.

Three more things went in after that, in the order I found out they were needed.

Vocabulary came first. Our domain has words that mean one thing here and something adjacent everywhere else, and a model has seen "everywhere else" far more often than it has seen us. Left alone it would name a new table with the general word and not ours, and it'd be perfectly consistent about it. A short glossary (this term, not that one, and here is the one banned synonym) fixed more review comments than anything else in the file.

Then read-before-touching pointers. The file doesn't explain how authentication works. It has one line: before you change login or session flows, read this document. The model follows a pointer reliably. It does not reliably infer that a document exists.

And then the rules the code can't express. We do not run migrations against shared environments from a laptop. Nothing in the code says so, because it's a rule about the world around the code. The assistant has to be told, otherwise it will do the helpful thing, and here the helpful thing is wrong.

What came back out

The second and third drafts were mostly deletions.

Anything the code already says went first. I'd written a paragraph about our error handling convention. The assistant could see the convention in any file it opened, and the paragraph drifted out of date the first time somebody changed the convention without changing the paragraph. Prose about code goes stale within a month and a stale briefing is worse than none. So if the code demonstrates something, the file doesn't describe it.

Style guidance the formatter enforces went next. I deleted two hundred words about quotes and semicolons, because Prettier runs on save and the assistant sees the result anyway.

After that I cut for length, and this is the amnesia-and-attention tension again, only concrete. The file is read in full every session, so every line costs something on every session, both in the model's context and in how much attention the important lines get. A human skims a long README and finds the bit they need. The assistant reads all of it and weights all of it, so the paragraph about our logging preferences competes with the line about not running migrations. Keeping the file short stops that.

The third draft was under a page, and it's the best of the three by some distance.

One file, several readers

The practical problem this year is that the tools all want different filenames. What I settled on is unglamorous. AGENTS.md holds the content, and every other file the tools look for is one line long, follow AGENTS.md. Claude Code can import a file directly with an @ reference, which is neater still. Either way there's one briefing and the per-tool files point to it, so it can't fork.

I've also stopped thinking of the file as mine to write alone. When a session goes wrong in a way that a sentence would have prevented, the sentence goes in, and when the code starts saying what a sentence says, the sentence comes out. It is the one document in the repository that gets tested every day, by a reader that can't fill gaps from memory. I think that makes it a better proxy for a new colleague's first week than anything I wrote for the colleagues themselves.

It carried over to onboarding documents

I didn't expect this, but writing for a reader that forgets has made me better at writing for readers that don't. It's the same discipline. Say what can't be inferred, point at what can, cut what the tooling enforces, and keep it short enough that it gets read and not skimmed. I've started applying it to onboarding documents, and they are shorter and more correct than they were.

Deyan Peev

Founding Engineer in Sofia, Bulgaria. Currently at 1club.

© 2026 Deyan Peev