AGENTS.md and CLAUDE.md in a monorepo: which files Codex, Claude Code, Copilot and Cursor actually load
Published · Updated · Facts checked against official vendor pages on November 27, 2026 · Rankings are independent of sponsorships
A monorepo needs more than one set of agent instructions: the web app's commands aren't the API's, and the rules for a shared package aren't the rules for an app. Every major coding agent now supports nested instruction files, but they don't load them the same way, and the differences decide whether your package rules are seen at all. This guide compares OpenAI Codex, Claude Code, GitHub Copilot and Cursor using their own docs, checked on November 26, 2026, and ends with a layout that works in all four. Two new free files go with it: an AGENTS.md for pnpm and Turborepo monorepos and a Copilot planner custom agent.
Tools in this post
The short version
OpenAI Codex joins AGENTS.md files from the repo root down to the folder you started in, one per folder, closest last. It doesn't read files in folders below where you started.
Claude Code loads CLAUDE.md files from your starting folder and every folder above it at launch, and loads a subfolder's file when it first reads or edits a file there. It reads AGENTS.md instead when you have no CLAUDE.md.
GitHub Copilot uses the nearest AGENTS.md in the directory tree, and path-specific instruction files when their applyTo glob matches.
Cursor applies AGENTS.md files in the root and any subfolder when you work on files there, combined with the parent folders' files, with the more specific one taking precedence.
The layout that works everywhere: one short root AGENTS.md for the whole repo, one AGENTS.md per package for its own commands, and a habit of starting Codex in the package you're changing.
OpenAI Codex: root down to where you started
OpenAI's AGENTS.md guide describes three steps. Codex first reads a global file from your Codex home folder (AGENTS.override.md if it exists, otherwise AGENTS.md). Then, starting at the project root, usually the Git root, it walks down to your current working directory and checks each folder for AGENTS.override.md, then AGENTS.md, then any fallback names you configured, taking at most one file per folder. Finally it joins them from the root down, so files closer to your working directory come later and override earlier guidance.
The detail that trips people up in a monorepo: Codex stops searching once it reaches your current directory. If you start Codex at the repo root, apps/web/AGENTS.md is never loaded, even when the task is entirely inside apps/web. Start Codex in the package (OpenAI's docs use codex --cd subdir to check which files are active), or keep anything every task needs in the root file.
Codex also stops adding files once the combined size reaches project_doc_max_bytes, 32 KiB by default. You can raise the limit in config, but OpenAI suggests splitting instructions across nested folders when you hit the cap. An AGENTS.override.md in a folder replaces that folder's AGENTS.md, which is handy for a team that needs different rules for one service.
Claude Code: launch folder and above, subfolders on demand
Anthropic's memory docs say Claude Code loads every CLAUDE.md and CLAUDE.local.md in the directory hierarchy above your working directory at launch, and concatenates them from the filesystem root down, so the file closest to where you launched is read last. Files in subfolders below your working directory load on demand: once Claude reads, writes or edits a file in that subfolder. So unlike Codex, starting at the root still picks up packages/api/CLAUDE.md when Claude touches the API.
Claude Code now reads AGENTS.md too. Since v2.1.277, if there's no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in your working directory or above it, Claude reads your AGENTS.md files instead, including a subfolder's AGENTS.md when it opens a file there and that folder has no CLAUDE.md of its own. If you do have a CLAUDE.md, it reads only the CLAUDE.md files unless one of them imports AGENTS.md with @AGENTS.md, or you change the Project instructions setting in /config. One catch from the docs: adding a personal CLAUDE.local.md stops Claude from reading AGENTS.md for you.
For big repos, Anthropic's monorepo guide adds two tools. claudeMdExcludes in your settings skips CLAUDE.md files you never need, such as another team's packages, and path-scoped rules in .claude/rules/ with a paths glob load only when Claude works on matching files. Anthropic recommends keeping each CLAUDE.md under 200 lines. Our free CLAUDE.md template is a good root file, and Claude Code skills vs subagents vs CLAUDE.md covers what to move out of it.
GitHub Copilot: the nearest AGENTS.md wins
GitHub's repository instructions docs say you can put AGENTS.md files anywhere in the repository, and when Copilot is working, the nearest AGENTS.md in the directory tree takes precedence. As an alternative, Copilot reads a single CLAUDE.md or GEMINI.md, but only from the repository root, so nested CLAUDE.md files are a Claude Code feature, not a Copilot one.
Copilot has a second, central way to scope rules: path-specific files in .github/instructions/ named NAME.instructions.md, with an applyTo glob such as apps/web/**. When one matches the file Copilot is working on and a repository-wide .github/copilot-instructions.md also exists, Copilot uses both. That makes path-specific files a good fit for rules that cut across packages, like test conventions; our free Copilot instructions for tests is written that way.
For planning a change that spans packages, our new free planner custom agent reads and searches the repo and writes a plan to docs/plans/ with real file paths, without touching code. GitHub Copilot custom agents vs skills vs instructions explains where each kind of file goes.
Cursor: nested AGENTS.md plus glob-scoped rules
Cursor's rules docs say it supports AGENTS.md in the project root and subdirectories. Nested files apply automatically when you work with files in that folder or below, and are combined with the parent folders' files, with more specific instructions taking precedence. That's close to Claude Code's model, and it means the same per-package AGENTS.md files work in Cursor without changes.
Project rules in .cursor/rules/ (.mdc files with description, globs and alwaysApply) are the central option, like Copilot's path-specific files. A rule with globs: apps/web/** attaches only when a matching file is in context, and you can organize rules into subfolders inside .cursor/rules/. Cursor's rules docs describe that one project-level .cursor/rules folder; they don't document separate .cursor/rules folders inside packages or other subdirectories, so for per-package instructions use a nested AGENTS.md or a glob-scoped rule like the one above. Plain .md files in that folder are ignored, so use .mdc. Our free stack rules, such as Cursor rules for Django and Cursor rules for Next.js, use file globs so they only load when that stack is in play.
A layout that works in all four
Put the shared rules in one root AGENTS.md: the package manager, how to run a task for one package, where dependencies go, import boundaries between apps and packages, and the checks to run before finishing. Keep it short, because Codex's 32 KiB cap counts every file it joins and Claude's 200-line target applies per file. Our free AGENTS.md for pnpm + Turborepo and AGENTS.md for a Python uv workspace are written to be that root file.
Then add an AGENTS.md in each app or package with only what's different there: its dev and test commands, its framework rules, its environment variables. Don't repeat the root file: Codex, Claude Code and Cursor combine the two. GitHub's docs only say the nearest AGENTS.md takes precedence for Copilot, so it's worth repeating the one or two root rules that matter most in that package, such as which package manager to use.
If you use Claude Code, either rely on its AGENTS.md support or add a root CLAUDE.md with @AGENTS.md on its first line plus any Claude-only notes. If you use Codex, start it in the package you're changing. And if a rule only applies to some file types across packages, such as tests or Tailwind classes, make it a glob-scoped Cursor rule or Copilot instructions file rather than copying it into every package. For more on why short files work better, see how long AGENTS.md, CLAUDE.md and Cursor rules should be and AGENTS.md vs CLAUDE.md vs Cursor rules.
Which agent should you use for a monorepo?
All four handle nested files now, so pick on the agent loop, not the config format. Claude Code and Cursor pick up package files automatically when they touch a package, which suits cross-package refactors. OpenAI Codex is more predictable but depends on where you start it. GitHub Copilot fits teams that want rules reviewed in pull requests and agents assigned from issues. Our Cursor vs Claude Code vs Copilot guide compares them in depth, and the Claude Code Agent Kit adds a full set of subagents, skills and hooks for Claude Code.
FAQ
- Does Codex read AGENTS.md files in subfolders?
- Only on the path from the project root down to the folder you started Codex in. OpenAI's docs say Codex stops searching once it reaches your current directory, so start Codex in the package to load that package's AGENTS.md.
- Does Claude Code read AGENTS.md?
- Yes, since v2.1.277, when there's no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in your working directory or above it. Otherwise it reads only CLAUDE.md files unless one imports AGENTS.md or you change the Project instructions setting.
- Which AGENTS.md does GitHub Copilot use in a monorepo?
- GitHub's docs say the nearest AGENTS.md in the directory tree takes precedence. Copilot also reads a single CLAUDE.md or GEMINI.md, but only from the repository root.
- Does Cursor support nested AGENTS.md?
- Yes. Cursor's docs say AGENTS.md files in subdirectories apply when you work with files in that folder, combined with parent folders' files, with more specific instructions taking precedence.
Free and paid rules for your agents
- AGENTS.md for a TypeScript monorepo (pnpm workspaces + Turborepo) (free)
- AGENTS.md for a Python monorepo (uv workspace) (free)
- Copilot custom agent: planner (.agent.md) (free)
- Cursor rules for Django 6 (models, migrations, ORM queries, security) (free)
- CLAUDE.md project memory template (free)
- AGENTS.md starter for any stack (free)
- Claude Code Agent Kit ($19): Installable Claude Code plugin: 12 subagents, 8 skills and 3 tested safety hooks.
- Cursor Rules: Next.js 16 ($9): 12 scoped Cursor rules, AGENTS.md and CLAUDE.md for Next.js 16.4 with Cache Components.
Related changelog
- 2026-11-23 · Anthropic deprecates Claude Opus 4.5 (API retirement Jan 22, 2027) and launches Enterprise Frontier Safeguards in beta
- 2026-11-18 · Google releases Gemini 4 Neon at $3 / $15 per 1M tokens; GitHub Copilot and Cursor add it
- 2026-11-17 · OpenAI releases GPT-6.2 Astra ($8 / $40) and GPT-6.2 Sol ($2 / $10) in ChatGPT Work, Codex and the API
- 2026-11-17 · MAI Code 2 and MAI Code 2 Flash arrive in GitHub Copilot; Flash works on Copilot Free
Sources
- OpenAI: Custom instructions with AGENTS.md (Codex)
- Claude Code Docs: Memory and project instructions
- Claude Code Docs: Set up Claude Code in a monorepo or large codebase
- GitHub Docs: Adding repository custom instructions
- GitHub Docs: Custom agents configuration
- Cursor Docs: Rules
- Turborepo Docs: Managing dependencies
- pnpm Docs: Workspace
Prices change often. Always confirm on the vendor's site before buying. See the full tier lists and the changelog.