Guide
What you get: A root AGENTS.md that tells coding agents how your monorepo is laid out and how to run commands per package, with room for each package's own AGENTS.md to add or override rules. In our test both Codex and Claude Code picked up the root file and the package file together when started inside the package. Best for Teams with a monorepo who use Codex, Claude Code or other agents that read AGENTS.md..
Before you start
- A monorepo in a git repository
- A task runner with a --filter style option (the commands as written match Turborepo)
- Codex or another AGENTS.md-aware agent
Worked example (Oct 17, 2026, Claude Code 2.1.296; Codex 0.151.0 (gpt-5.6-sol))
Input
Root AGENTS.md filled with: monorepo_tool=turbo, web_app=saltmarsh-web, web_owner=team-storefront, api_app=saltmarsh-api, api_owner=team-gateway. Added apps/saltmarsh-web/AGENTS.md with its own test command (`turbo run test --filter saltmarsh-web -- --project=chromium-smoke`) and two package-only rules. Both tools were started inside apps/saltmarsh-web. Question: Without reading any files, answer from the project instructions you were given at startup: (1) What monorepo tool does this repo use, and which team owns apps/saltmarsh-web? (2) What exact command runs this package's tests? (3) Name one rule that applies only to this package. (4) Which instruction files were you given: the repo-root AGENTS.md, this package's AGENTS.md, both, or neither? If you have no such instructions, say so.
Result
Codex: "Monorepo tool: Turbo. Owner of apps/saltmarsh-web: team-storefront. Exact test command: `turbo run test --filter saltmarsh-web -- --project=chromium-smoke` ... Instruction files given: both the repo-root AGENTS.md and this package's AGENTS.md." Claude Code: "The repo uses turbo (Turborepo). apps/saltmarsh-web is owned by team-storefront... I was given both: the repo-root AGENTS.md and apps/saltmarsh-web/AGENTS.md. Inside this package, the package file wins where the two conflict."
Fresh copy of a Next.js 16 starter git repo with the root AGENTS.md replaced and empty apps/ and packages/ folders created; turbo itself was not installed, so the commands were not run. Codex: read-only sandbox, `codex exec` run with cwd apps/saltmarsh-web; no commands in its log. Claude Code 2.1.296: plan mode, cwd apps/saltmarsh-web, JSON output showed 1 turn (no file reads); with no CLAUDE.md present it still loaded both AGENTS.md files. Both answered with the root owner (root file) and the package test command and rule (nested file). After this test the Turborepo-only commands became fill-in fields that work with pnpm, Nx or Turborepo, and the UI owner became a field.
How to check it worked
- Start the agent inside a package folder and ask, without reading files, for the package's test command and the team that owns it. The owner comes from the root file and the command from the package file, so a correct answer shows both loaded.
- In Codex, run from the package folder; it collects AGENTS.md files from the git root down to the current folder.
- In Claude Code, run /memory to see which instruction files are loaded.
Common problems
- The agent only knows the package rules, not the root ones: Codex walks up to the git root, so if the folder isn't a git repo (or you started outside it) only the nearest file may load. Run from inside the repo.
- The agent ignores package rules: you started it at the repo root. Nested AGENTS.md files apply when you work in or launch from that package; start the session in the package folder or tell the agent which package you're in.
- Commands fail with your tool: `<tool> run test --filter <package>` is Turborepo syntax. pnpm wants `pnpm --filter <package> test`, Nx uses `nx run <project>:test`. Rewrite rule 1 and 'Before you finish' for your tool.
- Agents that don't read AGENTS.md (or older versions) ignore it. Point their own config file at it, for example a CLAUDE.md containing `@AGENTS.md`.
Log in to join the discussion.