In short
AGENTS.md is a Markdown file in your repo, giving coding agents project instructions, often described as a README for agents. Include setup, build and test commands, code style, testing rules, security notes and PR guidelines. There are no required fields. Keep it short and specific. In a monorepo, nested files can apply to subprojects, with the nearest file taking priority.
What it is
AGENTS.md is an open format for instructions to AI coding agents. Its site calls it “a README for agents”: READMEs are for people, and this file holds the extra context that agents need. It says that over 60,000 open-source projects use it.
It's now stewarded by the Agentic AI Foundation under the Linux Foundation. There's no special syntax. As its FAQ says, it's just standard Markdown, and you can use any headings you like.
Which tools read it
Support is broad. Sources list OpenAI Codex, Google Gemini CLI, Devin, Windsurf, Jules, Cursor, VS Code with GitHub Copilot, Zed and Aider, among others. See Claude Code vs Codex and Cursor vs Codex.
Claude Code can read it too, although by default only when there's no CLAUDE.md in your working directory or above it. If you have both, you can import it with @AGENTS.md in your CLAUDE.md. See how to write a CLAUDE.md file.
Exact behaviour differs by tool and version, so check the docs for the ones you use.
A template
# AGENTS.md
## Project
Booking app for dental clinics. PHP back end, MySQL, vanilla JS front end.
## Setup
- Copy .env.example to .env
- Start: docker compose up
- Seed test data: php scripts/seed.php
## Commands
- Lint: composer lint
- All tests: composer test
- One test: vendor/bin/phpunit tests/BookingTest.php
- Run lint and tests before you say a task is finished.
## Code style
- Follow the patterns in src/Bookings as the reference
- All SQL uses prepared statements through src/Db.php
- User-facing text goes through t() for translation
## Testing
- Every bug fix gets a regression test
- Don't weaken or delete a test to make it pass; explain the failure
## Security
- Never log patient names or phone numbers
- Never read or print .env
- Check clinic_id on every query; clinics must never see each other's data
## Pull requests
- Small changes, one purpose each
- Title format: [area] what changed
- Describe how you tested it
The format's site suggests these same topics: project overview, build and test commands, code style, testing instructions and security considerations.
What makes it useful
Commands that work. This is the most valuable thing you can give. Many agents will try to run tests, if you tell them how. Test each command by copying it.
The non-obvious. “We use tabs” can be picked up from the code. “Invoices must never be deleted, only cancelled, for legal reasons” can't.
Specifics, not aspirations.
| Not useful | Useful |
|---|---|
| Write secure code | Check clinic_id on every query |
| Follow best practices | Use src/Bookings as the reference pattern |
| Test thoroughly | Run composer test before finishing |
| Be careful with data | Never log patient names |
A definition of done. Tell the agent what it has to do to finish. It prevents it from declaring success too early.
Examples. Point to a good file to copy. Models are excellent at following a pattern.
Things that went wrong before. If an agent keeps making a certain mistake, add a line about it.
What to leave out
- Everything the code already shows, such as the whole folder tree
- Long explanations. Link to them in
docs/, and let the agent read when relevant - Generic advice
- Secrets. This file's in your repo. See how to handle secrets and API keys.
- Details that change weekly
Each line uses up context on each task. Anthropic's guidance for CLAUDE.md is to target under 200 lines, because longer files reduce adherence. That's a sensible limit here, too. See context engineering vs prompt engineering.
Monorepos and nested files
You can place a file in each subproject:
/AGENTS.md General rules
/apps/web/AGENTS.md Web front-end rules
/services/api/AGENTS.md API rules
According to the spec's site, agents read the nearest file in the directory tree, so the closest one to the edited file takes priority, and direct chat prompts override all of them. Tools vary in how they handle this. Some combine files rather than replacing them, and Claude Code loads subdirectory files as it works. So don't rely on subtle override behaviour. Keep nested files focused on what's different.
/apps/web/AGENTS.md <- editing web code reads this
/services/api/AGENTS.md <- editing the API reads this
Getting started
- Ask your agent to draft it. “Read this repo and write an AGENTS.md with setup, commands, conventions and warnings. Only include what you can verify.”
- Cut the draft in half. Remove anything obvious.
- Check every command by running it.
- Add what only your team knows.
- Commit it, and review changes in pull requests.
- Try a small task and see whether it behaves better.
Don't expect perfection. Add to it whenever you find yourself repeating a correction.
Common mistakes
- Writing it once and forgetting it. A wrong command is worse than none.
- Treating it as a guarantee. Agents can ignore instructions, particularly in long sessions. If something must never happen, use CI, branch protection, permissions and hooks.
- Trusting one from elsewhere. Instruction files can carry malicious commands, and repos you clone might contain them. Read them before running an agent on unfamiliar code. See how to stop prompt injection.
- Duplicating rules across tools. Keep one source of truth, and link other files to it.
- Contradictions between this file and your actual code. Agents tend to follow the code, or get confused.
Also useful for people
A good AGENTS.md is a fairly accurate onboarding document. New developers can read it, too. Don't let it replace your README, though, as they serve different purposes: the README explains the project to users and contributors, while this one tells agents how to work on it.
How to tell if it's helping
Compare a few tasks before and after. Look for fewer corrections, correct test commands on the first attempt, and diffs that match your conventions. If an agent keeps ignoring a line, try making it more specific or moving it nearer the top. If nothing changes, then delete it.
If you'd like help getting your team productive with coding agents, book a call.
Common questions
What is AGENTS.md?
It's a plain Markdown file in your repository, giving AI coding agents instructions about your project, such as commands, conventions and warnings. It's described as a README for agents, is an open format, and has no required fields or special syntax.
What should I put in AGENTS.md?
Include a short project overview, setup, build and test commands, code style, testing rules, security notes and pull request guidelines. Focus on what agents can't work out from the code. Leave out secrets, generic advice and long explanations.
Does Claude Code use AGENTS.md?
According to its documentation, yes, when there's no CLAUDE.md in your working directory or above it. If you've got both, it reads CLAUDE.md by default, and you can import the other file using @AGENTS.md. Check the current docs for your version.
Where does AGENTS.md go?
Put it in the root of your repository. In a monorepo, you can add further files in subprojects, and agents generally use the nearest one to the file being edited. Keep nested files focused on what's different for that part.