3.1 CLAUDE.md Hierarchy, Scoping, and Modular Organisation
What You Need to Know
Section titled “What You Need to Know”A CLAUDE.md file is a Markdown file of instructions for Claude Code. Claude Code reads these files at three levels: user (one person), project (the whole team) and directory (one folder). @ path imports (references to other files by their path) and the .claude/rules/ directory split instructions across several files.
This lesson uses one made-up example throughout: an osteopath practice whose two developers use Claude Code on its booking website. Every session should follow the practice’s naming rules and testing requirements. One developer likes short answers. The booking API package has its own REST conventions.
The Three-Level Hierarchy
Section titled “The Three-Level Hierarchy”User-level: ~/.claude/CLAUDE.md
This file applies only to you. It is in your home directory, outside any repository. So it is not version-controlled, and git never shares it. A new teammate who clones the repo will not get these instructions. Keep this level for strictly personal preferences: verbosity settings, a preferred output style, your own shortcuts. The developer who likes short answers says so here.
Project-level: .claude/CLAUDE.md or root CLAUDE.md
This file applies to everyone on the project. It is in the repository and is version-controlled. Every developer who clones or pulls the repo gets these instructions automatically. Team-wide standards belong here: naming conventions, error handling patterns, testing requirements, architecture decisions, code review checklists. Both .claude/CLAUDE.md (inside the .claude directory) and a CLAUDE.md at the repository root are valid project-level locations. The practice’s naming rules belong here.
Directory-level: subdirectory CLAUDE.md files
These files apply when you work in that specific directory. Use them for package-specific conventions that differ from the project root. For example, a /packages/api/CLAUDE.md might hold REST conventions that the frontend package never needs. The booking API’s REST conventions belong in that package’s CLAUDE.md.
Loading Order and Conflict Handling
Section titled “Loading Order and Conflict Handling”The Anthropic memory docs are explicit: “All discovered files are concatenated into context rather than overriding each other”. Every applicable file loads into the same context window.
CLAUDE.md files do not form a configuration with strict precedence: the docs describe a load order. The files load in order from the broadest scope to the most specific, so a project instruction appears after a user instruction. Across the directory tree, “content is ordered from the filesystem root down to your working directory”. So “instructions closer to where you launched Claude are read last”. When you start a session in the booking API package, Claude reads the user file, then the project file, then the package file.
A file that Claude reads last does not win a conflict: nothing marks one file as the winner. The docs say it directly: “if two rules contradict each other, Claude may pick one arbitrarily”. CLAUDE.md is delivered as a user message, not as part of the system prompt. Anthropic says “there’s no guarantee of strict compliance”. Treat CLAUDE.md as guidance that the model usually follows, not as a configuration layer with deterministic overrides.
So do not depend on CLAUDE.md scoping for a rule that must apply on every run. Examples of such a rule are a blocked tool, a required formatter and a permission policy. Put that rule in settings.json. The client enforces settings.json regardless of what Claude decides. Or use a hook, which runs at a fixed lifecycle event. The docs say so directly: “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”. A tool that the practice must always block belongs in settings.json.
Modular Organisation with @ path imports
Section titled “Modular Organisation with @ path imports”When one CLAUDE.md grows past a few hundred lines, it becomes hard to maintain. The @ syntax lets you split it across several files and reference those files from the main file. The directive is simply @ followed by a path. There is no @import keyword, even though many pages online write it that way.
For example:
Coding standards:
@./standards/naming-conventions.md@./standards/error-handling.md@./standards/testing-requirements.mdAt load time, the file that each @<path> line names is inlined into the CLAUDE.md. Per-package CLAUDE.md files can import only the standards that apply to them. The API package imports API conventions and the frontend package imports component rules. No standard is duplicated. The practice’s booking API does the same.
The docs say that imported files load alongside the CLAUDE.md that references them. The file is inlined at the moment that Claude reads your CLAUDE.md, as if you had pasted its text there. Splitting a 600-line CLAUDE.md into six 100-line imports makes the source nicer to work in. But the context stays the same size. To make the context of each session smaller, use .claude/rules/ with path-scoped frontmatter (a block of settings at the top of the file that lists the paths it applies to) (Task Statement 3.3). Those files only load when Claude works in matching paths.
CLAUDE.local.md, local-only overrides
Section titled “CLAUDE.local.md, local-only overrides”CLAUDE.local.md is next to CLAUDE.md at any level in the hierarchy, and it loads in the same way. Three small differences separate it from CLAUDE.md.
- Loading order.
CLAUDE.local.mdis appended afterCLAUDE.mdat the same level, so your personal notes are the last thing Claude reads there. That is load order, not precedence: the file that Claude reads last does not win a contradiction. If two instructions conflict, Claude may still pick either one. - Gitignored by convention. The
.localsuffix marks files that you do not want to commit. Most teams addCLAUDE.local.mdto.gitignoreso personal changes stay personal. - What it’s for. The shared
CLAUDE.mdholds the team’s rules. TheCLAUDE.local.mdnext to it holds your personal preferences for this repo, for example a favourite scratchpad path, a verbose explanation that you paste again and again, a temporary debugging note that you will delete next week.
CLAUDE.local.md is a project-scoped version of ~/.claude/CLAUDE.md. A team rule belongs in CLAUDE.md instead. A practice developer’s scratchpad path belongs in CLAUDE.local.md. The testing requirements do not.
The .claude/rules/ Directory
Section titled “The .claude/rules/ Directory”Instead of a single CLAUDE.md, the .claude/rules/ directory can hold topic-specific rule files.
testing.md: test naming, assertion patterns, fixture usageapi-conventions.md: endpoint naming, request/response schemasdeployment.md: deployment checklist, environment configuration
Each file can optionally include YAML frontmatter with path scoping (Task Statement 3.3). Without frontmatter, rules files load for all sessions, so the practice’s testing.md would load in every session.
What Survives Compaction
Section titled “What Survives Compaction”When /compact summarises a long session, the project-root CLAUDE.md is loaded again in full. Its location gives it no special status. After compaction, Claude reads it again from disk and injects it into the context again. Your instructions were never part of the conversation history, so the summariser has nothing there to compress.
Two things are not loaded again automatically: nested CLAUDE.md files in subdirectories, and .claude/rules/ files with paths: frontmatter. Both load on demand. So they load again when Claude next reads a matching file, not when compaction ends. When an instruction seems to disappear after /compact, this is usually the reason. The other possible cause is an instruction that only ever existed in the conversation. Compaction can summarise that instruction. A naming rule typed only into a chat at the practice has no file that Claude can read again.
Diagnosing What Loaded: /memory and /context
Section titled “Diagnosing What Loaded: /memory and /context”When behaviour differs between sessions or developers, check which memory files each session loaded. If Claude Code follows the conventions for one practice developer and ignores them for the other, that check gives the answer.
Current state (checked 6 October 2026): Claude Code splits the job across two commands. /memory lists your CLAUDE.md, CLAUDE.local.md and auto-memory locations, and opens any of them in your editor. /context reports what loaded at launch, under Memory files. To confirm that a file is loaded, run /context and read that list. The docs say: “check the list under Memory files to verify the CLAUDE.md and CLAUDE.local.md files that should load at launch”. Two kinds of file load on demand, so they are not on that list. They are a CLAUDE.md in a subdirectory of your working directory and a rule with paths frontmatter (Task Statement 3.3). When one of these files loads, a Loaded line with its path appears in the terminal.
In the exam
Section titled “In the exam”The exam tests again and again which level applies where, and whether you can spot the wrong level. Either project-level path may appear.
The favourite trap for Task Statement 3.1 is a new team member not receiving instructions. For months, Claude Code has followed the team’s conventions for one teammate. A new teammate clones the repository and gets inconsistent results that ignore those conventions. The root cause is always a configuration hierarchy problem. The conventions are in the first teammate’s user-level config (~/.claude/CLAUDE.md), not the project-level config. User-level config is not shared via git, so the new teammate never received the conventions. The fix is to move the conventions to project-level configuration. At the practice, the naming rules would have been in one developer’s home directory.
Diagnose this case immediately: when a question pairs “new team member” with “inconsistent behaviour”, check where the configuration is stored.
The exam also tests that the diagnostic commands load nothing.
Source for the /memory and /context details: Claude Code memory docs.
Exam Traps
Section titled “Exam Traps”Sources
Section titled “Sources”- How Claude remembers your project (CLAUDE.md and auto memory) — Anthropic
- Claude Certified Architect Foundations Exam Guide — Task Statement 3.1 — Anthropic
- CCAR-F Exam Guide v1.0: Task Statement 3.1 — Anthropic
Exam Simulator
Section titled “Exam Simulator”Five exam-style multiple-choice questions on CLAUDE.md Hierarchy, Scoping, and Modular Organisation. Pick an answer, then open the explanation.
Question 1
Section titled “Question 1”Developer A’s Claude Code follows the team’s API naming conventions perfectly. Developer B, who joined last week, gets inconsistent naming from Claude Code. Both work on the same repo and branch. What is the most likely root cause?
- A. Developer B has not run /memory to load the configuration files
- B. Developer B needs to install an MCP server to access the naming convention rules
- C. The conventions live in Developer A’s user-level CLAUDE.md, not the project config
- D. The conventions are in a .claude/rules/ file that Developer B’s system does not support
Answer & explanation
Correct: C
- A is wrong: /memory is a diagnostic tool that shows which files are loaded. It does not trigger loading. Configuration loads automatically based on file location.
- B is wrong: MCP servers provide tool integrations, not CLAUDE.md configuration. Naming conventions are configuration, not tools.
- C is correct: User-level CLAUDE.md (~/.claude/CLAUDE.md) is not version-controlled or shared via git. Developer A has the instructions locally; Developer B, having just cloned the repo, does not. Moving instructions to project-level config (.claude/CLAUDE.md) fixes this.
- D is wrong: .claude/rules/ files are inside the repository and version-controlled. If the conventions were there, Developer B would receive them on clone.
Question 2
Section titled “Question 2”A team’s project has grown to include over 200 lines of coding conventions in a single CLAUDE.md file. The file covers naming, testing, deployment, API design, and infrastructure. What is the most maintainable approach to reorganise this?
- A. Use the .claude/rules/ directory with topic-specific rule files (testing.md, api-conventions.md, deployment.md)
- B. Move all conventions to the user-level ~/.claude/CLAUDE.md so each developer can customise
- C. Split the file into multiple CLAUDE.md files in the root directory
- D. Create a skill in .claude/skills/ that loads the conventions on demand
Answer & explanation
Correct: A
- A is correct: The .claude/rules/ directory holds topic-specific rule files. Each file handles one concern (testing, API, deployment). This is the intended alternative to a monolithic CLAUDE.md.
- B is wrong: User-level config is personal and not shared via git. Moving team conventions there means new team members do not receive them.
- C is wrong: You cannot have multiple CLAUDE.md files in the same root directory. The .claude/rules/ directory is the designed mechanism for splitting conventions by topic.
- D is wrong: Skills load on-demand as task-style workflows, either when you invoke them with /name or when the model picks them up from context. Coding conventions should apply to every edit without relying on invocation, which is what .claude/rules/ and CLAUDE.md provide.
Question 3
Section titled “Question 3”A developer runs /memory and discovers that an expected rules file is not showing as loaded. What does this tell them?
- A. They need to run /memory again with a –reload flag to force loading
- B. They need to restart Claude Code because configuration only loads at startup
- C. The /memory command is only available in interactive mode and does not work in their current session
- D. Wrong path, broken frontmatter, or a glob pattern that never matches
Answer & explanation
Correct: D
- A is wrong: /memory does not have a –reload flag. It is a diagnostic tool only.
- B is wrong: Configuration loads based on the files being edited and the hierarchy, not only at startup.
- C is wrong: /memory works in the interactive session to show loaded configuration.
- D is correct: If a rules file is not loaded, the issue is either that the file is missing, has malformed frontmatter, or (for path-scoped rules) the developer is not editing files that match the glob pattern.
Question 4
Section titled “Question 4”A project has packages/api/ with API-specific conventions and packages/frontend/ with component conventions. The team wants each package to follow its own standards without duplicating shared conventions. What is the correct configuration approach?
- A. Create a directory-level CLAUDE.md in each package directory with all conventions, including shared ones
- B. Project-level CLAUDE.md with an @ path import for shared standards, directory-level for package ones
- C. Place all conventions in the user-level config and instruct each developer to copy the right sections
- D. Create one skill per package that developers must invoke before working in that directory
Answer & explanation
Correct: B
- A is wrong: This duplicates the shared conventions in every package directory, creating maintenance burden and drift risk.
- B is correct: the @ path import enables modular organisation. Note the syntax: a line reading @./standards/naming.md, not @import. There is no @import keyword. Shared standards live in one place and are imported where needed. Package-specific conventions live in directory-level CLAUDE.md files. No duplication.
- C is wrong: User-level config is personal and not shared via git. This approach fails for new team members.
- D is wrong: Skills load on-demand as task-style workflows. Conventions should apply to every edit as always-in-context guidance, which CLAUDE.md (and .claude/rules/ for path-scoped cases) provides.
Question 5
Section titled “Question 5”Which of the following is a valid project-level CLAUDE.md location?
- A. ~/CLAUDE.md
- B. node_modules/.claude/CLAUDE.md
- C. /etc/claude/CLAUDE.md
- D. .claude/CLAUDE.md in the repository root
Answer & explanation
Correct: D
- A is wrong: ~/CLAUDE.md is in the user’s home directory, not inside a repository. It is not the same as ~/.claude/CLAUDE.md (user-level) and would not be recognised.
- B is wrong: node_modules/ is for installed dependencies. Configuration inside node_modules is not recognised by Claude Code.
- C is wrong: /etc/ is a system directory. Claude Code does not read configuration from system-level paths.
- D is correct: .claude/CLAUDE.md inside the repository is one of two valid project-level locations (the other being a root CLAUDE.md file).