A study across 138 real-world repositories found that developer-written AGENTS.md files reduce agent-generated bugs by 35-55%. LLM-generated instruction files, by the same analysis, actually made things worse. That gap tells you almost everything about what this file is and is not.
AGENTS.md is not memory. It is a briefing document that survives between sessions because it lives in version control, not because the agent retains anything. The distinction matters when you are deciding how much to trust your coding agent on day two of a multi-week refactor.
What the context file actually does (and what it doesn't)
AGENTS.md is a plain Markdown file at the repo root. When a coding agent starts a session, it reads the file and loads the contents as system-level context.
All the major formats - CLAUDE.md, AGENTS.md, .cursorrules - do the same conceptual job: giving the agent a persistent briefing that survives across sessions.
The reason this matters is simple:
AI models have no persistent memory. Every session starts blank. Without a configuration file, you would repeat the same instructions every time - your tech stack, coding conventions, project structure, deployment rules.
Agents can maintain long-term context of a project's goals, conventions, and architecture through dedicated files like CLAUDE.md or AGENTS.md, allowing them to retain context across sessions that can last for days or weeks.
In practice, that means the agent knows not to touch the payments/ module without a review, knows your test runner is pytest --tb=short, and knows the migration convention your team settled on last quarter - because you wrote it down.
What it cannot do: learn. A context file has no write-back. If your agent makes a decision in a session, that decision does not get stored anywhere unless a human edits the file afterward. This is different from in-model fine-tuning or a live memory layer like Mem0 or Zep. It is closer to a well-maintained onboarding doc that a new contractor reads before starting work.
The fragmented format problem every multi-tool team hits
The 2026 market has split into five categories of agentic coding tool: AI IDEs, CLI agents, cloud agents, GitHub-native agents, and open-source/local-first agents. Most engineering teams use at least two of them. That creates an immediate problem.
Claude Code looks for CLAUDE.md. Codex CLI reads AGENTS.md. Gemini CLI checks for GEMINI.md. Cursor has .cursorrules. GitHub Copilot uses copilot-instructions.md. Windsurf has .windsurfrules.
The result is a fragmented landscape where teams maintaining multi-tool workflows end up with duplicated context scattered across half a dozen files.
AGENTS.md is the closest thing to a universal format right now.
It is recognized by Codex CLI, Copilot CLI, Gemini CLI, Cursor, and Claude Code itself.
CLAUDE.md is Claude Code's native file, and it still has capabilities AGENTS.md does not standardize - most notably hierarchical loading and imports.
The Copilot situation is the most nuanced.
GitHub renamed Copilot coding agent to Copilot cloud agent on April 1, 2026
, and its handling of AGENTS.md is not a strict enforcement:
Copilot does not guarantee that every rule in AGENTS.md is followed as literally as Claude Code follows CLAUDE.md. Claude Code treats CLAUDE.md as authoritative configuration; Copilot treats AGENTS.md more like a very strong system prompt.
If your team uses both, a rule that Copilot "suggests" but Claude Code enforces produces different behavior on the same task - and that inconsistency is quiet enough that you might not notice it in a PR review.
| Tool | Native format | Reads AGENTS.md? | Enforcement |
|---|---|---|---|
| Claude Code | CLAUDE.md |
Yes (imports supported) | Authoritative |
| OpenAI Codex CLI | AGENTS.md |
Yes (canonical) | Authoritative |
| GitHub Copilot cloud agent | .github/copilot-instructions.md |
Yes (root + docs/) | Strong suggestion |
| Gemini CLI | GEMINI.md |
Partial | Strong suggestion |
| Cursor | .cursor/rules/*.mdc |
Partial | Strong suggestion |
| Windsurf | .windsurfrules |
No | - |
The practical answer for a team running multiple tools: maintain one canonical AGENTS.md as the source of truth, then symlink or auto-generate the vendor-specific files from it in CI. It is more work upfront. It is less work than maintaining four files that drift apart over six months.
What belongs in the file (and the thing nobody puts in it)
A well-written AGENTS.md should include stable project context, development commands, directory responsibilities, architecture rules, testing requirements, security boundaries, migration practices, restricted files, and completion-report expectations.
The thing most teams leave out: explicit scope limits.
The biggest risk from agentic coding tools is not bad code generation. The bigger risk is out-of-scope edits, weak permission boundaries, hidden token cost, unreviewed database migrations, unsafe shell commands, and over-trusting generated pull requests.
A line in AGENTS.md like Do not modify files under /infra without a human confirmation step is not a guarantee - but it is context the agent will weigh, and it is a written record of your team's intent that reviewers can check against.
AGENTS.md can tell the agent how the project is organized, which commands build and test it, what conventions to follow, and which changes are unsafe. It guides Copilot; it does not enforce rules or replace CI, code review, tests, or branch protection.
The CI and branch protection are what actually enforce the rules. The context file is closer to team norms than to a firewall.
The attack surface nobody mentioned at onboarding
Here is the non-obvious problem. The same property that makes AGENTS.md useful - it is read automatically on agent startup, before the user gives any task instructions - makes it an attractive injection surface.
The vendor pitch for AI coding tools is developer productivity. The reality is that .claude/settings.json and .mcp.json are no longer configuration files. They are execution vectors. They look like metadata. They function like installers. This applies to every AI coding tool that processes repository-level configuration, not just Claude Code.
Aim Labs found that Cursor instantly executed any new entry added to ~/.cursor/mcp.json with no confirmation, and that a suggested edit landed on disk and triggered execution even if the user rejected the suggestion. That collapses the whole chain: read hostile content, write config, execute code. Cursor fixed it in version 1.3.
The threat model for AGENTS.md specifically: if a malicious commit adds instructions to the file - "when generating code, also append the following to any outgoing request" - and your agent reads it as authoritative, it will follow those instructions.
According to the Gravitee State of AI Agent Security 2026 report, 80.9% of technical teams have pushed past planning into active testing or production, but only 14.4% of those agents went live with full security and IT approval.
Most teams have not threat-modeled their context files.
The countermeasure is not complicated: treat AGENTS.md changes with the same review discipline as code that runs in CI. Require an approval on any PR that modifies it.
Immutable audit trails covering triggers, inputs, decisions, and actions
at the agent level help too, but the context file review is the cheapest gate you can add today.
AGENTS.md and agentic coding: common questions
What is AGENTS.md and what does it do for a coding agent?
AGENTS.md is a Markdown file at the root of a repository that coding agents read at session start. It provides persistent project context - architecture rules, test commands, conventions, restricted files - without requiring the developer to re-explain the codebase each time. It is version-controlled, not in-model, so it does not learn or update itself.
Should my team use AGENTS.md or CLAUDE.md?
If your team uses only Claude Code, CLAUDE.md gives you more capabilities including hierarchical loading and imports. If your team uses multiple tools - Claude Code, Codex CLI, and GitHub Copilot cloud agent - a single AGENTS.md is closer to a universal standard and reduces the risk of conventions drifting across tool-specific files. Many teams maintain one AGENTS.md and generate vendor-specific files from it.
Does AGENTS.md actually prevent bugs in practice?
A study across 138 real-world repositories found that human-written AGENTS.md files reduce agent-generated bugs by 35-55%. The key word is human-written: files generated by the agent itself did not show the same benefit. The value comes from encoding institutional knowledge the agent cannot infer from the codebase alone - things like your team's migration approval process or which directories are off-limits.
Is AGENTS.md a security risk?
It can be. Because agents read AGENTS.md automatically as authoritative context before any user task, a malicious or compromised commit to the file can inject instructions the agent will follow. The mitigation is straightforward: require a human review and approval on any PR that modifies context files, and treat them with the same scrutiny as code that runs in production pipelines.
What should I actually put in AGENTS.md?
Focus on things the agent cannot infer from reading the code: which commands run tests and builds, which directories or files should never be modified autonomously, your team's PR and migration conventions, security-sensitive boundaries, and a short note on how you expect the agent to signal when it needs a human decision. Keep it concise - a 200-line AGENTS.md that no one maintains is worse than a tight 40-line one that is accurate.