Guides

CLAUDE.md in a monorepo

A root file plus one per package is the layout Anthropic recommends, and it works, as long as you know the three rules about where you start Claude. Here they are, with the real load list for a test repo from two start folders, the limits, and the mistakes I keep seeing in linted repositories.

The three rules. Files from your start folder up to the root load at launch. Files in subfolders load when Claude first reads or edits something in there. Files in sibling folders never load. Everything else on this page is a consequence.

Where you start decides what loads

From the memory docs: Claude Code "loads CLAUDE.md and CLAUDE.local.md from your current working directory and every directory above it", concatenated root first, so the file nearest to where you launched is read last. Then: "Claude also discovers CLAUDE.md and CLAUDE.local.md files in subdirectories under your current working directory. Instead of loading them at launch, Claude Code loads each one once Claude reads, writes, or edits another file in that subdirectory." A cat or head on a single file in Bash counts as a read.

The monorepo guide puts the choice as a table. Start at the repository root and you get "Root only; subdirectory files load on demand", which suits "tasks span multiple packages". Start in a package and you get "That directory's plus every ancestor's", which suits work "scoped to one package". The guide's own example: "When you start Claude from packages/api/, it loads both packages/api/CLAUDE.md and the root CLAUDE.md. Claude sees the local instructions alongside the repository-wide rules, with no instructions from packages/web/ in context."

Two start folders, real output

I built a small repo with the recommended layout, plus a few deliberate faults, and ran the AsItIs load model on it. Started at the root:

$ npx -y asitis@0.4.8 loads --tool claude-code

Claude Code: about 108 tokens at launch from 4 files; 3 more files can load later; 1 not loaded
  At launch
    1. CLAUDE.md, about 43 tokens, project instructions
    2.    docs/conventions.md, about 18 tokens, imported by CLAUDE.md
    3.    @AGENTS.md.: not loaded as written (see lint_steering), not counted
    4.    @docs/style.md).: not loaded as written (see lint_steering), not counted
    5. .claude/rules/always.md, about 5 tokens, rule without paths, so it loads every session
    6. Skill listing (2 entries), about 42 tokens
  Later, when the agent works in a folder or on matching files
    7. .claude/rules/frontend.md, when Claude reads or edits a file matching apps/web/** (no file matches now)
    8. packages/api/CLAUDE.md, when Claude reads or edits a file in packages/api
    9. packages/web/CLAUDE.md, when Claude reads or edits a file in packages/web

Both package files are under "Later", with the exact trigger. Now the same repo, started in packages/web:

$ npx -y asitis@0.4.8 loads packages/web --root . --tool claude-code

Claude Code: about 110 tokens at launch from 4 files; 1 more file can load later (up to about 18 tokens); 1 file depending on settings or your approval, or not counted; 2 not loaded
  At launch
    1. CLAUDE.md, about 43 tokens, project instructions (from the project root, above the start folder)
    2.    @AGENTS.md.: not loaded as written (see lint_steering), not counted
    3.    @docs/style.md).: not loaded as written (see lint_steering), not counted
    4. packages/web/CLAUDE.md, about 20 tokens, project instructions
    5. .claude/rules/always.md, about 5 tokens, rule without paths, so it loads every session
    6. Skill listing (2 entries), about 42 tokens, names and descriptions of skills, commands and subagents; bodies load on use
  Later, when the agent works in a folder or on matching files
    7. .claude/rules/frontend.md, about 18 tokens, when Claude reads or edits a file matching apps/web/** (no file matches now)
  Only after you approve imports from outside the start folder (not counted)
    8. docs/conventions.md, about 18 tokens, imported by CLAUDE.md, after you approve external imports for this project
  Not loaded
    - AGENTS.md: CLAUDE.md switches off the AGENTS.md fallback, and no CLAUDE.md imports it
    - packages/api/CLAUDE.md: in packages/api, which is not the start folder, above it or below it
  Warnings
    - Claude Code ignores AGENTS.md here: there is a CLAUDE.md and it does not import AGENTS.md. Add the line @AGENTS.md to CLAUDE.md if both should share instructions
    - 1 import points outside packages/web (docs/conventions.md). Claude Code loads it only after you approve external imports, which it asks once per project in an interactive session; claude -p never asks, so in scripts and CI it loads only if someone already said yes. Start Claude higher up, or move the file inside packages/web
  How sure: 6 confirmed with a canary run.

Three changes. The package's own file moved up to launch. The sibling's file is gone for good. And the root file's import, docs/conventions.md, now sits under its own heading: it loads only after you approve imports from outside the start folder. The next section explains that prompt.

Inside a session the ground truth is /context all: the files that loaded at launch are listed under Memory files, and when a subfolder file loads later a Loaded line with its path appears in the terminal.

Imports in the root file

Root CLAUDE.md files in monorepos tend to collect @docs/conventions.md style imports. Two things to know. First, imports don't save context: the docs say imported files "load together with the CLAUDE.md that imports them". Second, once you start in packages/web, docs/conventions.md is outside the folder you started in, and the docs treat an import like that as external: "The first time Claude Code encounters external imports in a project, it shows an approval dialog listing the files. If you decline, the imports stay disabled and the dialog doesn't appear again." Approve it and the file loads from then on, for you, on that machine. claude -p never shows the dialog, so a headless or CI run never loads it unless the answer is already stored.

I had this wrong in 0.4.0: the canary runs were all claude -p, the prompt never appeared, and the load view said the import "does not expand". Driving an interactive session on 2.1.312 and 2.1.325 showed the dialog, and 0.4.1 lists these imports under their own heading, waiting for approval, and doesn't count them. The practical rule is unchanged: if a convention has to be present from every start folder, including CI, write it in the root file itself.

Imports also fail on punctuation (@AGENTS.md. with a full stop loads a file that doesn't exist). That's covered in Claude Code ignores my CLAUDE.md.

Path-scoped rules, and rules that match nothing

The alternative to a per-package file is a rule in the root .claude/rules/ with a paths field. It loads "when Claude works with a file matching the rule's paths: glob", from any start folder, and a rule without paths loads every session like CLAUDE.md. The monorepo guide's comparison: package files when "directory owners maintain their own conventions; instructions are versioned with the code", rules when "you want all conventions in one place, or the same rule applies to many scattered paths".

The failure mode is a glob that matches nothing. In the output above, .claude/rules/frontend.md has paths: ["apps/web/**"] in a repo whose packages live under packages/. It will never load, and nothing in Claude Code tells you. The linter's path-rule-matches-nothing warning does. Globs are relative to the project root; the docs' table has the exact matching rules (/*.md is top-level only, src/components/*.tsx doesn't recurse). For the other ways a rule fails to load, including frontmatter that doesn't parse and so loads every session, see .claude/rules not loading.

The limits

  • On-demand files are capped per file. A subfolder CLAUDE.md, a subfolder rules file or a path-scoped rule over 40,000 characters (200K context) is cut: "Claude receives only the start of it", plus a note to read the rest. Check with wc -m. A file that loads at launch is delivered in full up to 4 MiB.
  • 200 lines is the target per file, and you get a startup warning past it, and another when files that are each fine "add up past a combined limit at session start". Each CLAUDE.md, rules file and import counts separately. The token cost guide has the numbers.
  • Settings don't inherit. "Project settings in .claude/settings.json aren't inherited from parent directories the way CLAUDE.md files are." Deny rules and hooks have to be in the package's own .claude/settings.json if you start there. The personal settings.local.json is read at the repository root in a git repo.

A layout that works

monorepo/
  CLAUDE.md                     repo-wide rules, short
  .claude/
    settings.json               deny rules, hooks (not inherited by subfolders)
    rules/
      api.md                    paths: ["packages/api/**"]
      web.md                    paths: ["packages/web/**"]
  packages/
    api/
      CLAUDE.md                 loads when Claude works in here
      .claude/skills/api-testing/SKILL.md
    web/
      CLAUDE.md
      .claude/skills/component-patterns/SKILL.md

Root file: the handful of rules that are true everywhere, which the monorepo guide illustrates with three lines (run package scripts from the package folder, prefix commit subjects with the package name, never edit generated files). Package files: that package's stack and gotchas. Skills under each package for procedures, which load "when Claude determines it's relevant" and cost only their description until then. Shared skills in the root .claude/skills/ so they load from any start folder.

If you start at the root and other teams' package files keep loading on demand, exclude them for yourself in .claude/settings.local.json:

{
  "claudeMdExcludes": [
    "**/packages/legacy-*/**"
  ]
}

Patterns match absolute paths, so start with **/. The docs note that when you create this file by hand you also need to gitignore it yourself; Claude Code only does that for files it writes.

Mistakes the linter finds

From the 71 public repositories in the AsItIs test corpus, the monorepo-specific findings in 0.4.0 are these:

  • nested-duplicate: a package file repeats a rule from the root file word for word. Harmless, but it's paid for twice and drifts later.
  • nested-contradiction: the root says "use named exports", the package says "use default exports for pages". The docs' warning applies: "Claude may pick one arbitrarily." Say which wins, in the package file.
  • sec-nested-override: a package file that tells the agent to ignore the files above it. Legitimate once in a while, and exactly what a planted file would say, so it's reported.
  • path-rule-matches-nothing: the glob above.
  • broken-import: punctuation glued to an @path.

Codex is different

If the same monorepo is used with Codex, the model is a chain, not a tree: Codex reads AGENTS.md from the git root down to your folder, one file per directory, with a single 32 KiB budget for all of them. A nested file in a sibling package never loads, same as Claude Code, but a nested file below a big root file is dropped for a different reason: the budget is spent. AGENTS.md not loading in Codex has the output for that case, and asitis loads --tool codex shows it for your repo.

Check your file

The plugin's /asitis:md-loads prints what Claude Code, Codex, Gemini CLI, Cursor and Copilot load from any start folder in your monorepo, and /asitis:md-lint flags rules that match nothing, nested files that repeat or contradict the root, and imports that will not resolve. Read-only.

Open the steering file checker

To check every steering file in a project from inside Claude Code, including links, @imports and what loads every session, install the free AsItIs plugin. It is read-only and makes no network calls.

claude plugin marketplace add Katta041/asitis-agent-tools
claude plugin install asitis@asitis

About the pluginSource on GitHub

MIT licensed. A star on GitHub helps other people find it.

Questions

Does Claude Code read sibling packages' CLAUDE.md files?

No. Starting in packages/web loads the root CLAUDE.md and packages/web/CLAUDE.md. packages/api/CLAUDE.md is in a folder that is neither above nor below the start folder, so it never loads in that session. Starting at the root, it loads once Claude reads or edits a file in packages/api.

Should I use per-package CLAUDE.md files or .claude/rules with paths?

The Claude Code docs offer both. A per-package CLAUDE.md lives with the code and loads at launch when you start there, or on demand from the root; the package owner maintains it. A path-scoped rule in the root .claude/rules folder keeps every convention in one place and loads whenever Claude works with a matching file, wherever you started. Use rules when the same convention applies to scattered paths; use package files when each team owns its own.

Is there a size limit on a package CLAUDE.md?

Yes, for the on-demand ones. A subfolder CLAUDE.md, a subfolder rules file or a path-scoped rule has a per-file limit of 40,000 characters on a 200K context window. Over that, Claude gets only the start plus a note to read the rest, which it may not do. The root CLAUDE.md that loads at launch is delivered in full up to 4 MiB.

Does .claude/settings.json in the root apply when I start in a package?

The docs say project settings are not inherited from parent directories the way CLAUDE.md files are: Claude Code reads .claude/settings.json from the session's working directory. The personal .claude/settings.local.json is the exception; in a git repository Claude Code reads and writes it at the repository root. So commit deny rules and hooks in each package's .claude/settings.json if you start sessions there.

See what an agent changed in your CLAUDE.md. Keep or revert each change.

The linter is free and needs no signup. I'm also building a desktop editor for the markdown your agents write and read. It shows what an agent changed since you last looked, lets you keep or revert each change, and never touches a line you didn't edit. No release date yet. One email to confirm, one when the paid beta opens, one when 1.0 ships. $29 once for a founding licence, with 24 months of updates.

Or add the linter to CI, no email needed.

Your address is stored with Cloudflare, which hosts this site. No IP address is kept. See the privacy policy.

Related: Claude Code ignores my CLAUDE.md, CLAUDE.md best practices, how many tokens does my CLAUDE.md cost?, AGENTS.md not loading in Codex.

Sources, read on 15 November 2026: Claude Code docs, How Claude remembers your project and Set up Claude Code in a monorepo or large codebase. Quotes are exact. The external-import dialog was checked in interactive sessions on Claude Code 2.1.312 and 2.1.325. Command output is from @asitis/mcp 0.4.2 (0.4.3 prints the same) on a fixture repository, trimmed for width; the one line it gets wrong is called out above.