If you run Claude Code in the terminal while someone else opens the same repository in Cursor or Codex, instruction files drift apart fast.
Copy-pasting a 400-line style guide into every tool's config file doesn't just double your maintenance. Depending on the client, it can silently truncate nested package rules or add thousands of static tokens to every turn.
Here is how each instruction format actually loads, three traps worth avoiding, and a minimal layout that keeps one source of truth.
TL;DR
-
Root
AGENTS.md-> put shared build, test, and repo conventions here (read natively by Codex, Cursor, Windsurf, Cline, and Copilot) -
CLAUDE.md-> keep it tiny with a single@AGENTS.mdimport plus Claude-only notes -
.cursor/rules/*.mdc-> reserve for path-scopedglobsrules that shouldn't load globally -
SKILL.md-> use for occasional multi-step workflows so only the short metadata loads at startup
ποΈ How each file loads
| File | Read by | Loading behavior & budget |
|---|---|---|
AGENTS.md |
Codex, Cursor, Windsurf, Cline | Loaded along directory chain (root -> cwd); 32 KiB cumulative cap in Codex |
CLAUDE.md |
Claude Code | Loaded in full at session start (@path imports expand immediately) |
.cursor/rules/*.mdc |
Cursor (v0.45+) |
Loaded conditionally when active files match YAML globs
|
SKILL.md |
Claude Code, Codex, Goose | Progressive disclosure: only name + description (~50 tokens) load until triggered |
β οΈ Trap 1: Codex's 32 KiB limit is cumulative
OpenAI Codex walks from ~/.codex/AGENTS.md to your repo root AGENTS.md and down to your current working directory.
By default, project_doc_max_bytes is 32,768 bytes (32 KiB) across that entire chain, not per file. If your root AGENTS.md is a 28 KiB architecture essay, a package-specific packages/api/AGENTS.md deeper in the tree gets truncated or dropped without a loud warning.
Keeping root AGENTS.md under ~150 lines of concrete build, lint, and test commands leaves plenty of room for subdirectory overrides.
π Trap 2: @path imports in CLAUDE.md don't save context
A common assumption in Claude Code is that splitting a large CLAUDE.md into imports like this keeps the context window lean:
@docs/architecture.md
@docs/coding-standards.md
It helps human readability, but it does not defer loading. Claude Code expands @path imports into the session context at launch.
If a rule only applies to database migrations or API routes, put it in path-scoped rules (.claude/rules/*.md or .cursor/rules/*.mdc) or an on-demand SKILL.md instead of importing it into root CLAUDE.md.
π§© Trap 3: SKILL.md fails silently on folder-name mismatch
Agent Skills validate YAML frontmatter strictly:
-
name: 1β64 characters, lowercase alphanumeric and single hyphens only (^[a-z0-9]+(-[a-z0-9]+)*$), and it must match the parent folder name (db-check/SKILL.md->name: db-check) -
description: 1β1,024 characters stating both what the skill does and when to use it
If name has uppercase letters, underscores, or doesn't match the folder name, the agent skips it silently.
βοΈ One repo layout that stays in sync
Instead of hand-editing the same rules in three places:
- Put shared build, test, and architecture constraints in root
AGENTS.md. - Point
CLAUDE.mdatAGENTS.mdand only add Claude-specific slash commands or hooks:
# Project Instructions
@AGENTS.md
## Claude Code Notes
- Run `/clear` between unrelated tasks to avoid re-caching long threads.
- Put personal local ports or sandbox paths in
CLAUDE.local.md(gitignored). - Keep
.cursor/rules/*.mdcstrictly for directory-specificglobs(likesrc/components/**/*.tsx).
Wrapping up
Most instruction drift comes from treating AGENTS.md and CLAUDE.md as separate documents. Pick AGENTS.md as the base, import it from CLAUDE.md, and push situational workflows out to skills or glob-scoped rules.
If you want to check byte budgets or generate the boilerplate files side by side, there's a small browser-based linter and converter and a set of MIT starter templates on GitHub.
Related: Why Your MCP Config Works in Cursor but Not in VS Code
How are you organizing repo instructions when teammates use different coding agents?
Top comments (5)
The cumulative 32 KiB cap in Codex is the trap I'd have missed. The single @AGENTS.md import in CLAUDE.md is a neat way to keep one source of truth. A cheap safeguard: a CI check that fails if CLAUDE.md grows beyond the import plus a few lines, so Claude-only notes don't slowly turn into a second copy of the style guide.
That CI line-count gate is a really practical ideaβit catches drift right at PR time before
CLAUDE.mdquietly turns into a parallel guide.You can also pair it in the same CI step with a byte-size check across each directory's
AGENTS.mdchain (leaving a little headroom below Codex's default32,768-byteproject_doc_max_bytescap for any personal~/.codex/AGENTS.md), so oversized updates fail loudly in CI instead of getting silently truncated.When a nested package has its own AGENTS.md, how do you stop an agent started at the repo root from building a duplicate helper before opening that subdirectory?
Good questionβnested
AGENTS.mdfiles aren't loaded at repo-root startup (they're either skipped when yourcwdis the root or only picked up once the agent opens files in that directory), which creates that exact blind spot. A lightweight pattern that avoids bloating the root file:AGENTS.mdβ just the path and what lives there (e.g.,packages/shared/ β HTTP client, auth helpers, date formatting), without duplicating the package's full rules.AGENTS.md) before adding any new cross-cutting helper.@repo/shared/*) make a quickrg/grep from the root surface existing helpers immediately instead of relying on prompt memory alone.That way the root
AGENTS.mdstays small as an index, while detailed package conventions stay scoped to the nested files.A root
check before creatingline still loses in practice unless the agent has to output the exact@repo/shared/*symbol and file path it is extending before generating any diff; otherwise it runsrg, sees ten barrel exports, and writes a fresh wrapper anyway. AI Lint packages that root pre-flight checklist and parallel-solution reject doctrine so coding agents must name the existing shared helper they are building on before writing code: ai-lint.dosaygo.com/go/forum-20261...