A developer opens a fresh terminal, starts a conversation with their AI coding agent of choice, and asks it to add a small feature to a repo they have worked in for months. The agent responds by asking which test runner the repo uses, where the build command lives, and whether it should commit at the end.
The same questions came up in the last conversation. They will come up in the next one.
Each major tool now solves this problem the same way: a markdown file at the repo root that the agent reads automatically before responding to any request. Anthropic’s Claude Code reads CLAUDE.md, the most widely used of the three. OpenAI’s Codex reads AGENTS.md, based on a shared spec at agents.md that is slowly being adopted by other tools. Google’s Gemini CLI reads GEMINI.md. The names differ. The convention is the same.
This post is the cross-tool explainer of that convention: which file each agent reads, why the format is markdown, what belongs inside, and where the convergence on agents.md is heading.
What You’ll Learn
This guide is for developers and AI power users who work with two or more coding agents (Claude Code, Codex CLI, Gemini CLI, Cursor, Aider, Copilot) and have noticed every tool now wants a markdown file at the repo root for project context.
Readers will finish with three layers installed. First, the convention itself: a single markdown file, committed to source control, read automatically by the agent on every conversation. Second, the file map: which agent looks for which filename, and where the global counterpart lives in the user’s home directory. Third, the contents reference: the seven canonical sections most teams converge on, and the anti-patterns that make the file useless or worse.
Why AI Coding Agents Need a File at All

A pretrained model knows the language, the framework, and the standard library. It does not know that this repo uses ESM modules, ships a CLI to npm under a scoped name, runs tests with Vitest in watch mode, and never mocks the database in integration tests.
That context has to come from somewhere outside the model’s weights. Without it, every conversation starts from zero. The agent re-discovers the test runner by reading package.json, re-discovers the build command by trying three wrong ones, re-asks whether to commit at the end, and re-confirms which directory the user is working in.
A short list of the kinds of context a model cannot infer:
- The build and test commands the project actually uses, including arguments and flags
- Naming conventions for files, components, branches, and commits
- Forbidden actions, like dropping tables, force-pushing to main, or installing new dependencies without approval
- In-flight migrations, deprecated paths, code that looks active but is being torn out
- Internal acronyms, product names that conflict with public terms, domain glossary
- Deployment targets, environment names, secret loading paths
Some of this lives in the codebase and the agent can find it. A lot of it does not. The instructions file is the durable answer to “where does the agent learn what makes this repo specific?”. It works the same way a SaaS docs program makes a product legible to AI assistants reading the site, only the consumer here is a coding agent reading a repo instead of a chat assistant reading a docs page.
The Convention in One Paragraph
A plain markdown file, committed to the repository root, named in a tool-recognized way (AGENTS.md, CLAUDE.md, GEMINI.md, or one of a small set of accepted variants), that the agent loads automatically before responding to any request in that repo.
No JSON, no YAML wrapper, no plugin install, no register_* call. The agent reads the file as part of system prompt assembly. Anything in the file is in scope for every conversation in that repository.
The same paragraph could be written about the way agents read a public website at query time: one file, machine-readable, loaded before the answer is composed. The repo file is the source-control side of the same idea.
The agents.md File Map: Which Agent Reads Which File
The convention exists in parallel across every major coding agent. The filename differs, the location is consistent (the repo root, with one exception), and a global counterpart lives in the user’s home directory:
| Tool | Project file | Global file | Notes |
|---|---|---|---|
| Claude Code (Anthropic) | CLAUDE.md | ~/.claude/CLAUDE.md | Also reads nested CLAUDE.md files in subdirectories |
| Codex CLI (OpenAI) | AGENTS.md | ~/.codex/AGENTS.md | Reference implementation of the shared agents.md spec |
| Gemini CLI (Google) | GEMINI.md | ~/.gemini/GEMINI.md | Reads project file, then merges with global |
| Cursor | .cursor/rules/*.md | n/a | Older single-file .cursorrules still recognized |
| Aider | CONVENTIONS.md | n/a | Loaded only when explicitly listed via --read |
| GitHub Copilot | .github/copilot-instructions.md | n/a | Repo-level only, IDE support varies |
A few details matter. Copilot is the only major tool that puts the file inside .github/ instead of the repo root, which is worth calling out because the muscle memory from the others does not carry over. Aider does not read its file automatically; the user has to pass it explicitly, which means a team relying on Aider needs to standardize the --read flag in shared scripts.
Several tools now also accept AGENTS.md as a fallback when the tool-specific file is absent. The fallback is partial across the ecosystem and changes from release to release, so the safer pattern is to write AGENTS.md first and add a tool-specific file only when a tool needs different behavior.
The reference spec for AGENTS.md lives at agents.md. It is an OpenAI-led proposal, written to be implementable by any tool, which is the reason a handful of tools outside OpenAI’s ecosystem have started accepting the filename as a fallback.
Why Markdown and Not JSON or YAML
The file is markdown for five reasons, in order of importance.
LLMs were trained on markdown. GitHub READMEs, Stack Overflow answers, technical blogs, documentation sites, internal wikis exported to text. The model handles markdown structure natively. There is no parser to fail, no schema to validate against, no missing-comma failure mode that drops the file silently. A markdown file with one header out of place is still a usable file.
Headings are skimmable. An agent loading a 4,000-token instruction file can selectively attend to the sections relevant to the current task. A request about test failures can pull the “How to test” section to the front of context. A request about deployment can pull the “Deployment targets” section. JSON blobs flatten that structure into key-value pairs the model has to scan linearly.
Git diffs are clean. A change to one rule shows up as a one-line diff in code review. JSON pretty-printing introduces spurious diffs whenever a key gets reordered by a tool. YAML’s whitespace sensitivity creates the same problem in the other direction.
Humans read it too. The same file is the project’s onboarding doc for new humans. New team members read AGENTS.md to learn the conventions, the build commands, and the forbidden actions. Two audiences, one artifact, no drift.
No tool lock-in. A markdown file moves between Claude Code, Codex CLI, and Gemini CLI without modification. A YAML config tied to a vendor schema does not. The file is portable in the way a README.md has always been portable.
The architectural lesson: the file is markdown because the consumer is a model trained on markdown, and the file’s primary job is to be read, not to be parsed.
What Belongs Inside the File
Most teams converge on the same seven sections. The exact order varies; the contents do not.
Project overview
One paragraph naming what the project is, who it serves, and what the agent should assume about scope. Three sentences, not three paragraphs. The agent is not the audience for marketing copy; it needs enough context to recognize when a request is in scope and when it is wandering into unrelated territory.
How to build and run
The exact commands. pnpm install, pnpm dev, cargo run --release, python -m pytest. The agent will use these. If they require a specific Node version, a virtualenv, or a .env file, name the requirement next to the command.
## Build and run
- Install: `pnpm install` (requires Node 20)
- Dev server: `pnpm dev` (port 3000)
- Production build: `pnpm build`
How to test
The test runner, the command, the convention for fixtures, the rule for snapshot tests. Anything an agent could break by guessing. If integration tests hit a real database and mocking is forbidden, name the rule. If the team uses Vitest with --run for one-shot runs and --watch is the default, name that.
Conventions
Naming, file layout, import order, error handling style, where state goes, where logic goes. Specific rules beat philosophical principles. “Use named exports, never default exports” beats “follow modern JavaScript style”. “Errors propagate up, no try/catch except at module boundaries” beats “handle errors carefully”.
Forbidden actions
A short list of things the agent must not do without explicit approval. Common entries:
- Drop or alter database tables
- Force-push to main or master
- Modify CI configuration without flagging
- Commit
.envor files matching*.secret - Install new dependencies without confirming
- Use
--no-verifyon commits
Each entry should be one line. The agent is going to scan this list under token pressure on every action; the shorter and sharper each rule, the more reliably it gets respected.
Useful commands
A short reference of CLI invocations the agent will need but cannot derive from package.json or Makefile alone. Custom scripts, repo-specific tools, migration commands, deployment hooks. One line per command, with what it does.
File map and glossary
A short tree or bulleted list naming the top-level directories and what lives in each. The agent can read the codebase, but the file map saves dozens of file-listing calls when context is tight. The glossary handles domain terms, internal acronyms, and product names that collide with public terms (“Studio” inside this repo means the admin UI, not the Anthropic product).
Frame each section as “the question the agent will otherwise have to ask the user”. The file exists to absorb the questions that come up in every conversation.
What Does Not Belong
The discipline section. A short, dense file beats a long, comprehensive one because the file is read on every call.
Do not duplicate the codebase. If the build command lives in package.json, the file should name the script (pnpm test) and not paste the script body. The agent reads the codebase too.
Do not write architectural philosophy. “Keep it simple”, “favor composition over inheritance”, “clean code matters” are not actionable. They take tokens and change nothing about agent behavior.
Do not write decisions that change weekly. Sprint goals, current bug priorities, in-flight refactors. These belong in tickets or PR descriptions, not in a file every agent reads on every call. By the time the agent picks them up, they are stale.
Do not paste secrets. API keys, OAuth client IDs, internal hostnames, database URLs. The file is committed to git and read by every model invocation. Treat it the way a README.md should be treated and assume it is public.
Do not write things the agent can find. “The User model is in src/models/User.ts” is wasted tokens if the agent can run a one-line search. Reserve the file for rules and context that cannot be derived from the code.
Do not turn it into a manifesto. A two-thousand-line CLAUDE.md is worse than no file. The agent reads the entire thing on every call. Length is a real cost, paid in tokens, latency, and the dilution of the rules that actually matter.
The token cost is concrete. A 5,000-token AGENTS.md is 5,000 tokens prepended to every conversation in the repo. On a model billed at standard input rates, that is real money over a week of work, and it is real attention budget that the model now cannot spend on the actual task.
The Global vs Project Hierarchy
Most agents support both a personal file in the user’s home directory and a project file at the repo root. The two layers serve different purposes.
The global file holds personal preferences that follow the user across every repo. Preferred response style, default tools, personal forbidden actions, languages the user works in.
# ~/.claude/CLAUDE.md (excerpt)
- Prefer terse responses, no filler.
- Default languages: Python, TypeScript, Go.
- Never run destructive git commands without confirmation.
- Use `gh` for all GitHub operations, not the web UI.
The project file holds context specific to one codebase. Build commands, test runners, conventions, forbidden actions, file map.
# AGENTS.md (excerpt, project root)
- Build: `pnpm build`. Tests: `pnpm test`.
- Use named exports only, never default exports.
- Integration tests hit a real Postgres; never mock the database.
- Database migrations live in `src/db/migrations`. Run with `pnpm migrate`.
The agent loads both, with project rules taking precedence on conflicts. The canonical paths repeat the pattern across tools:
- Claude Code:
~/.claude/CLAUDE.mdplus repoCLAUDE.md - Codex CLI:
~/.codex/AGENTS.mdplus repoAGENTS.md - Gemini CLI:
~/.gemini/GEMINI.mdplus repoGEMINI.md
Claude Code adds one wrinkle: it also reads nested CLAUDE.md files in subdirectories, merging them in when the agent works in that subdirectory’s path. This is a Claude-specific behavior; the other tools currently do not nest.
One File or Several? The Convergence on AGENTS.md
Each tool started with its own filename because each ecosystem grew up independently. Anthropic shipped Claude Code with CLAUDE.md and it is the file most AI developers have actually written. OpenAI proposed AGENTS.md as a shared spec at agents.md and shipped it in Codex CLI. Google followed with GEMINI.md. Several tools now read AGENTS.md as a fallback when the tool-specific file is absent, which is the softest signal yet that the convention is drifting toward a shared filename.
The practical recommendation for a team that uses more than one agent: write one AGENTS.md as the source of truth, then add small CLAUDE.md, GEMINI.md, or other tool-specific files only for behavior the canonical file cannot capture. A common pattern is a one-line CLAUDE.md that says “see AGENTS.md” and a small extension for Claude Code’s specific feature set (slash commands, hooks, MCP servers).
# CLAUDE.md
See AGENTS.md for project context. Claude-specific notes below.
## Slash commands
- /test: run `pnpm test` and summarize failures
- /deploy: run `pnpm build` then `./scripts/deploy.sh`
The honest framing: the convention is converging on AGENTS.md but is not yet a single hard standard. Tools add and drop fallbacks across releases. A reader who writes a clean, tool-agnostic AGENTS.md today will not have to rewrite it when the convention finishes settling.
The Pattern That Repeats: Markdown as the Universal AI Contract

The AGENTS.md family is the source-control side of a larger pattern. On the public web, sites are publishing llms.txt and llms-full.txt to give AI assistants a structured view of the site without HTML scraping. In source control, repos are publishing AGENTS.md to give AI coding agents a structured view of the project without grepping every file.
Both are markdown. Both are committed and version-controlled. Both are read automatically by agents. Both encode the same idea: the AI is now a primary consumer of the project’s documentation, and the project should publish a clean, machine-readable version for that consumer.
Markdown ended up at the center of the convention because it is the format both audiences (humans and the models humans use) read natively. The file is portable, diff-friendly, parser-free, and skimmable. Every coding agent landed on the same answer because the constraints pointed there.
The takeaway: the markdown file at the repo root is now part of the project’s contract with every AI agent that opens it. Writing one well is ten minutes of work that pays off on every conversation that follows.
Get Cleaner Inputs Into Your Agents
The same problem AGENTS.md solves at the repo level shows up at the page level. AI agents read pages, agents read repos, and both produce better answers when the input is clean markdown instead of raw HTML or PDF.
The CopyMarkdown extension converts any webpage to clean markdown in one click, ready to drop into Claude, ChatGPT, Cursor, or any agent that reads context from a paste. It is the page-level companion to the repo-level work this post describes.