Task Statement 3.1·Domain 3 — 20% of exam
CLAUDE.md Hierarchy, Scoping, and Modular Organisation
Configure CLAUDE.md files with appropriate hierarchy, scoping, and modular organization
Official Exam Guide Objectives
The objectives below are quoted from Anthropic's Claude Certified Architect – Foundations exam guide, v1.1. Read the exam guide summary for the full blueprint.
Knowledge of
- The CLAUDE.md configuration hierarchy: user-level (~/.claude/CLAUDE.md), project-level (.claude/CLAUDE.md or root CLAUDE.md), and directory-level (subdirectory CLAUDE.md files)
- That user-level settings apply only to that user—instructions in ~/.claude/CLAUDE.md are not shared with teammates via version control
- The @import syntax for referencing external files to keep CLAUDE.md modular (e.g., importing specific standards files relevant to each package)
- .claude/rules/ directory for organizing topic-specific rule files as an alternative to a monolithic CLAUDE.md
Skills in
- Diagnosing configuration hierarchy issues (e.g., a new team member not receiving instructions because they're in user-level rather than project-level configuration)
- Using @import to selectively include relevant standards files in each package's CLAUDE.md based on maintainer domain knowledge
- Splitting large CLAUDE.md files into focused topic-specific files in .claude/rules/ (e.g., testing.md, api-conventions.md, deployment.md)
- Using the /memory command to verify which memory files are loaded and diagnose inconsistent behavior across sessions
What You Need to Know
Claude Code picks up CLAUDE.md files from three places, and a surprising number of exam items reduce to noticing that a rule was written at the wrong one. Knowing what each level reaches — and what it cannot — is most of this task statement.
The Three-Level Hierarchy
Scope answers exactly one question: who receives this instruction? The guide names three levels; two more files sit beside them and turn up in answer options.
| File | Who receives it | Travels through git? |
|---|---|---|
~/.claude/CLAUDE.md | You, on this machine, in every project | No |
CLAUDE.md at the repository root | Everyone who clones the repository | Yes |
.claude/CLAUDE.md | The same: the alternative project location | Yes |
CLAUDE.local.md beside a CLAUDE.md | You, in this checkout only (gitignored by convention) | No |
packages/api/CLAUDE.md (any subdirectory) | Everyone, but only once Claude works in that subdirectory | Yes, loaded on demand |
Managed policy CLAUDE.md (see Deep Dive) | Everyone on the machine, deployed by the organisation | No, installed by IT |
User-level: ~/.claude/CLAUDE.md
Yours alone. It sits in your home directory rather than in any repository, which means git never sees it and it never reaches anybody else. A new teammate cloning the project inherits none of it. Reserve this level for things that are genuinely about you: how verbose you like responses, an output style you prefer, shortcuts nobody else would want.
Project-level: .claude/CLAUDE.md or root CLAUDE.md
Everyone's. It is committed with the code, so cloning or pulling the repository brings it along automatically for every developer. Anything the team has agreed on belongs here — naming conventions, how errors are handled, what testing is expected, architectural decisions, the review checklist.
Two paths are equally valid at this level: CLAUDE.md sitting at the repository root, or .claude/CLAUDE.md inside the .claude directory. Exam items use both, so neither is a signal that something is wrong.
Directory-level: subdirectory CLAUDE.md files
Scoped to work happening in that part of the tree. These carry conventions that are real for one package and irrelevant elsewhere — REST conventions in /packages/api/CLAUDE.md, say, which the frontend package has no use for.
A subdirectory file below where you launched Claude is discovered but not loaded at launch. It joins the context on demand, the first time Claude reads or edits a file in that subdirectory, so it arrives after everything that loaded at start-up. That is worth remembering when behaviour differs between two sessions: one may simply never have touched the directory whose file carries the rule.
Loading Order and Conflict Handling
It is tempting to read three levels as three tiers of precedence. That is not how CLAUDE.md behaves, and the Anthropic memory docs say so directly: "All discovered files are concatenated into context rather than overriding each other." Everything applicable ends up in the same context window together, and nothing displaces anything.
What the docs describe is a load order — the sequence in which files arrive — rather than a chain of overrides:
- Ordering runs from broadest scope to most specific, so a project instruction lands in context after a user instruction. Down the directory tree, "content is ordered from the filesystem root down to your working directory," which means "instructions closer to where you launched Claude are read last."
- At any one level,
CLAUDE.local.mdfollowsCLAUDE.md, putting your personal notes last in that directory.
Arriving later is not the same as winning. On this the docs leave no room: "if two rules contradict each other, Claude may pick one arbitrarily." CLAUDE.md reaches the model as a user message rather than as part of the system prompt, and Anthropic states plainly that "there's no guarantee of strict compliance." It is guidance that is usually followed — not a configuration layer resolving conflicts deterministically.
So if the project file says "use tabs" and your user file says "use spaces", both are in context and Claude may follow either. For an ordinary convention the fix is to remove the contradiction, keeping one statement in the scope that should own it, rather than hoping load order settles it.
Which has a practical consequence worth carrying into the exam. Where a rule has to hold on every single run — a tool that must stay blocked, a formatter that must run, a permission that must not be granted — scoping it into the right CLAUDE.md does not make it binding. Put it in settings.json, which the client applies whatever the model concludes, or in a hook, which fires at a fixed point in the lifecycle. The docs state the division outright: "Settings rules are enforced by the client regardless of what Claude decides to do. CLAUDE.md instructions shape Claude's behavior but are not a hard enforcement layer."
CLAUDE.md concatenates — settings.json overrides, step 1: Three CLAUDE.md levels — user, project, directory
Modular Organisation with @ path imports
Once a CLAUDE.md runs past a few hundred lines it stops being pleasant to maintain, and the @ syntax exists to break it apart. A line is just @ followed by a path — there is no @import keyword, whatever a good proportion of the write-ups online show.
The syntax in your CLAUDE.md:
# .claude/CLAUDE.md
Coding standards:
@./standards/naming-conventions.md
@./standards/error-handling.md
@./standards/testing-requirements.mdEvery @<path> pulls that file inline as the CLAUDE.md loads. A relative path resolves from the file that contains the import, not from where you launched Claude, so the lines above read .claude/standards/…. Because each package's CLAUDE.md imports only what it needs, the API package takes the API conventions and the frontend takes the component rules, with nothing written twice.
Per-package imports in a monorepo
The guide's skill is "Using @import to selectively include relevant standards files in each package's CLAUDE.md based on maintainer domain knowledge". The shape: shared standards live once, in one folder, and each package's own CLAUDE.md names the ones its maintainers judge relevant, then adds what is true only there.
# packages/payments-api/CLAUDE.md
@../../docs/standards/api.md
@../../docs/standards/pci-handling.md
- Every amount is integer minor units, in the currency on the order record.# packages/web-ui/CLAUDE.md
@../../docs/standards/react.md
@../../docs/standards/accessibility.mdThe ../../ climbs from the package folder to the repository root, because paths resolve from the importing file. The web UI never loads the PCI rules, and editing api.md updates every package that imports it, so copies cannot drift. Because these are directory-level files, their imports arrive with them: on demand, when Claude first works in that package.
A large monorepo has the opposite problem too: launching Claude inside one package also picks up CLAUDE.md files from the directories above it, which may belong to other teams. The claudeMdExcludes setting takes glob patterns, matched against absolute paths, and skips the files they match. It cannot exclude a managed policy CLAUDE.md.
Imports organise; they do not save context
Here is the part that matters for context budgeting: imports resolve eagerly, at launch. The referenced file is inlined the instant Claude reads the CLAUDE.md, exactly as though you had pasted it there yourself. Breaking 600 lines into six files of 100 improves the editing experience and leaves the context Claude receives precisely as large as before. Shrinking what actually loads per session is a different tool — .claude/rules/ with path-scoped frontmatter, covered in Task Statement 3.3, where files load only when the paths match.
Splitting the file doesn't shrink what loads, step 1: One CLAUDE.md, 600 lines, everything in one file
CLAUDE.local.md, local-only overrides
CLAUDE.local.md sits beside CLAUDE.md at any level and loads by the same mechanism. Three differences are worth holding:
- Loading order. It arrives after the
CLAUDE.mdbeside it, giving it the final word within that directory — subject, still, to conflicts resolving arbitrarily. - Gitignored by convention. The
.localsuffix signals "not for committing", and most teams add it to.gitignoreso private adjustments stay private. - What it's for. The committed
CLAUDE.mdcarries what the team agreed; theCLAUDE.local.mdbeside it carries what only you need here — a scratch directory you favour, an explanation you are tired of retyping, a debugging note with a short life expectancy.
The clean way to think about it: CLAUDE.local.md is ~/.claude/CLAUDE.md narrowed to one repository. Reaching for it to express something the whole team should follow is a signal that the rule belongs in CLAUDE.md instead.
The .claude/rules/ Directory
Rather than one CLAUDE.md carrying everything, .claude/rules/ holds a file per topic:
testing.md— test naming, assertion patterns, fixture usageapi-conventions.md— endpoint naming, request/response schemasdeployment.md— deployment checklist, environment configuration
Any of these may carry YAML frontmatter that scopes it to particular paths, which Task Statement 3.3 covers properly. A rules file without frontmatter simply loads for every session. The split leaves CLAUDE.md short: a project overview, the build and test commands, and the few rules that apply everywhere.
.claude/
├── CLAUDE.md # overview, commands, universal rules
└── rules/
├── testing.md
├── api-conventions.md
├── deployment.md
└── frontend/
└── components.md # subfolders are discovered tooThree further points about the directory:
- Discovery is recursive. Every
.mdfile under.claude/rules/, in subfolders included, is picked up. - Symlinks work, so one rule set can be shared across several repositories.
- User-level rules exist too, in
~/.claude/rules/, and load before project rules. As with CLAUDE.md, neither set overrides the other: if a user rule and a project rule conflict, Claude may follow either, so keep them consistent.
Choosing the mechanism
Each goal has one mechanism that actually achieves it:
| Goal | Mechanism |
|---|---|
| Organise a large file for editing | @ imports or .claude/rules/ |
| Reduce what loads into context | .claude/rules/ with paths: frontmatter (3.3) |
| Load a procedure only when a task needs it | A skill (3.2) |
| Guarantee that something happens or is blocked | A hook or settings.json |
The /memory Command
The exam guide names /memory as the command for verifying which memory files are loaded. It earns its place when behaviour drifts — between two sessions, or between two developers running what should be identical setups — because it answers the question underneath most of those puzzles: are the files you assume are loaded genuinely loaded?
When an instruction is not followed
Work down this ladder; each rung rules out one cause.
| Step | Check | What it rules out |
|---|---|---|
| 1 | Is the file loaded? (/memory on the exam; /context all today) | A file that is missing, misplaced or not yet loaded |
| 2 | Scope: does this file's location load for this user and this session? | A rule parked at user level, in CLAUDE.local.md, or in a subdirectory not yet touched |
| 3 | Conflict: does another loaded file say the opposite? | A contradiction Claude may resolve either way |
| 4 | Specificity: is the instruction concrete enough to act on? | "Format code properly" where "Use 2-space indentation" was meant |
| 5 | Mechanism: must this hold on every run? | A guarantee asked of guidance; move it to a hook or settings.json |
Writing Instructions That Get Followed
Placement decides who receives an instruction; wording decides whether it is acted on. Concrete, checkable instructions beat vague ones:
| Weak | Strong |
|---|---|
| "Format code properly" | "Use 2-space indentation" |
| "Test your changes" | "Run npm test before committing" |
| "Keep files organised" | "API handlers live in src/api/handlers/" |
| "Be careful with the database" | "Never run migrations against prod; use make migrate-staging" |
Structure the file with headers and bullets, and spend its lines on what Claude cannot see for itself: pitfalls, the reasons behind decisions, conventions that differ from the default. Do not restate what the code already shows, such as directory listings or dependency lists; that is pure context cost. Notes meant only for human maintainers can go in a block-level HTML comment, which is stripped before the file enters context (see Deep Dive).
The Critical Exam Scenario: New Team Member Not Receiving Instructions
This is the exam's favourite trap for Task Statement 3.1, and the setup barely varies:
Someone who has been on the team a while gets exactly the behaviour they expect — API naming, test structure, error handling all followed. A new joiner clones the same repository, checks out the same branch, and gets output that ignores every one of those conventions.
The cause is the same every time. Those conventions live in the long-standing developer's own ~/.claude/CLAUDE.md, not in the repository's .claude/CLAUDE.md or root CLAUDE.md. Nothing at user level travels through git, so the new joiner never received any of it — and never could have, on any branch. The misplacement is hard to spot from the inside because it keeps working perfectly for the person who made it.
The fix: move instructions from user-level to project-level configuration.
Learn to recognise it from the pairing alone. A new team member plus inconsistent behaviour, with the repository and branch confirmed identical, points at where the configuration lives rather than at anything in the code.
Same repo, same branch — the fix was where the rule lived, step 1: A longtime developer keeps conventions in ~/.claude/CLAUDE.md
Deep Dive
settings.json: the precedence chain CLAUDE.md doesn't have
CLAUDE.md files concatenate; settings.json files don't — they resolve through a genuine five-level precedence order, highest to lowest: managed (enterprise policy, can't be overridden by anything) → command line arguments (temporary session overrides) → local (overrides project and user) → project (overrides user) → user (lowest, applies only when nothing else specifies the setting). A project actually has two settings files: .claude/settings.json for settings checked into source control and shared with the team, and .claude/settings.local.json for settings that are not checked in — personal preferences and experimentation.
Sourcecode.claude.com › settingsfetched 2026-07-30
settings.json locations, including the enterprise managed path
User-scope settings live at ~/.claude/settings.json and apply across all projects. Enterprise managed settings (managed-settings.json) load from an OS-specific path that individual users can't touch: /Library/Application Support/ClaudeCode/ on macOS, /etc/claude-code/ on Linux and WSL, and C:\Program Files\ClaudeCode\ on Windows.
Sourcecode.claude.com › settingsfetched 2026-07-30
The fourth CLAUDE.md scope: managed policy
Beyond the user/project/directory levels introduced above, Claude Code recognises a fourth scope: managed policy, loaded from the same OS-specific system paths as managed settings (e.g. /etc/claude-code/CLAUDE.md on Linux/WSL, C:\Program Files\ClaudeCode\CLAUDE.md on Windows). A managed policy CLAUDE.md is organisation-deployed, applies to every session on the machine, and "cannot be excluded" by any individual setting — it always applies, "regardless of individual settings."
Sourcecode.claude.com › memoryfetched 2026-07-30
@import mechanics: depth limit and what parsing skips
Imports recurse — an imported file can itself import others — but only to a maximum depth of four hops in current docs (older documentation said five; see the divergence log). Import parsing deliberately skips Markdown code spans and fenced code blocks, so wrapping a path in backticks lets you mention it in prose without triggering an import of it.
Sourcecode.claude.com › memoryfetched 2026-07-30
Import resolution, exclusions and file limits
- Relative paths in an import resolve relative to the file that contains the import, and imports are loaded at launch.
- External imports: importing a file from outside the project triggers an approval dialog.
claudeMdExcludesis a setting that skips matching CLAUDE.md files, for monorepos where other teams' files would otherwise load.- Block-level HTML comments in a CLAUDE.md are stripped before it reaches the model, so maintainer notes cost no context.
- Size: a file over 4 MiB is skipped entirely.
.claude/rules/supports symlinks.
Sourcecode.claude.com › memoryfetched 2026-11-19
Sharing personal preferences across worktrees
CLAUDE.local.md is scoped to a single working-tree checkout, so it doesn't follow you into a git worktree of the same repo. To share personal instructions across worktrees, import a file from your home directory instead of relying on CLAUDE.local.md — e.g. a line reading @~/.claude/my-project-instructions.md inside the project CLAUDE.md.
Sourcecode.claude.com › memoryfetched 2026-07-30
/init and the 200-line size guidance
/init generates a starting CLAUDE.md by analysing the codebase: it creates a file with build commands, test instructions, and conventions it discovers, and if a CLAUDE.md already exists, /init suggests improvements rather than overwriting it. Separately, the docs recommend keeping each CLAUDE.md under 200 lines, since "longer files consume more context and reduce adherence" — the same argument that motivates splitting into .claude/rules/.
Sourcecode.claude.com › memoryfetched 2026-07-30
Quick Reference
| Item | Value / behaviour |
|---|---|
| User-level CLAUDE.md | ~/.claude/CLAUDE.md — personal, not git-shared |
| Project-level CLAUDE.md | .claude/CLAUDE.md or root CLAUDE.md — shared via git |
| Directory-level CLAUDE.md | subdirectory CLAUDE.md — loads on demand when Claude reads files there |
| Managed policy CLAUDE.md | OS-specific enterprise path — cannot be excluded, applies to every session |
| CLAUDE.md load order | broadest → most specific; CLAUDE.local.md loads after CLAUDE.md at the same level |
| CLAUDE.md conflict handling | concatenated, not overridden — "Claude may pick one arbitrarily" |
| settings.json precedence | managed > CLI args > local > project > user (strict, highest wins) |
| settings.json locations | user ~/.claude/settings.json; project .claude/settings.json (shared) / .claude/settings.local.json (personal); enterprise OS-specific path |
| @ import syntax | @path on its own line — no @import keyword in current docs |
| @ import depth | 4 hops max, recursive (current docs; older docs said 5) |
| @ import scope skip | markdown code spans / fenced code blocks are never parsed for imports |
| /init | generates or improves a CLAUDE.md from codebase analysis |
| /memory | exam answer for verifying which memory files are loaded; never triggers loading |
| /context all | current product: lists what this session actually loaded, under Memory files |
| @ import path resolution | relative to the importing file; loaded at launch |
| Import from outside the project | triggers an approval dialog |
claudeMdExcludes | skips matching CLAUDE.md files (not managed policy) |
| Block-level HTML comments | stripped before CLAUDE.md enters context |
| CLAUDE.md over 4 MiB | skipped entirely |
~/.claude/rules/ | user-level rules; load before project rules, neither overrides |
| Recommended CLAUDE.md size | under 200 lines per file |
.claude/rules/ (no paths) | loads at launch, same priority as .claude/CLAUDE.md |
Exam Traps
More wrong answers, and why each fails
| Tempting answer | Why it fails | Choose instead |
|---|---|---|
Commit CLAUDE.local.md (or take it out of .gitignore) so teammates or CI receive it | It is the personal layer; committing it ships everyone's private notes and repurposes the one uncommitted file | Move the shared content into CLAUDE.md or .claude/CLAUDE.md |
Add the organisation's managed policy CLAUDE.md to claudeMdExcludes because it is noisy | Managed policy files cannot be excluded by any individual setting | Raise it with whoever deploys the policy |
| Keep growing one CLAUDE.md to 900 lines so every rule is in one place | "Longer files consume more context and reduce adherence", and the docs' target is under 200 lines | Split by topic into .claude/rules/, scoped by path where possible |
How This Is Tested
| Stem signal | Answer | Wrong-answer pattern beside it |
|---|---|---|
| A new team member, same repository and branch, does not get the conventions | They are in user scope; move them to .claude/CLAUDE.md or root CLAUDE.md | Stale clone; a contradicting rule on the new joiner's machine |
| "How do you verify which memory files are loaded?" | /memory (today, /context all shows what loaded) | Re-run or reload something to force loading |
| CLAUDE.md is too large and rules are being missed | Split into topic files in .claude/rules/, scoped by path | Split into @ imports, which still load at launch |
| Different packages need different standards from one shared set | Each package's CLAUDE.md imports the relevant standards files | Paste copies into each package; one root file with a heading per package |
| One package's conventions leak into another package's work | A directory-level CLAUDE.md in the package that owns them | A sentence or heading in the root file saying where the rule applies |
| Behaviour is inconsistent across sessions | Check which files loaded, then look for contradictions and for subdirectory files that load only on demand | Assume the more specific file wins |
| A rule must hold on every run | A hook or settings.json | Stronger wording in CLAUDE.md; moving it to a "higher" CLAUDE.md |
Official sample question 6, which belongs to Task Statement 3.3, shows the directory-level trap from the exam's side. Its option D, "Place a separate CLAUDE.md file in each subdirectory containing that area's specific conventions", is wrong because it "can't easily handle files spread across many directories since CLAUDE.md files are directory-bound."
Practice Scenario
Your team's root CLAUDE.md carries REST endpoint conventions — kebab-case paths, a fixed { data, error, metadata } response envelope. Claude has started applying that envelope to React component props in packages/frontend/, and two pull requests this week were reworked because of it. What's the most effective first step?
Practice Questions
Exam simulator
Question 1 of 13
Scenario · Claude Code for Continuous Integration
Your CI review job posts comments that ignore the team's rule against swallowing exceptions, yet reviews the tech lead runs on their laptop always flag it. The runner clones the repository fresh under a service account. The rule was agreed six weeks ago, and git log shows the project CLAUDE.md has not changed since March. What change would most effectively fix this?
Sources
- How Claude remembers your project (CLAUDE.md and auto memory) — Anthropic
- Claude Code Settings — Anthropic
- Claude Certified Architect Foundations Exam Guide — Task Statement 3.1 — Anthropic