Skip to content
For developers6 min read

What is AGENTS.md? How to write one (2026)

AGENTS.md explained: what the file is, which coding agents read it, how nested files and overrides work, and a template you can copy, checked against the docs.

By TeaserTrack Team

Published

Laptop screen showing code and debugging tools, the kind of project an AGENTS.md file describes to a coding agent
On this page

    AGENTS.md is a plain Markdown file at the root of a repository that tells AI coding agents how to work on the project: how to install it, how to run the tests, which code style to follow and what to check before a pull request. The AGENTS.md site calls it "a README for agents" and says it is used by over 60k open source projects. There are no required fields. Everything below comes from the AGENTS.md site and the docs of OpenAI Codex, GitHub Copilot and Claude Code, checked on 8 November 2026.

    Why a separate file

    A README is for people: what the project is, how to get started, how to contribute. An agent needs more detail than that, such as the exact test command, the lint rules, which folders it must not touch, and the order of steps before a commit. Put all of that in a README and it gets long and hard to read. AGENTS.md gives agents one predictable place to look and keeps the README short.

    The format came out of work across OpenAI Codex, Amp, Jules from Google, Cursor and Factory, and it is now stewarded by the Agentic AI Foundation under the Linux Foundation.

    Which tools read it

    The AGENTS.md site lists more than 20 agents and tools that support the file, among them Codex from OpenAI, Jules and Gemini CLI from Google, Cursor, the GitHub Copilot coding agent, VS Code, Zed, Warp, Aider, goose, opencode, Devin and Windsurf from Cognition, Junie from JetBrains, Amp, RooCode, Kilo Code and Augment Code. Some need a setting: Aider reads it with read: AGENTS.md in .aider.conf.yml, and Gemini CLI with "context": { "fileName": "AGENTS.md" } in .gemini/settings.json.

    Three tools are worth knowing in detail:

    • Codex reads AGENTS.md before doing any work. It first reads a global file from ~/.codex (an AGENTS.override.md there wins over AGENTS.md), then walks from the project root down to the folder you work in and takes at most one file per folder. It stops adding files once the total reaches 32 KiB by default, so split long instructions across folders.
    • GitHub Copilot lets you keep one or more AGENTS.md files anywhere in the repository, and the nearest one in the directory tree takes precedence. It also accepts a single CLAUDE.md or GEMINI.md at the root, next to its own .github/copilot-instructions.md.
    • Claude Code reads AGENTS.md by default only when there is no CLAUDE.md in your working directory or above it. Inside AGENTS.md, @path imports are expanded. If your project also needs a CLAUDE.md, the Claude Code docs suggest an @AGENTS.md import at the top of it, with any Claude-only instructions below, so every tool shares one file.

    Nested files: the nearest one wins

    In a monorepo, put another AGENTS.md inside each package. Agents read the nearest file in the directory tree, so a package can ship its own test command and rules while the root file covers everything else. The AGENTS.md site notes that, at the time of writing, the main OpenAI repository had 88 AGENTS.md files. When instructions conflict, the file closest to the edited code wins, and an explicit instruction in the chat overrides every file.

    Diagram of a repository with an AGENTS.md at the root and another in packages/api. An agent editing packages/api/src/routes.ts reads the nearest file, and the chat prompt overrides both.
    The closest AGENTS.md to the file being edited takes precedence; your chat prompt overrides them all.

    What to put in it

    The AGENTS.md site suggests these sections, and they match what an agent asks about most often:

    • Project overview: one paragraph on what the code does and how it is laid out.
    • Build and test commands: the exact commands, such as pnpm install, pnpm dev and pnpm test.
    • Code style: language settings and conventions, for example TypeScript strict mode or quote style.
    • Testing instructions: where CI lives, how to run one test, and that the suite must pass before a merge.
    • Security considerations: secrets, files never to commit, risky areas.
    • Extras: commit message format, pull request rules, deployment steps, anything you would tell a new teammate.

    If you list test commands, the AGENTS.md site says agents will try to run them and fix failures before they finish. Keep commands exact and current; a wrong command costs every run.

    A template to copy

    To fill in your own from a short form, with a live preview and a download, use the free AGENTS.md generator. It runs in your browser.

    # AGENTS.md
    
    ## Project
    A Next.js app with a Postgres database. App code is in app/, shared code in lib/.
    
    ## Setup and checks
    - Install: npm ci
    - Dev server: npm run dev
    - Before every commit: npm run lint, npm run typecheck and npm test must pass.
    
    ## Code style
    - TypeScript strict mode. No any.
    - Server code never imports from components/.
    
    ## Rules
    - Never edit files in supabase/migrations by hand.
    - Never commit .env files.
    - Keep pull requests small, with a one line summary first.
    
    Code editor showing source code next to a project file tree.
    An agent reads AGENTS.md before it opens the rest of the tree, so put the commands it needs first.

    Common mistakes

    • Copying the README. Agents can read the README already. Use AGENTS.md for what is not in it.
    • Stale commands. Treat the file as living documentation and update it in the same pull request that changes a script.
    • One giant file. Codex stops at 32 KiB by default. Move package rules into nested files.
    • Two files that disagree. If you keep a CLAUDE.md or GEMINI.md too, import AGENTS.md from it, or link the old name to the new one, so there is one source of truth.

    Which agent to use it with

    For prices, see the AI coding tools pricing hub. To choose an agent, read Claude Code vs Codex, Cursor vs GitHub Copilot and Claude Code vs opencode, and see the best AI coding tools for a wider list.