# 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.

Source: https://fullbytedeveloper.com/blog/write-agents-md-that-agents-read
Published here: 2026-11-26, updated 2026-12-03

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):

```md title="AGENTS.md"
# 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 verified
```

Popular 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:

```bash
test -f /agent/repos/fullbytedeveloper-website/AGENTS.md && head -n 3 /agent/repos/fullbytedeveloper-website/AGENTS.md
```

Captured output:

```text
# Working on Full Byte Developer

**The rulebook is brain AGENTS.md** (https://github.com/kamilikamil/fullbytedeveloper-socials-brain, sibling
```

Your file will name your own install and test commands; the point is the file exists where agents look [1].

## Draw the shared instruction hub

<figure>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 720 280" role="img" aria-label="AGENTS.md feeds Cursor Codex and Claude Code; README stays for humans">
  <defs>
    <marker id="arrowAgentsMd" markerWidth="10" markerHeight="10" refX="8" refY="3" orient="auto">
      <path d="M0,0 L8,3 L0,6 Z" fill="#14b8a6"/>
    </marker>
  </defs>
  <rect x="0" y="0" width="720" height="280" rx="12" fill="#0b1f3a"/>
  <rect x="260" y="24" width="200" height="64" rx="8" fill="#123052" stroke="#f59e0b" stroke-width="2"/>
  <text x="292" y="52" fill="#f59e0b" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">AGENTS.md</text>
  <text x="280" y="72" fill="#cbd5e1" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">install / test / PR</text>
  <path d="M280 88 V120" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowAgentsMd)"/>
  <path d="M360 88 V120" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowAgentsMd)"/>
  <path d="M440 88 V120" stroke="#14b8a6" stroke-width="3" fill="none" marker-end="url(#arrowAgentsMd)"/>
  <rect x="40" y="128" width="160" height="56" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="84" y="162" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">Cursor</text>
  <rect x="280" y="128" width="160" height="56" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="328" y="162" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">Codex</text>
  <rect x="520" y="128" width="160" height="56" rx="8" fill="#123052" stroke="#14b8a6" stroke-width="2"/>
  <text x="548" y="162" fill="#f8fafc" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">Claude Code</text>
  <rect x="120" y="208" width="480" height="48" rx="8" fill="#123052" stroke="#64748b" stroke-width="2"/>
  <text x="160" y="238" fill="#cbd5e1" font-family="ui-sans-serif, system-ui, sans-serif" font-size="14">README.md stays for humans; AGENTS.md holds agent gates [1]</text>
</svg>
</figure>

*One shared file beats three slightly different pasted setups that drift apart every week.*

## 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]:

1. Only `AGENTS.md` (no project `CLAUDE.md` / `CLAUDE.local.md` above): Claude reads your `AGENTS.md`.
2. `AGENTS.md` plus a project `CLAUDE.md` or `CLAUDE.local.md`: Claude reads your `CLAUDE.md` files only.
3. A `CLAUDE.md` that imports `AGENTS.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]:

```md title="CLAUDE.md"
@AGENTS.md

## Claude-only notes
- Use a PreToolUse hook for hard blocks; markdown is guidance, not enforcement
```

Relative `@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](/blog/instruction-map) [3]. Related: [Where each Claude Code instruction belongs](/blog/claude-md-where-instructions-belong), [Rewrite AGENTS.md rules with a checklist](/blog/rewrite-agents-md-rules-checklist), [Claude Code settings load order](/blog/claude-code-settings-load-order), [Constrain AI coding agent scope](/blog/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](/blog/rewrite-agents-md-rules-checklist) [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](/blog/rewrite-agents-md-rules-checklist) 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](/blog/instruction-map) open [3]. For engine work that needs playtest log triage next to those instructions, continue on [Claude Code for game development](/blog/claude-code-for-game-development).

Browse the [AI agents topic](https://fullbytedeveloper.com/blog/topic/ai-agents).

Send this to the friend who pastes the same how to run tests paragraph into every agent chat.

Image: Central glowing blue vertical slab on a grey pedestal connected by cyan data paths to four grey cubes arranged around it on a dark gridded floor with concentric floor rings.
https://fullbytedeveloper.com/media/write-agents-md-that-agents-read/write-agents-md-that-agents-read-venice.webp
One instruction hub feeds every coding agent node; keep install and test commands in that shared file.

## Sources

1. [AGENTS.md format site](https://agents.md/)
2. [Claude Code docs: How Claude remembers your project (memory)](https://code.claude.com/docs/en/memory)
3. [Which instruction file each coding agent actually reads](https://fullbytedeveloper.com/blog/instruction-map)
4. [Rewrite AGENTS.md rules with a checklist](https://fullbytedeveloper.com/blog/rewrite-agents-md-rules-checklist)
