AnthropicClaude Certified Architect – Foundations2026-103.1 Configure CLAUDE.md files with appropriate hierarchy, scoping, and modular organization
Put team instructions where everyone receives them
Completed by the knowledge check
Learning objective
Map user ~/.claude/CLAUDE.md, project CLAUDE.md or .claude/CLAUDE.md, and directory-level instruction scopes; diagnose missing team rules stored only in personal configuration.
Core idea
Choose an instruction file by its audience and when its contents must enter context. A convention in your home directory can shape every project you open without reaching anyone who clones the repository. A committed project instruction reaches the team; a nested instruction reaches sessions working in that part of the tree.
Claude Code reads these Markdown files as guidance. Their contents accumulate in context rather than behave like settings with a winner at each scope. Locating a rule correctly makes it available, but neither its location nor emphatic wording guarantees compliance. Diagnose delivery before rewriting the rule, and use a hook when an operation must run at a defined event.
How it works
Match the location to the audience
The documented instruction locations separate personal preferences from shared conventions:
| Location | Intended audience | Appropriate content |
|---|---|---|
~/.claude/CLAUDE.md | You, across projects | Personal explanation and workflow preferences |
Root CLAUDE.md or .claude/CLAUDE.md | The project team through source control | Build commands, testing expectations, architectural constraints |
packages/api/CLAUDE.md | Work involving that directory | API-specific conventions that other packages do not need |
Root CLAUDE.local.md | You, in this project | Sandbox URLs and preferred local test data |
The dot directory in .claude/CLAUDE.md does not make that file personal. It is an alternative location for project instructions. Commit it if the team should receive it. Conversely, CLAUDE.local.md is a personal project file even though it lives beside the shared code. Add it to .gitignore so it is not committed; do not assume its filename alone prevents sharing.
A gitignored CLAUDE.local.md exists only in the worktree where you created it. It is not a reliable delivery mechanism for another worktree or teammate. For a personal convention that should apply across projects, use the user-level file. For a convention that everyone needs, use the shared project file rather than telling teammates to copy your local notes.
Organizations can also deploy managed instructions. The documented locations are /Library/Application Support/ClaudeCode/CLAUDE.md on macOS, /etc/claude-code/CLAUDE.md on Linux and WSL, and C:\Program Files\ClaudeCode\CLAUDE.md on Windows. Individual settings cannot exclude this managed file. Its organizational distribution distinguishes it from a developer’s home file.
Separate startup loading from directory loading
Claude Code loads CLAUDE.md and CLAUDE.local.md in the working directory and its ancestors at launch. If you start in packages/api/, the repository’s root instructions and the API directory’s instructions enter context immediately. If you start at the root, the nested API file loads when Claude reads, writes, or edits another file in its directory.
The launch directory therefore changes which instructions are present before the first task. A database rule placed in packages/api/src/db/CLAUDE.md can be absent from an API session until Claude accesses that subtree. This is appropriate for database-only guidance. It is the wrong location for a rule every API task needs before examining files.
Across the directory hierarchy, files are concatenated from the filesystem root toward the working directory. Within a directory, CLAUDE.local.md is appended after CLAUDE.md. Reading an instruction later does not cancel conflicting text read earlier: Anthropic warns that Claude might follow either conflicting instruction. Keep shared and personal files consistent rather than treating the nested file as an override.
Use execution mechanisms for mandatory actions
A line such as “format every edited file” in CLAUDE.md asks Claude to remember a convention. A Claude Code command hook runs a script at a lifecycle event. For a shared formatter, configure the hooks key in .claude/settings.json, select PostToolUse, and use matcher: "Edit|Write" with an inner hook whose type is "command" and whose command runs the formatter. The hook input includes tool_input.file_path for these file tools.
PostToolUse runs after a successful tool call. An Edit|Write matcher covers those tools, not a Bash command or an external process that rewrites the same file. It also cannot prevent the completed edit. The convention’s prose explains the expected style; the configured script performs the formatting on the selected event. This is Claude Code configuration, distinct from the Agent SDK policy hooks in 1.5.1 and 1.5.3.
Key distinctions and trade-offs
User scope versus project-local scope: Both are personal, but ~/.claude/CLAUDE.md spans projects while CLAUDE.local.md supplies notes for one project. Neither replaces a committed team instruction.
Root versus nested scope: Root instructions are available from the start of a root session. Nested files defer package details until the session accesses that area, avoiding unrelated guidance. Put a prerequisite higher than the work it governs.
Instruction hierarchy versus enforcement: The hierarchy determines delivery and context order. A settings-based hook determines when a script executes. Moving prose into a more specific file does not turn it into a deterministic gate.
Keeping everything at the root improves initial availability but loads package conventions into unrelated work. Keeping everything deeply nested can delay instructions a task needs immediately. Choose the smallest scope that still makes the rule available before the relevant decision.
Architecture / decision scenario
A developer-productivity team uses Claude Code in a repository containing API and web packages. The lead’s sessions use the correct test command, but a new teammate’s sessions choose a different runner. The repository root has no test instruction; the command exists only in the lead’s ~/.claude/CLAUDE.md.
Move the shared test command into a committed root CLAUDE.md or .claude/CLAUDE.md. Keep the lead’s personal response preference in the home file. Store a private sandbox URL in root CLAUDE.local.md and ignore that file. Put API-only error conventions in packages/api/CLAUDE.md, accepting that a root session receives them when it accesses API files.
The team also requires formatting after Claude’s file-tool edits. Configure hooks.PostToolUse in shared .claude/settings.json with the Edit|Write matcher and a command hook for the project formatter. Do not claim that this matcher covers every possible disk change. Check loaded launch instructions with /context and use /memory to edit the misplaced rule; 3.1.4 owns that diagnostic workflow.
Common exam traps
- Treating a successful session on one laptop as proof that the repository distributes its rules.
- Assuming
.claude/CLAUDE.mdis private because it lives in a dot directory. - Putting team standards in
CLAUDE.local.mdand expecting a clone to receive them. - Expecting nested instructions to be present at the start of every root session.
- Assuming a more specific instruction overrides contradictory text higher in the tree.
- Equating a formatting instruction with a configured formatter hook.
What to remember
Choose the file by audience, then check when it loads. User instructions are personal across projects; local instructions are personal within a project; committed project and nested files carry team guidance. Context order does not resolve contradictions. Use the hooks settings key and an appropriate lifecycle event when the requirement is to execute a script rather than deliver advice.
Knowledge check
A team lead’s Claude Code sessions always use the project’s test command. A new teammate, working from an up-to-date clone, gets a different test runner. The repository holds no test instruction; the command is written only in the lead’s ~/.claude/CLAUDE.md. Which change gives every teammate the command?
~/.claude/CLAUDE.md.claude/CLAUDE.md committed to the repositoryCLAUDE.local.md at the lead’s repository root~/.claude/CLAUDE.md~/.claude/CLAUDE.md is personal and spans the lead’s projects; it never travels with the repository, which is why one clone behaves differently. A project file, at the root or under .claude/ , is shared through version control. Fixing one teammate’s home file leaves the next one broken, and CLAUDE.local.md is a personal per-project file meant to stay out of Git.Engineers start Claude Code at the repository root. packages/api/CLAUDE.md says to plan API changes against openapi.yaml. Asked for an API change, Claude writes a plan before opening any file, and the plan ignores that rule. What explains it?
CLAUDE.md imports itpackages/api/CLAUDE.md overrides the nested file wherever the two disagreepackages/api/CLAUDE.md files from the working directory and its ancestors; a file in a subdirectory loads once Claude reads, writes or edits another file there. A root session that plans before touching the package has not received the rule yet. A rule needed before any file is opened belongs higher in the tree.A developer’s ~/.claude/CLAUDE.md says to use npm, and the committed project CLAUDE.md says to use pnpm. Claude Code switches between the two from one task to the next. What fixes it?
npm line into CLAUDE.local.md , which Claude reads last and obeyspnpm line into a nested CLAUDE.md , which overrides its ancestorspnpm line as IMPORTANT so that it outranks the personal oneA team requires its formatter to run on every file Claude changes with Edit or Write, for every developer on the project. Which configuration meets the requirement?
PreToolUse command hook with matcher Edit|Write in .claude/settings.jsonCLAUDE.md telling Claude to format every edited filePostToolUse command hook with matcher Edit|Write in .claude/settings.jsonPostToolUse command hook with matcher Edit|Write in ~/.claude/settings.jsonPostToolUse fires after the tool call succeeds, when there is a changed file to format. PreToolUse runs before the edit exists. The shared .claude/settings.json reaches the team, while a user settings file reaches one developer.References
- Anthropic, How Claude remembers your project
- Anthropic, Settings files and precedence
- Anthropic, Automate actions with hooks
- Anthropic, Hooks reference