{"slug": "agents-md-best-practices-what-to-write-who-reads-it-nov-2026", "title": "AGENTS.md Best Practices: What to Write, Who Reads It (Nov 2026)", "summary": "As of 24 Nov 2026, the AGENTS.md format's own site reports the instruction file is used by over 60k open-source projects and is stewarded by the Agentic AI Foundation under the Linux Foundation, with the format's GitHub repository carrying the MIT licence. The site recommends a single short markdown file at the repository root listing build steps, test commands, code style, testing instructions and security considerations, with nested AGENTS.md files placed inside each package in large monorepos because agents read the nearest file in the directory tree and the closest one takes precedence. Vendor docs diverge on nested files: GitHub Copilot agrees the nearest file wins, OpenAI's Codex joins files from the root down so closer files override earlier guidance, and OpenCode combines files without resolving conflicts between them.", "body_md": "# AGENTS.md Best Practices: What to Write, Who Reads It (Nov 2026)\n\nAGENTS.md best practices from the format's site and vendor docs, checked 24 Nov 2026: what to write, where files go, which tools read it.\n\nThe best `AGENTS.md` is one short markdown file at the repo root that lists the commands and rules an agent cannot guess, with nested files only where a folder truly differs. Checked 24 Nov 2026: these best practices come from the [format’s own site](https://agents.md) and the docs of five tools that read the file.\n\nRunning several coding agents on one repo? [Munder Difflin](https://harnessmd.com/download) is free and open source: a desktop app that runs a team of AI agents for all kinds of knowledge work, coding included, on your own computer. It runs engines such as Claude Code, Codex and Gemini CLI. The [install guide](https://munderdiffl.in/blog/how-to-install-and-use-munder-difflin/) covers setup. For habits beyond this file, see [Claude Code best practices](https://munderdiffl.in/blog/claude-code-best-practices/).\n\n## What is an `AGENTS.md` file? [#](#what-is-an-agentsmd-file)\n\nA plain markdown file of instructions for coding agents. The [format’s site](https://agents.md) calls it “a README for agents: a dedicated, predictable place to provide the context and instructions to help AI coding agents work on your project.” There are no required fields: “`AGENTS.md` is just standard Markdown. Use any headings you like”.\n\nOn 24 Nov 2026 the site says the format is “used by over 60k open-source projects” and “is now stewarded by the Agentic AI Foundation under the Linux Foundation.” Its [GitHub repository](https://github.com/agentsmd/agents.md) carries the MIT licence, per GitHub on 24 Nov 2026.\n\n## What should you put in `AGENTS.md`? [#](#what-should-you-put-in-agentsmd)\n\nWhat a README leaves out. The site names “build steps, tests, and conventions that might clutter a README or aren’t relevant to human contributors.” It lists popular sections: project overview, build and test commands, code style guidelines, testing instructions and security considerations. Commit messages, pull request guidelines and deployment steps fit too: “anything you’d tell a new teammate belongs here too.”\n\nList your test commands. The site’s FAQ says that when you list them, the agent “will attempt to execute relevant programmatic checks and fix failures before finishing the task.” [OpenCode’s docs](https://opencode.ai/docs/instructions/) name a similar core: “build commands, architecture notes, code conventions, and verification requirements.”\n\nHere is a short example that follows the site’s suggested sections:\n\n```\n# Project overview\nA web app and its API in one repo.\n\n## Build and test commands\n- Install: `pnpm install`\n- Test one file: `pnpm vitest run path/to/file`\n- Lint: `pnpm lint`\n\n## Code style\n- TypeScript strict mode.\n\n## Security\n- Never commit `.env` files.\n```\n\n## Where should `AGENTS.md` files live? [#](#where-should-agentsmd-files-live)\n\nAt the root of the repo first. The site says to create the file “at the root of the repository”, and in a large monorepo to “Place another `AGENTS.md` inside each package.” Agents “automatically read the nearest file in the directory tree, so the closest one takes precedence”, and its FAQ adds that “explicit user chat prompts override everything.”\n\nTools treat nested files differently. [GitHub’s Copilot docs](https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/add-custom-instructions/add-repository-instructions) agree the nearest file “will take precedence.” Per [OpenAI’s Codex docs](https://learn.chatgpt.com/docs/agent-configuration/agents-md), Codex joins files from the root down, and closer files “override earlier guidance because they appear later in the combined prompt.” OpenCode “combines the files and does not resolve conflicts between them.”\n\nOur view: write nested files that add to the root file and never contradict it, because nearest wins only holds for some tools.\n\n## Which tools read `AGENTS.md`, and how? [#](#which-tools-read-agentsmd-and-how)\n\nThe five tools below name it in their own docs. Checked 24 Nov 2026:\n\n| Tool | File it reads | How it picks between files | Source | \n|---|---|---|---|\n| Codex | `AGENTS.override.md` , else`AGENTS.md` , in`~/.codex` ; the same plus fallback names in each folder from the project root to your working folder | One file per folder, joined root down; later files override | [Codex docs](https://learn.chatgpt.com/docs/agent-configuration/agents-md) | \n| Claude Code | `AGENTS.md` and`.claude/AGENTS.md` , from v2.1.277 | By default, only when no `CLAUDE.md` ,`.claude/CLAUDE.md` or`CLAUDE.local.md` is in your working folder or above | [Memory docs](https://code.claude.com/docs/en/memory) | \n| OpenCode | `~/.config/opencode/AGENTS.md` , then every`AGENTS.md` from the workspace up toward your home folder | Combines all; a folder’s `AGENTS.md` wins over its`CLAUDE.md` | [OpenCode docs](https://opencode.ai/docs/instructions/) | \n| Gemini CLI | `GEMINI.md` by default;`AGENTS.md` once named in`context.fileName` | Concatenates every file found | [Gemini CLI docs](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/gemini-md.md) | \n| GitHub Copilot | One or more `AGENTS.md` anywhere in the repo | Nearest file in the tree takes precedence | [GitHub docs](https://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/add-custom-instructions/add-repository-instructions) | \n\nGemini CLI needs one setting. Its docs give this `settings.json` example:\n\n```\n{\n  \"context\": {\n    \"fileName\": [\"AGENTS.md\", \"CONTEXT.md\", \"GEMINI.md\"]\n  }\n}\n```\n\n## How long should `AGENTS.md` be? [#](#how-long-should-agentsmd-be)\n\nShort. Codex sets a hard cap: it “stops adding files once the combined size reaches the limit defined by project_doc_max_bytes (32 KiB by default).” Its docs show `project_doc_max_bytes = 65536` in `~/.codex/config.toml` to raise it, or say to split instructions across nested folders.\n\nClaude Code’s memory docs target under 200 lines per `CLAUDE.md` file, because longer files “consume more context and reduce adherence”. Our view: the same budget suits `AGENTS.md`.\n\n## Does Claude Code read `AGENTS.md` or `CLAUDE.md`? [#](#does-claude-code-read-agentsmd-or-claudemd)\n\nBy default, one or the other. Anthropic’s [memory docs](https://code.claude.com/docs/en/memory) say Claude Code v2.1.277 and later reads `AGENTS.md` when there is no `CLAUDE.md`, `.claude/CLAUDE.md` or `CLAUDE.local.md` in your working folder or above it. It does not read `AGENTS.override.md`, `AGENTS.local.md` or anything under `.agents/`.\n\nTo keep one shared file, the docs give three routes: put `@AGENTS.md` at the top of a `CLAUDE.md`, symlink `CLAUDE.md` to `AGENTS.md`, or set **Project instructions** in `/config` to `claude-md-and-agents-md` so Claude reads both. The import also covers sessions that cannot load `AGENTS.md` directly. OpenCode goes the other way and reads `CLAUDE.md` in any folder without an `AGENTS.md`. Our [` CLAUDE.md` best practices](https://munderdiffl.in/blog/claude-md-best-practices/) guide covers the Claude side.\n\n## How do you keep `AGENTS.md` up to date? [#](#how-do-you-keep-agentsmd-up-to-date)\n\nCommit it and keep editing it. The site says “Treat `AGENTS.md` as living documentation.” OpenCode’s docs say to commit project instruction files “so everyone working in the repository receives the same guidance.”\n\nReloads differ. Codex rebuilds its instruction chain on every run. OpenCode picks up edits to a global or parent file before the next request, but a nested file already loaded needs a new session. From v2.1.283, Claude Code’s `/doctor prompt-audit` checks `AGENTS.md` files for “outdated or conflicting content”. For more on Codex itself, see [what is Codex](https://munderdiffl.in/blog/what-is-codex/) and our [Codex Max plan tips](https://munderdiffl.in/blog/codex-max-plan-tips/).\n\n## `AGENTS.md` best practices at a glance, checked 24 Nov 2026 [#](#agentsmd-best-practices-at-a-glance-checked-24-nov-2026)\n\n| # | Rule | From | \n|---|---|---|\n| 1 | One file at the repo root first | Format site | \n| 2 | Overview, build and test commands, code style, testing, security | Format site | \n| 3 | Test commands listed, so the agent can run checks | Format site | \n| 4 | Nested files per package in a monorepo | Format site | \n| 5 | Nested files add to the root file, never contradict it | Our view | \n| 6 | Under 32 KiB combined for Codex, or raise `project_doc_max_bytes` | Codex docs | \n| 7 | Import or symlink it from `CLAUDE.md` when you need both | Claude Code memory docs | \n| 8 | Commit it and treat it as living documentation | Format site, OpenCode docs | \n\n## FAQ\n\nWhat should I put in `AGENTS.md`?\n\nThe format's site lists project overview, build and test commands, code style guidelines, testing instructions and security considerations as popular sections, plus anything you would tell a new teammate. Checked 24 Nov 2026.\n\nDoes Claude Code read `AGENTS.md`?\n\nYes, from v2.1.277, by default only when there is no `CLAUDE.md`, `.claude/CLAUDE.md` or `CLAUDE.local.md` in your working folder or above it. To keep both, import it with `@AGENTS.md` from `CLAUDE.md`, or set Project instructions in /config to `claude-md-and-agents-md`.\n\nWhich `AGENTS.md` wins when there are several?\n\nIt depends on the tool. The format's site and GitHub's Copilot docs say the nearest file takes precedence. Codex joins files from the root down so closer ones override, and OpenCode combines them without resolving conflicts. Checked 24 Nov 2026.\n\nIs there a size limit for `AGENTS.md`?\n\nIn Codex, yes. It stops adding files once the combined size reaches `project_doc_max_bytes`, 32 KiB by default, and you can raise that in `~/.codex/config.toml`. Checked 24 Nov 2026.\n\nHow do I make Gemini CLI read `AGENTS.md`?\n\nName it in `context.fileName` in your Gemini CLI `settings.json`, for example `[\"AGENTS.md\", \"CONTEXT.md\", \"GEMINI.md\"]`. By default Gemini CLI reads `GEMINI.md`.", "url": "https://wpnews.pro/news/agents-md-best-practices-what-to-write-who-reads-it-nov-2026", "canonical_source": "https://munderdiffl.in/blog/agents-md-best-practices/", "published_at": "2026-11-24 00:00:00+00:00", "updated_at": "2026-11-24 17:12:12.966628+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "ai-tools"], "entities": ["Agentic AI Foundation", "Linux Foundation", "GitHub Copilot", "OpenAI Codex", "OpenCode", "Munder Difflin", "Claude Code"], "also_reported_by": [], "takeaway": "Write one short AGENTS.md at the repo root listing commands and rules agents cannot guess, and add nested files only where a folder truly differs, since nearest-file precedence holds for Copilot and Codex but OpenCode merges files without resolving conflicts.", "recommendation": {"advice": "Put build, test and lint commands plus conventions in a root AGENTS.md, and make nested files additive rather than contradictory because Codex and Copilot let the nearest file win while OpenCode merges without conflict resolution.", "playbook": "coding-agents", "playbook_url": "https://wpnews.pro/playbooks/coding-agents"}, "alternates": {"html": "https://wpnews.pro/news/agents-md-best-practices-what-to-write-who-reads-it-nov-2026", "markdown": "https://wpnews.pro/news/agents-md-best-practices-what-to-write-who-reads-it-nov-2026.md", "text": "https://wpnews.pro/news/agents-md-best-practices-what-to-write-who-reads-it-nov-2026.txt", "jsonld": "https://wpnews.pro/news/agents-md-best-practices-what-to-write-who-reads-it-nov-2026.jsonld"}}