Write an AGENTS.md coding agents actually read
Put build, test and convention notes in AGENTS.md so Codex, Cursor, Claude Code and peers share one file.
Published here , updated · 4 sources · Resume reading
You paste the install and test commands into every agent chat, then wonder why Cursor, Codex, and Claude Code invent different setups. Put those commands in one AGENTS.md at the repo root. agents.md calls it a README for agents: build steps, tests, and conventions that would clutter a human README, used in over 60k open-source projects [1].
Add a minimal AGENTS.md
Create AGENTS.md next to README.md. The format is plain Markdown with no required fields [1]. Cover what an agent needs to ship a change: install, test, style, and PR gates [1].
Minimal shape drawn from the site's examples (swap pnpm for your package manager):
# AGENTS.md
## Setup commands
- Install deps: pnpm install
- Start dev server: pnpm dev
- Run tests: pnpm test
## Code style
- TypeScript strict mode
- Prefer the project's existing patterns
- Prefer small diffs over drive-by refactors
## Testing instructions
- Run pnpm test before finishing
- Fix failures before you ask for review
- After import moves, run the project lint command
## PR instructions
- Title: short and literal
- Include what you verifiedPopular sections on agents.md also include project overview and security considerations [1]. Add only what a new session would otherwise re-ask.
This website repo already keeps an AGENTS.md at the root. A quick existence check on this host:
test -f /agent/repos/fullbytedeveloper-website/AGENTS.md && head -n 3 /agent/repos/fullbytedeveloper-website/AGENTS.mdCaptured output:
# Working on Full Byte Developer
**The rulebook is brain AGENTS.md** (https://github.com/kamilikamil/fullbytedeveloper-socials-brain, siblingYour file will name your own install and test commands; the point is the file exists where agents look [1].
Keep README for humans
agents.md states the split on purpose: README stays for quick starts, project description, and contribution guides; AGENTS.md holds the agent-facing detail [1]. One file works across many listed tools (Codex, Cursor, goose, opencode, Copilot coding agent, and others named on the site) [1]. Claude Code can read the same file too [2]. The format is stewarded by the Agentic AI Foundation under the Linux Foundation [1].
In a monorepo, agents.md says you can nest another AGENTS.md per package. Agents read the nearest file in the directory tree; the closest one wins [1]. At the time of writing, the agents.md FAQ notes the main OpenAI repo had 88 of these files [1]. An explicit chat prompt still overrides the files [1].
Make Claude Code load the same file
Claude Code can read AGENTS.md as project instructions so a multi-tool repo does not need a second copy [2]. Default table from the memory docs [2]:
- Only
AGENTS.md(no projectCLAUDE.md/CLAUDE.local.mdabove): Claude reads yourAGENTS.md. AGENTS.mdplus a projectCLAUDE.mdorCLAUDE.local.md: Claude reads yourCLAUDE.mdfiles only.- A
CLAUDE.mdthat importsAGENTS.md: both, through the import.
Direct AGENTS.md reading needs Claude Code v2.1.277 or later [2]. Files that count for the "has CLAUDE.md" check: CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md in the working directory or above it. Your ~/.claude/CLAUDE.md, managed org instructions, and .claude/rules/ do not block AGENTS.md [2].
Common failure: you keep both a project CLAUDE.md and an AGENTS.md, with no import. Claude then reads the CLAUDE files only, and the shared agent file is ignored [2]. Fix it with an @AGENTS.md import (or delete the empty CLAUDE file, or change Project instructions) [2]:
@AGENTS.md
## Claude-only notes
- Use a PreToolUse hook for hard blocks; markdown is guidance, not enforcementRelative @path imports resolve relative to the file that contains them [2]. A sentence that tells Claude in words to "go read AGENTS.md" is not an import; Claude may never open the file [2]. Keeping an @AGENTS.md import never makes Claude read the file twice [2].
Confirm the file is in context
In an interactive Claude Code session that loaded AGENTS.md because no project CLAUDE file blocked it, you should see a line such as no CLAUDE.md found; AGENTS.md loaded: /home/you/repo/AGENTS.md [2]. If the file is missing from context, check for a stray CLAUDE.local.md, upgrade past v2.1.277, or keep the @AGENTS.md import for sessions that cannot load AGENTS.md directly [2]. Claude Code treats instruction files as context, not enforced configuration; use a PreToolUse hook when an action must be blocked [2].
For the cross-agent map of which tool reads which file, see which agent reads which instruction file [3]. Related: Where each Claude Code instruction belongs, Rewrite AGENTS.md rules with a checklist, Claude Code settings load order, Constrain AI coding agent scope.
Write rules agents can follow
Prefer exact commands over vibes. "Run the tests" is weaker than pnpm test. Prefer existing project patterns over aspirational style guides that conflict with the codebase. Prefer small diffs; agents amplify drive-by refactors when the file invites them [1].
Security notes belong in AGENTS.md when they are operational (never commit .env, never push force to main). Hard blocks still need hooks or CI, because markdown is guidance [2]. When rules rot, trim them with the checklist on rewrite AGENTS.md rules [4].
Nest package-level files only when install or test commands truly differ. A nested file that repeats the root verbatim adds merge noise without changing agent behavior [1].
Keep the file short enough to load
Agents have context budgets. A 4,000-line dump of every historical decision crowds out the three commands that matter today. Prefer links to deeper docs for rare paths, and keep install, test, lint, and PR gates near the top [1]. When a rule only applies to one package, put it in that package's nested AGENTS.md instead of forcing every session to read it [1].
Review the file when tooling changes. A stale yarn test line after you moved to pnpm is how agents invent broken setups again. The checklist on rewrite AGENTS.md rules helps trim dead rules [4].
Monorepo nesting without chaos
Nest only when commands differ. If every package uses the same pnpm test, one root file is enough [1]. If a package needs a special Docker bootstrap, put that bootstrap in the nested file and leave the root focused on shared gates. Remember the closest-file-wins rule when two files disagree [1].
Chat prompts still override files. Use that for one-off experiments, then fold durable lessons back into AGENTS.md so the next session does not depend on your memory [1].
Mistakes that leave agents guessing
Keeping a project CLAUDE.md and an AGENTS.md with no @AGENTS.md import, then blaming Claude for ignoring the shared file [2].
Pasting a paragraph of setup into every chat instead of updating the file once [1].
Writing essay-length philosophy in AGENTS.md while omitting the one test command that matters [1].
Using a verbal "please read AGENTS.md" sentence as if it were an import [2].
Duplicating conflicting rules across root and nested files so the closest file wins in a surprising directory [1].
Treating AGENTS.md as enforced security. Hooks and CI still own hard blocks [2].
Leaving stale package-manager commands after a migration so every agent fails the first test run [1].
What you have now
A shared agent instruction file pattern with Claude Code load rules from the memory docs [1][2]. Your next commit should add or trim AGENTS.md until an agent can install, test, and open a PR without re-asking the same setup questions. For which tool reads which file, keep which agent reads which instruction file open [3]. For engine work that needs playtest log triage next to those instructions, continue on Claude Code for game development.
Browse the AI agents topic.
Send this to the friend who pastes the same how to run tests paragraph into every agent chat.

Keep this guide
Filed under AI agents, Claude Code
Questions about this guide
What is AGENTS.md?
Per agents.md, a simple open format for guiding coding agents: a dedicated place for build steps, tests and conventions that would clutter a README. The site says it is used by over 60k open-source projects.
Does Claude Code read AGENTS.md?
Per Claude Code memory docs: by default Claude reads AGENTS.md when no CLAUDE.md or CLAUDE.local.md exists in the working directory or above it. Reading AGENTS.md directly requires Claude Code v2.1.277 or later. If both exist, Claude reads CLAUDE.md files only unless you import AGENTS.md or change Project instructions.
Should I replace README.md?
No. agents.md says README.md stays for humans; AGENTS.md holds the extra agent-focused context.
What if nested AGENTS.md files conflict?
Per agents.md, the closest AGENTS.md to the edited file wins among nested files, and an explicit chat prompt overrides everything.
How do I make Claude Code load AGENTS.md when CLAUDE.md exists?
Add an @AGENTS.md import in CLAUDE.md, or remove the empty CLAUDE file, or change Project instructions so the shared file is included.
Sources
- AGENTS.md format siteagents.md
- Claude Code docs: How Claude remembers your project (memory)code.claude.com
- Which instruction file each coding agent actually readsfullbytedeveloper.com
- Rewrite AGENTS.md rules with a checklistfullbytedeveloper.com