AGENTS.md is an open, plain Markdown file format placed in a software repository to give AI coding agents the project-specific instructions they need, such as how to build, test and style the code. In AI for coding, it acts as a README written for agents: humans read the README, while agents read AGENTS.md before they edit files or run commands.
The format emerged in 2025 as a shared convention backed by several agent vendors, replacing a patchwork of tool-specific instruction files. It has no required schema, which keeps adoption simple, and its value depends almost entirely on how precise, current and verifiable its contents are.
How agents discover and apply AGENTS.md
A compatible agent looks for AGENTS.md at the repository root when a session starts and loads its text into the model context as standing instructions. The file is ordinary Markdown with free-form headings, so the model interprets it the same way it interprets a well-written prompt.
Large repositories and monorepos can contain nested AGENTS.md files in subdirectories. By convention, the closest file to the edited code takes precedence, so a package-level file can override root-level guidance for that package. An explicit instruction from the user in the chat still outranks anything written in the file.
The table below summarizes how instruction sources usually interact in an agent session.
| Source | Scope | Typical priority |
|---|---|---|
| User prompt | Current task | Highest |
| Nested AGENTS.md | One directory subtree | High for files in that subtree |
| Root AGENTS.md | Whole repository | Default project guidance |
| Agent built-in defaults | All projects | Lowest, used when nothing else applies |
What a useful AGENTS.md contains
An effective file contains facts an agent cannot reliably infer from the code alone. The most valuable entries are exact commands for setup, building, linting and testing, because agents use them to verify their own changes before reporting success.
| Section | Example content | Why agents need it |
|---|---|---|
| Setup commands | pnpm install, required runtime version | Avoids guessing package managers |
| Build and test | pnpm test --filter api | Enables self-verification |
| Code style | Strict TypeScript, no default exports | Keeps output consistent |
| Project structure | Where services, schemas and fixtures live | Speeds up navigation |
| Boundaries | Never edit generated files or migrations | Prevents harmful changes |
| Pull request rules | Commit message format, required checks | Matches team workflow |
| Security notes | No secrets in code, use the vault client | Reduces risky behavior |
Concise files work better than long ones. Every line consumes context window tokens on every task, and vague advice such as “write clean code” adds cost without changing behavior. A practical target is one to three screens of text at the root, with detail pushed into nested files.
AGENTS.md compared with other instruction files
Before the shared convention, each tool read its own file, and teams using several assistants had to maintain duplicate instructions. AGENTS.md is a vendor-neutral form of the broader project rules file concept, and many tools now read it directly or let a tool-specific file point to it.
| File | Primary reader | Format | Portability |
|---|---|---|---|
| AGENTS.md | Many coding agents | Free-form Markdown | Cross-tool |
| README.md | Human contributors | Free-form Markdown | Universal, but not agent-focused |
| CLAUDE.md | Claude Code | Markdown with imports | Tool-specific |
| .cursor/rules | Cursor | Rule files with metadata | Tool-specific |
| copilot-instructions.md | GitHub Copilot | Markdown | Tool-specific |
| CONTRIBUTING.md | Human contributors | Markdown | Process guidance only |
A common migration pattern is to make AGENTS.md the single source of truth and reduce tool-specific files to a short reference or a symbolic link, so that every assistant follows identical project rules.
Writing and maintaining the file
AGENTS.md should be treated as code, not documentation: it lives in version control, changes through reviewed pull requests and must stay in sync with the build. A stale test command is worse than none, because the agent will trust a broken instruction and may misreport failures.
| Mistake | Effect on agents | Fix |
|---|---|---|
| Outdated commands | Failed or skipped verification | Run commands in CI to validate them |
| Vague style advice | No measurable change | State concrete, checkable rules |
| Very long file | Wasted context, diluted priorities | Move detail into nested files |
| Contradicting the linter | Agent loops between fixes | Defer formatting to tooling |
| Secrets or internal URLs | Exposure through logs or outputs | Reference secure tooling instead |
Teams often ask the agent itself to propose updates after a session reveals a missing rule, then review that change like any other diff. This keeps the file grounded in observed agent mistakes rather than speculation.
Limitations and security considerations
AGENTS.md is guidance, not enforcement. Language models follow it probabilistically, so critical rules such as protected directories or forbidden commands also need hard controls in permissions, sandboxes, branch protection and CI checks.
- Prompt injection risk: a malicious contributor can hide harmful instructions in the file, so changes need code review like any executable configuration.
- No guaranteed support: tools differ in whether they read nested files and how they merge them.
- No standard schema: free-form text cannot be validated automatically beyond basic linting.
- Context cost: every instruction competes with source code for the model’s limited attention.
Understanding it simply
AGENTS.md is a note for AI helpers that write code. It sits in the project folder. It tells the AI how this project works.
Think of a new team member on day one. A good colleague hands over a short sheet: how to start the app, how to run the tests and which files to leave alone. AGENTS.md is that sheet, but for an AI assistant. With it, the assistant makes fewer wrong guesses and checks its own work.
Applied in practice
A ten-person team maintains a TypeScript monorepo with a web app, an API and a shared design library. Developers use two different coding agents, and both kept running the wrong test runner and editing generated API client files. The team writes a root AGENTS.md of about 60 lines with setup commands, the test command for each package, naming rules and a list of directories that must never be edited by hand.
They add a nested AGENTS.md in the API package that explains database migration rules. After two weeks, reviewers report that agent pull requests pass CI on the first run far more often, and edits to generated files stop appearing. The file now changes through normal review, and a CI job runs every listed command nightly so that broken instructions are caught early.