Where can Claude Code's CLAUDE.md files live, at managed, user, project and local scope, and who shares each one?
answer
- four scopes, broadest to most specific
- OS policy path, then home directory
- ./CLAUDE.md or ./.claude/CLAUDE.md
- CLAUDE.local.md belongs in .gitignore
- @path imports, four hops
basics
~10 sManaged policy CLAUDE.md applies to every user on the machine, ~/.claude/CLAUDE.md to you in every project, ./CLAUDE.md or ./.claude/CLAUDE.md to the team through git, and a gitignored ./CLAUDE.local.md to you in one project.
solid answer
~40 sThere are four scopes, loaded from broadest to most specific. The **managed policy** file sits at an OS path such as `/etc/claude-code/CLAUDE.md` on Linux and applies to every user on the machine; individual settings cannot exclude it. `~/.claude/CLAUDE.md` holds your personal preferences for every project. The **project** file, `./CLAUDE.md` or `./.claude/CLAUDE.md`, is committed and shared with the team. `./CLAUDE.local.md` is your private, per-project file, which you add to `.gitignore`. They are concatenated rather than overriding each other, with `CLAUDE.local.md` read after `CLAUDE.md` in the same directory. Any of them can pull in other files with `@path` imports, which resolve relative to the importing file, recurse at most four hops and still load at launch, so they organize a file without shrinking it.
go deeper
Recall the four scopes and their paths: managed, ~/.claude/CLAUDE.md, the project file and a gitignored CLAUDE.local.md.
Explain that the scopes concatenate in a fixed order, how @path imports resolve and nest to four hops, and why imports do not save context.
Show judgment about trust: why external imports need approval, why the managed file cannot be excluded, and the worktree trap with CLAUDE.local.md.
Weigh which guidance an organization should push through the managed file and which teams should own in their repositories.
## The four scopes Claude Code reads CLAUDE.md files from several locations, each with a different audience. The docs list them from broadest to most specific, which is also the order in which they enter context. | Scope | Location | Shared with | | --- | --- | --- | | Managed policy | macOS `/Library/Application Support/ClaudeCode/CLAUDE.md`; Linux and WSL `/etc/claude-code/CLAUDE.md`; Windows `C:\Program Files\ClaudeCode\CLAUDE.md` | Every user on the machine | | User | `~/.claude/CLAUDE.md` | Just you, in every project | | Project | `./CLAUDE.md` or `./.claude/CLAUDE.md` | The team, through version control | | Local | `./CLAUDE.local.md` | Just you, in this project | - **Managed policy** is deployed by IT or platform teams with MDM, Group Policy, Ansible or similar tooling. It carries organization-wide guidance such as coding standards or compliance reminders, and individual settings **cannot exclude** it. - **User** instructions are your personal preferences across all repositories: style habits, tooling shortcuts. Personal rule files can also go in `~/.claude/rules/`. - **Project** instructions are the team's: build commands, architecture, conventions. The two spellings are equivalent; `.claude/CLAUDE.md` keeps the repository root tidy. - **Local** instructions are your private notes for one repository, such as sandbox URLs or preferred test data. Claude Code treats the file the same way as CLAUDE.md, but you **add it to `.gitignore`** so it is never committed (the interactive `/init` flow can do this for you). ## How the scopes combine These files do not override one another. Claude Code **concatenates** what it finds: managed content first, then user, then project, and within a directory `CLAUDE.local.md` is appended after `CLAUDE.md`, so your personal notes are read last at that level. Later content is simply read later. A conflict is not resolved by scope; Claude may follow either instruction, so keep the layers consistent. Files in the working directory and every directory above it load at launch; CLAUDE.md files in subdirectories load later, when Claude reads files there. `/memory` lists your user and project memory files, including ones that do not exist yet (selecting one creates it), and `/context` shows which files actually loaded. ## Imports with @path Any CLAUDE.md can pull in other files with `@path/to/file` syntax, for example `See @README for an overview` or `- git workflow @docs/git-instructions.md`. - **Relative paths resolve from the file that contains the import**, not from the working directory. Absolute paths work too. - Imported files can import further files, up to a **maximum depth of four hops**. - Import parsing **skips code spans and fenced code blocks**, so writing `@README` inside backticks keeps it as literal text. - A path containing spaces needs a backslash before each space; a path wrapped in quotes is not imported at all. - Imports **load at launch** together with the file that references them. Splitting a long CLAUDE.md into imports helps organization but **does not reduce its context cost**. ## External imports and the approval dialog An import in a **project-level** memory file is *external* when it resolves outside the working directory, as `@~/.claude/my-project-instructions.md` does. The first time Claude Code meets external imports in a project, it shows an **approval dialog** listing the files. Decline, and those imports stay disabled and the dialog does not appear again. The reason is trust: anyone who can commit to the repository can write a project file, and an import could point it at files on your machine. Imports in your own user-scope files, such as `~/.claude/CLAUDE.md`, are files you wrote yourself, so ordinary sessions load them without the dialog. ## A worktree trap with CLAUDE.local.md Because `CLAUDE.local.md` is gitignored, it exists only in the worktree where you created it. A developer who works across several git worktrees of one repository finds the personal notes present in one checkout and missing in the others. The docs' remedy: 1. Keep the personal notes in a file under your home directory, for example `~/.claude/my-project-instructions.md`. 2. Import that file with `@~/.claude/my-project-instructions.md`, so every checkout that carries the import reads the same file. 3. Approve the external import once when Claude Code asks. ## Summary of who owns what - Organization guidance that nobody may opt out of: the managed file. - Your habits in every repository: `~/.claude/CLAUDE.md`. - Team knowledge reviewed like code: the project file. - Your private notes for one repository: `CLAUDE.local.md`, kept out of git. All four remain guidance; none of them enforces anything on its own.
- Can a developer drop the organization's managed CLAUDE.md with claudeMdExcludes?No. `claudeMdExcludes` applies only to user, project and local memory files; the managed policy CLAUDE.md cannot be excluded, so organization-wide guidance always loads. Organization-wide guidance therefore loads whatever exclusions individuals set.
- Why do personal notes in CLAUDE.local.md vanish when a developer switches git worktrees?Because the file is gitignored, it exists only in the worktree where it was created; other checkouts never receive it. The docs' fix is to keep the notes in a home-directory file and import it with an `@~/...` path, approving the external import once.
- How do you mention a path in a Claude Code CLAUDE.md without importing it?Wrap it in backticks. Import parsing skips Markdown code spans and fenced code blocks, so `` `@README` `` stays literal text, while a bare `@README` outside backticks imports the file.
- A project CLAUDE.md must sit at the repository root; .claude/CLAUDE.md is ignored
- ~/.claude/CLAUDE.md applies only to the project where it was created
- A more specific CLAUDE.md scope overrides a broader one
- @path imports load lazily, so they reduce context cost
- Import paths resolve relative to the working directory
- A developer can opt out of the managed CLAUDE.md with claudeMdExcludes