Study Notes / 2026 ・ No.05

AGENTS.md Field Notes

The house rules you hand to an AI

Published

Questions for this issue

Q1What is AGENTS.md? Q2When is it worth using? Q3How should you write one? (with an example) Q4Once AI gets smarter, will we still need it?

The short answer to Q4: you will write less of it, but it won't go away

Codex, Claude Code, Copilot, Cursor: start using coding agents
and a file called AGENTS.md begins to appear in repositories.
Here is what it is for, and how to write one that actually helps.

1

What AGENTS.md is — Q1

CORE

AGENTS.md is a README for coding agents: a plain Markdown file at the top of a repository, with no required format and no mandatory fields. An agent reads it when it starts work and learns how to build, how to run the tests and which rules to follow.

OpenAI published the format in August 2025, shaped together with Amp, Google's Jules, Cursor, Factory and others. That December it was donated, alongside MCP (see No. 1), to the new Agentic AI Foundation (AAIF) under the Linux Foundation, so it now belongs to no single company. According to the official site, more than 60,000 open-source projects use it and over 30 agents and IDEs can read it.

ToolIts own fileHow it treats AGENTS.md
OpenAI CodexAGENTS.mdThe origin. Concatenates ~/.codex/AGENTS.md with every AGENTS.md from the repo root down to the working folder (32 KiB in total by default)
Claude CodeCLAUDE.mdReads AGENTS.md instead when there is no CLAUDE.md (v2.1.277 and later). A CLAUDE.md can also pull it in with @AGENTS.md
GitHub Copilot
(coding agent)
.github/copilot-instructions.mdSupports AGENTS.md since August 2025
Cursor, Jules, Devin, Zed, Aider and moreListed on the official site

The difference from a README is the reader. A README is for people: what the project is and how to use it. AGENTS.md is for an agent doing the work: which command proves a change is right, what it must never touch. As the official site puts it, the agent-specific detail gets its own home instead of cluttering the README.

2

Why agents need it

WHY

An agent is a new hire on their first day, every day. As No. 1 explained, a model sees only what is in its context. Start a new session and whatever you told it last time is gone.

  • Some things can't be inferred — “this HTML is generated, don't edit it” or “a person signs off before anything goes live” appear nowhere in the code
  • Inference costs time and money — hunting for how to run the tests means opening file after file and trying things that fail. One written line saves all that
  • Instructions drift between people — moving spoken reminders into a file means every teammate's agent, whichever tool it is, follows the same rules

Think of it as onboarding notes for a new colleague, with one difference: this colleague reads every word, every time, and follows it quite literally. That is exactly why it has to be short and precise.

3

When to use it — Q2

WHEN

It pays off in repositories where agents work again and again, and above all where there are rules you can't see in the code. For a one-off small task, putting it in the request is enough.

SituationFitWhy
Unusual build or test steps◎Custom scripts, Docker, required env vars. Letting the agent search burns time and tokens
Places that must not be touched◎Generated files, vendored code, production config. One bad edit is expensive
Business systems◎House naming rules, tables that need approval to change. Business rules aren't written in the code
A team using several agents◎One file tells every tool the same rules
A monorepo○When front end and API differ, each folder can have its own AGENTS.md
A small app with a standard layout△Agents can work out a standard layout on their own
A throwaway script×Writing the file costs more than it saves

A simple test: have you told an agent the same thing twice? If so, you will be saying it a third time. That is the moment to add one line to AGENTS.md, and the least wasteful way to grow the file.

4

How to write it — Q3

HOW

Three principles: short, specific, and only what the code can't tell the agent. To decide what goes in, ask two questions: could the agent find this out itself, and how costly is a mistake?

Write it, or leave it out?

Enforce instead CI, hooks, branch protection A note can't enforce it Always write Don'ts, with the alternative Build output, prod, sign-off Leave out Project overview Stack, layout, generic advice Write briefly Commands, naming habits Saves the agent a search Costly Cheap The agent can find it out Nowhere in the code

Always write the top right. For the top left, don't just write it: enforce it

  • Give commands exactly as they run — not “run the tests” but npm test -- --run. Agents really do execute what you write
  • Add the reason in a few words — “generated, don't edit (fix build.py instead)”. With the reason, the agent handles similar cases you never wrote down
  • Pair every don't with what to do instead — a bare prohibition sends the agent looking for another way round
  • Keep it short — Claude Code's documentation suggests under 200 lines for a CLAUDE.md; Codex caps what it reads at 32 KiB by default. Longer files are followed less reliably, and you pay for them every session
  • No secrets — passwords and API keys never belong in the repo, and this file is shared with everyone
  • Enforce what must never happen — AGENTS.md is context, not configuration; it has no power to stop anything. Use branch protection to keep changes off main, and CI or hooks (such as Claude Code's hooks) to keep formatting intact

One file per folder: the nearest wins

repo/ ├─ AGENTS.md ├─ web/ │ ├─ AGENTS.md │ └─ src/ └─ api/ └─ … ← you work here Working in web/src/ 1 repo/AGENTS.md Rules for the whole repo 2 web/AGENTS.md Rules for web only 3 Your request Overrides everything Lower wins (the nearest file)

Codex concatenates from the root down to the working folder; later (nearer) files act as overrides

In a monorepo, subfolders can carry their own AGENTS.md. The official rule: the nearest file takes precedence, and your request overrides them all. OpenAI's own main repository reportedly has 88 of them.

With Claude Code, an AGENTS.md is read directly when there is no CLAUDE.md. To keep both, the documented approach is a one-line @AGENTS.md import at the top of CLAUDE.md, with Claude-only instructions below it. A symlink (ln -s AGENTS.md CLAUDE.md) also works, but if anyone clones on Windows, the import is safer.

# CLAUDE.md @AGENTS.md # Everything below is for Claude Code only - Before a large change, show the plan as a bullet list first
5

Example: this site's AGENTS.md

As an example, here is the AGENTS.md we would put in this site's own repository, kiji-site: a small repo where a single Python file generates pages in three languages, published on Cloudflare Pages. From building this blog with AI, I kept only what I kept having to explain and the mistakes that nearly happened.

# AGENTS.md — kiji-site Company site for KIJI Info-Tech, in Japanese, Chinese and English. ## Layout - Every page is generated by build.py. The *.html files at the root are build output: never edit them directly (fix build.py, then rebuild) - Images live in blog-img/<post-slug>/ as webp and jpg, 1600 and 960 wide ## Commands - Build: python3 build.py - Deployable output: ./build.sh (writes to dist/) - Check: python3 -m http.server 8765, then view at 1280px and 390px wide ## Adding a post - Add one line each to POSTS, FILE (all three languages) and POST_CATEGORY (a missing POST_CATEGORY entry stops the build) - Post cards run newest first: add at the top - After building, check SVG figures with getBBox (text overflowing or overlapping; the English version breaks most) ## Rules - Photos only under licences that allow reuse (CC BY, BY-SA, CC0 and so on), with the author and licence in the caption - Check prices, times and versions against primary sources, and date them ("as of September 2026") - Never git push. A person reviews and publishes - Commit messages in Japanese, key points as bullets
What's in itWhy it's there
*.html is generatedAsked to fix a style, an agent tends to edit the HTML directly, and the next build wipes it out
Commands and check widthsNo searching. Even the screen widths to check are fixed
Steps for adding a postThe three edits belong together; miss one and the build stops
Checking figuresLabels overflowing in the English version actually happened twice
Photo licencesSo it doesn't grab whatever image it finds online
No pushingA person looks before anything goes live. Irreversible steps stay human

What is left out matters just as much. No project tour: nothing like “written in Python” or “blog.html lists the posts”. Anything the agent can see by opening a file, it will read for itself. At around 30 lines, the file is also the size the research in the next chapter points to.

6

Does it actually work? — the research

DATA

There is little research so far, and the results disagree. But they point the same way: a short, human-written AGENTS.md that holds only what the code can't tell may help; anything else does nothing or gets in the way.

StudyWhat was testedResult
Lulla et al.
(Jan 2026)
10 repositories, 124 pull requestsWith AGENTS.md, median runtime 28.64% lower and output tokens 16.58% fewer, with similar completion
Gloaguen et al.
ETH Zurich
(Feb 2026)
138 AGENTbench and 300 SWE-bench Lite tasks; Claude Code, Codex, Qwen CodeLLM-generated files cut success by 0.5–2 points; human-written ones added about 4 points on average. Both raised inference cost by over 20%. Repository overviews didn't help
Khatri
(Jul 2026)
Claude Code and Codex CLI, 17 tasks, 288 runsNo significant effect on correctness. Failures came from design and implementation skill, not missing knowledge

The ETH paper explains why: agents follow the instructions faithfully and test and explore more, which makes the task itself harder. More text does not mean better results.

The practical lesson: don't commit a file generated by /init or similar as it is. If you generate one, read it and delete every line the code already makes obvious. That is the most reliable way to use AGENTS.md today.

The third paper is a preprint by an independent researcher. Every figure holds only under its own experimental setup.

7

Will smarter AI make it obsolete? — Q4

VIEW

My answer: you will write less of it, but it won't go away. Split what usually goes into an AGENTS.md into three kinds, and it becomes clear which parts intelligence will replace and which it can't.

What remains once models are smarter

Today Smarter Readable in code Findable by trying Unwritten intent No longer needed Unwritten intent This part stays

Widths are rough proportions. Unwritten intent doesn't shrink as models improve

  • What you can read in the code (the project overview, the language, the folder layout) — already unnecessary today, and the research says it doesn't help
  • What you can find out by trying (build and test commands, how to run it locally) — as models get smarter, faster and cheaper, searching costs less and less. Writing it down becomes purely a way to save time and money
  • Intent that is written down nowhere (why it was done this way, what must never happen, who decides) — no amount of reading code or history will surface it. It isn't a question of intelligence; the information simply isn't there

Think of people. However brilliant an engineer is, on their first day in a new job they don't know that “we never touch the production database on Fridays” or that “changes to this table need sign-off from finance”. The best engineers are the ones who ask about those rules first.

What will change is the form. There are already ways for agents to note what they learn (such as Claude Code's auto memory), instructions loaded only when needed (skills), and mechanisms that enforce (hooks and CI), so less needs to go into one AGENTS.md. Still, a place where people write down what people decided, and where people and AI read the same thing, should remain, for the same reason the README never went away.

This chapter is the author's reading of the facts above.

§ — On one page

  1. AGENTS.md is a README for agents: plain Markdown, read by over 30 tools including Codex, Copilot and Cursor, and by Claude Code when there is no CLAUDE.md.
  2. Use it where agents work repeatedly and there are rules you can't see in the code. Told an agent something twice? Add a line.
  3. Write commands, don'ts with their alternatives, and the reasons. Short, and by hand. No overviews or generic advice.
  4. Enforce what must never happen with branch protection, CI and hooks. AGENTS.md can't enforce anything.
  5. The smarter AI gets, the less you need to write, but the file stays as the place for intent the code doesn't contain.

References

AGENTS.md Field Notes — seven chapters / 2026.09

← Back to all posts