CLAUDE.md Hierarchy
Where files live
| Level | Path | Shared with |
|---|---|---|
| Managed policy | macOS /Library/Application Support/ClaudeCode/CLAUDE.md; Linux/WSL /etc/claude-code/CLAUDE.md; Windows C:\Program Files\ClaudeCode\CLAUDE.md | All users on the machine (IT-managed) |
| User | ~/.claude/CLAUDE.md | You, every project |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md | The team (commit it) |
| Local | ./CLAUDE.local.md (add to .gitignore) | You, this project |
How they load
CLAUDE.mdandCLAUDE.local.mdin the working directory and every directory above it load at launch.- Files are concatenated, not overriding each other, ordered from filesystem root down to the working directory.
- Files in subdirectories below the working directory load on demand, once Claude reads, writes or edits a file in that subdirectory.
claudeMdExcludes(glob patterns, any settings layer) skips files, useful in monorepos. Managed policy files cannot be excluded.- Extra directories added with
--add-dirload theirCLAUDE.md,.claude/CLAUDE.md,.claude/rules/*.mdandCLAUDE.local.md.
Imports
@path/to/file inside a CLAUDE.md pulls that file in at launch. Relative paths resolve relative to the file containing the import, not the working directory. Imports can nest to a maximum of four hops. Code spans and fenced blocks are not parsed, so ` @README ` stays literal. A path with spaces needs backslash-escaped spaces; quoted paths are not imported.
Commands
/initgenerates a starting CLAUDE.md from your codebase (suggests improvements if one exists)./memoryviews and edits memory files.
Writing guidance (verified, from the docs)
- Target under 200 lines per file; longer files cost context and reduce adherence.
- Be specific and concise; contradictory instructions across files can lead Claude to pick one arbitrarily.
- Move instructions relevant to only part of the codebase into path-scoped rules (3.3); move multi-step procedures into skills (3.2).
It guides; it does not enforce
CLAUDE.md is context, not enforced configuration. To block an action regardless of what Claude decides, use a PreToolUse hook (see Domain 1.4 and 1.5). Subagents receive project CLAUDE.md unless omitClaudeMd is set.
AGENTS.md (verified, version-sensitive)
If a repo has AGENTS.md and no CLAUDE.md in or above the working directory, Claude Code reads AGENTS.md. If both exist, only the CLAUDE.md files load (unless the CLAUDE.md imports AGENTS.md). Reading AGENTS.md directly needs a recent version.
Auto memory vs CLAUDE.md
CLAUDE.md is written by you; auto memory is notes Claude writes (first 200 lines or 25 KB loaded each session). Both are context, not guarantees.
Exam traps
- Treating CLAUDE.md as a security control.
- Expecting a child
CLAUDE.mdto override the parent. They concatenate. - Imports resolved from the working directory instead of the importing file.
- A giant CLAUDE.md holding path-specific rules or procedures.
- Putting personal preferences in the shared file instead of
CLAUDE.local.mdor~/.claude/CLAUDE.md.
References
- How Claude remembers your project — checked Oct 16, 2026
Check your understanding
Personal sandbox URLs for one project, not committed?Show answerHide answer
Answer
./CLAUDE.local.md, gitignored.Do subdirectory CLAUDE.md files load at launch?Show answerHide answer
Answer
No, on demand when Claude touches files there.How do you guarantee
.envis never edited?Show answerHide answerAnswer
APreToolUsehook (or permission deny rule), not CLAUDE.md.