What to put in an AGENTS.md file, and what to leave out

Put in only what an agent cannot learn from the code and needs in every session: how to build and test, where things live, and rules you would otherwise repeat. Write each line so it can be checked. Leave out style rules a linter already enforces, and anything that matters for one folder only.

Start free

The short answer

An AGENTS.md is for the lines you would otherwise type into chat at the start of every session. If a line is something the agent can read from the code, something a tool already enforces, or something that only matters in one folder, it does not belong in the root file.

This page is for the person who writes or reviews a team's AGENTS.md or CLAUDE.md and wants a rule for deciding what stays. The vendor facts below come from three pages read on December 6, 2026: the AGENTS.md site, Claude Code's memory page and Codex's AGENTS.md guide. The keep-or-cut test in the next section is our own call, built from what those pages say.

What the three sources say

The AGENTS.md site describes the file as "A simple, open format for guiding coding agents, used by over 60k open-source projects." On structure it says: "No. AGENTS.md is just standard Markdown. Use any headings you like; the agent simply parses the text you provide." Its two example files use headings such as "Setup commands" and "Code style", and "Dev environment tips", "Testing instructions" and "PR instructions".

Claude Code's memory page says: "Claude treats CLAUDE.md files as context, not enforced configuration." It also says: "The more specific and concise your instructions, the more consistently Claude follows them." It sets a size target: "target under 200 lines per CLAUDE.md file. Longer files consume more context and reduce adherence." And it warns: "if two instructions contradict each other, Claude may pick one arbitrarily."

Codex's guide says Codex "stops adding files once the combined size reaches the limit defined by project_doc_max_bytes (32 KiB by default)." Its advice on review rules is: "Keep rules concise, explain the behavior to flag and any safe path or exception, and reserve formatting and lint checks for CI."

A keep-or-cut test for each line

Ask four questions of every line, in this order. A line that fails any of them moves or goes.

First, can the agent learn it by reading the code? A line that says the project uses TypeScript tells an agent what it will see in the first file it opens. Claude Code's page says the same about its own first draft: after /init, "Refine from there with instructions Claude wouldn't discover on its own."

Second, is it concrete enough to check? Claude Code's page gives three pairs. It prefers "Use 2-space indentation" to "Format code properly", "Run `npm test` before committing" to "Test your changes", and "API handlers live in `src/api/handlers/`" to "Keep files organized". If you cannot tell whether a line was followed, rewrite it until you can.

Third, does a tool already enforce it? Codex's page tells review rules to leave formatting and lint checks to CI. The same holds for the whole file: a rule that a failing check will catch anyway only adds length.

Fourth, does it apply in every session, in every folder? The AGENTS.md site says "The closest AGENTS.md to the edited file wins; explicit user chat prompts override everything." A rule for one package belongs in that package's own file, so the root file stays short and nothing in it contradicts a nested one.

Where a cut line goes

A cut line does not have to disappear. Rules for one part of a repo go in a nested AGENTS.md; the AGENTS.md site says agents read the nearest file in the directory tree. A decision and its reasons go in a decision record that the root file points to; our guide on writing one is linked below. A check that can be run goes in CI.

Claude Code's page also says that for "a multi-step procedure or only matters for one part of the codebase", a skill or a path-scoped rule is the better home. That is Claude Code's feature, so it is not a place other agents will look.

Keeping the file honest over time

A file that was right in March is wrong when a command is renamed in June. Claude Code's page names the risk in its own words, "outdated or conflicting instructions", and says to review the files periodically. Our call is to give the file an owner and review it whenever a build or test command changes, because a wrong command costs more than a missing one.

In Almanac, which we make, an AGENTS.md or CLAUDE.md is one of a workspace's key docs. When an agent changes a key doc, the change becomes a suggested edit that a person approves, and history shows who changed it and why, so a rule an agent added cannot slip in unseen. Almanac holds a team's docs as plain markdown, so the file stays a plain file that Claude Code, Codex and other agents can read. It is not required for any of the advice above, and a repo with a careful owner does fine without it.

Questions people ask

How long should an AGENTS.md be?

There is no single number for AGENTS.md. Claude Code's page says to "target under 200 lines per CLAUDE.md file", and Codex's guide gives a combined limit of 32 KiB by default. Shorter than both is fine if the file covers what the agent cannot learn from the code.

Does AGENTS.md need a set format?

No. The AGENTS.md site says "AGENTS.md is just standard Markdown" and that you can "Use any headings you like".

Does an agent always follow every line?

Not necessarily. Claude Code's page says it treats these files "as context, not enforced configuration". For a rule that must hold, use a check that fails, not only a line of text.

Which file wins when two disagree?

The AGENTS.md site says "The closest AGENTS.md to the edited file wins; explicit user chat prompts override everything." Codex says files closer to your current directory override earlier guidance.

Related

Start free