Where CLAUDE.md files live, in load order
loaded first → loaded last
- Managed policye.g.
/etc/claude-code/CLAUDE.md— every user on the machine; cannot be excluded - User
~/.claude/CLAUDE.md— just you, every project; not in git - Project
./CLAUDE.mdor./.claude/CLAUDE.md— the team, via version control - Local
./CLAUDE.local.md— just you, this project; add to.gitignore - Subdirectory
src/api/CLAUDE.md— loaded on demand when Claude reads files there
The four scopes, and who sees each
Claude Code reads CLAUDE.md files from several places, each with a different audience. The scope you choose is really a decision about who the instruction is for. Get it wrong and the instruction either reaches nobody who needs it or reaches people who don’t.
| Scope | Location | Who gets it | Put here |
|---|---|---|---|
| Managed policy | OS-specific path, deployed by IT (MDM, Group Policy, Ansible) | Every user on the machine | Company-wide standards, compliance reminders |
| User | ~/.claude/CLAUDE.md | Only you, in every project | Personal style and tooling preferences |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md | Everyone who clones the repo | Build and test commands, architecture, team conventions |
| Local | ./CLAUDE.local.md (gitignored) | Only you, in this project | Your sandbox URLs, preferred test data |
The user file is where team-wide instructions most often get lost. It sits in your home directory, so it never goes into git. A convention you wrote there will be followed on your laptop and nowhere else — including in CI, and on the new starter’s machine. If a rule should apply to everyone working on the repository, it belongs in the project file and gets committed.
How the files combine
Files do not override each other. Claude Code walks from the filesystem root down to the directory you launched from, loading every CLAUDE.md and CLAUDE.local.md it finds, and concatenates them. Start Claude in repo/packages/api/ and it loads repo/CLAUDE.md and repo/packages/api/CLAUDE.md, with the closer file read later. Within a directory, CLAUDE.local.md comes after CLAUDE.md.
Subdirectories below where you started behave differently: their CLAUDE.md files are not loaded at launch. They are pulled in on demand, when Claude reads a file in that subdirectory. This is what makes per-directory files cheap — the frontend team’s conventions cost nothing while Claude works in the backend.
Modular organisation: imports, rules and per-directory files
A single root CLAUDE.md tends to grow until it covers every subsystem. The documentation’s target is under 200 lines per file, because longer files consume more context and reduce adherence. There are three ways to split one up, and they do different things.
| Mechanism | How it works | Saves context? |
|---|---|---|
@path import | @docs/git-workflow.md inside a CLAUDE.md pulls that file in at launch | No — imported files load at launch too |
.claude/rules/*.md | One topic per file; files without paths frontmatter load at launch like the project file | Only when scoped with paths (see 3.3) |
Per-directory CLAUDE.md | Lives beside the code it describes; owned by that team | Yes — loads only when Claude works there |
Imports are for organisation and reuse: pointing at an existing README, a package.json, or a shared file. Relative paths resolve from the file that contains the import, not from where you launched, and imports can nest up to four hops deep. A path inside backticks is not imported, which lets you mention a file without loading it. The first time a project imports a file from outside the working directory, Claude Code asks for approval.
# Project overview
See @README.md for the architecture and @package.json for scripts.
# Commands
- Build: npm run build
- Single test file: npm test -- path/to/file.test.ts
# Conventions
- API handlers live in src/api/handlers/
- Never edit files under generated/ — run npm run codegen
# Detail
- Git workflow: @docs/claude/git-workflow.md
- Release checklist lives in a skill (/release), not hereOne bloated file versus a modular set
Weak: one 600-line root filetext
# CLAUDE.md
- Write clean code
- I like short commit messages
- My staging URL: dev-sam.internal
- React components: (80 lines)
- SQL migration rules: (90 lines)
- Release procedure: 40 steps
- File-by-file tour of src/
- IMPORTANT: ... (x25)Strong: split by audiencetext
./CLAUDE.md (60 lines, committed)
commands, layout, team rules
@docs/claude/git-workflow.md
.claude/rules/react.md (paths)
.claude/rules/migrations.md (paths)
.claude/skills/release/SKILL.md
CLAUDE.local.md (gitignored)
my staging URL
~/.claude/CLAUDE.md
short commit messagesWhat to put in, and what to leave out
CLAUDE.md earns its place with facts Claude needs in every session and cannot work out from the code: commands it can’t guess, style rules that differ from defaults, repository etiquette, architectural decisions, environment quirks and known gotchas. It should not contain things Claude can derive by reading the code, standard language conventions, long tutorials, frequently changing information, or a file-by-file tour. The documentation’s test for each line is whether removing it would cause mistakes.
Where does this instruction belong?
- Every session, whole teamProject
CLAUDE.mdcommitted to git - Only for some filesPath-scoped ruleor a subdirectory CLAUDE.md
- A multi-step procedureSkillloads when invoked (3.2)
- Must happen, no exceptionsHook or deny ruleenforced, not advisory
Checking what actually loaded
/context— shows which CLAUDE.md and rules files are in the current session, under Memory files. If a file isn’t listed, Claude can’t see it./memory— lists CLAUDE.md, CLAUDE.local.md and other memory locations across user and project scopes, and opens any of them in your editor./init— generates a starter CLAUDE.md from the codebase, or suggests improvements to an existing one.- The
InstructionsLoadedhook — logs which files loaded, when and why; useful for debugging on-demand files.
Two behaviours are worth knowing when instructions seem to vanish. After /compact, the project-root CLAUDE.md is re-read from disk, but nested files and path-scoped rules only return when Claude next reads a matching file. And an instruction you only typed into chat is lost at compaction — if it should persist, it belongs in a CLAUDE.md.
Traps the wrong answers are built from
| Tempting but wrong | Do this instead |
|---|---|
Putting team conventions in ~/.claude/CLAUDE.md | Commit them to the project CLAUDE.md so every clone, including CI, gets them. |
| One ever-growing root CLAUDE.md covering every subsystem | Keep the root short; move area-specific conventions to per-directory files or path-scoped rules. |
Splitting a big file into @imports to save context | Imports organise but still load at launch; use path-scoped rules, subdirectory files or skills to defer loading. |
| Counting on the more specific file to win a contradiction | Files are concatenated and conflicts are resolved by judgement; remove the conflict instead. |
| Writing a hard requirement as a CLAUDE.md line in capitals | Enforce it with a hook or a permissions.deny rule; keep CLAUDE.md for guidance. |
You should now be able to
- Place an instruction at the managed, user, project, local or subdirectory level according to who needs it.
- Explain that CLAUDE.md files concatenate from the root down, with subdirectory files loading on demand.
- Split an oversized CLAUDE.md using imports,
.claude/rules/and per-directory files, knowing which of these actually save context. - Diagnose a missing instruction with
/contextand/memory. - Recognise when a requirement needs a hook or permission rule rather than CLAUDE.md.