examhub .cc The most efficient path to the most valuable certifications.
Vol. I
In this note ≈ 27 min

CLAUDE.md Files — Hierarchy, Scoping, and Modular Organization

5,400 words · ≈ 27 min read

The CLAUDE.md hierarchy is the central topic of Domain 3.1 on the Claude Certified Architect — Foundations (CCA-F) exam, and it is one of the most scenario-rich topics across the entire 60-question, 120-minute sitting. Task statement 3.1 — "Configure CLAUDE.md files with appropriate hierarchy, scoping, and modular organization" — shows up in both the Code Generation with Claude Code scenario cluster and the Claude Code for Continuous Integration cluster, so every candidate who sits the exam will face at least one or two questions that hinge on understanding exactly where a CLAUDE.md file lives, who sees it, and how its instructions merge with instructions from other levels.

This study note walks through the entire CLAUDE.md hierarchy an architect is expected to master at the foundational tier: the three scoping levels (user, project, directory), the precedence and merge rules between them, the @import syntax for modular file composition, the .claude/rules/ directory pattern as an alternative to a monolithic CLAUDE.md, the /memory command for verifying loaded memory files, the diagnostic pattern when a new teammate is not receiving expected instructions, and the concrete exam traps that separate a 720 pass from an 893 top-percentile score. A clear distinction is drawn between what the CCA-F expects (architecture-level judgment, recognition of scope pitfalls) and what belongs to hands-on implementation depth outside the foundational scope.

What Is CLAUDE.md and Why Does the Hierarchy Matter?

CLAUDE.md is the primary configuration file that Claude Code reads at session startup to establish persistent behavioral instructions, coding conventions, project context, and memory that should apply across conversations. Where a one-shot user prompt only affects a single turn, a CLAUDE.md instruction is injected into Claude's working memory every time a session begins in the relevant directory — which is why the file is sometimes called the "project memory" or "repository memory" file.

The CLAUDE.md hierarchy exists because Claude Code is used in at least three different contexts simultaneously: by individual engineers who have personal habits ("always run pnpm never npm"), by teams who share a repository with collective conventions ("all React components use functional style with hooks"), and by subsystems inside a repository that need local overrides (a /docs directory that should follow Markdown rules instead of TypeScript rules). A single flat configuration file cannot serve all three audiences without constant collisions, so Anthropic designed the CLAUDE.md hierarchy with three merging scopes.

The CLAUDE.md hierarchy is the three-level scoping system Claude Code uses to merge configuration files from different sources into a single effective instruction set.

  • User-level CLAUDE.md lives at ~/.claude/CLAUDE.md and applies to every Claude Code session run by that operating-system user, across every repository.
  • Project-level CLAUDE.md lives at .claude/CLAUDE.md or as a bare CLAUDE.md at the repository root, and applies to every session opened inside that repository.
  • Directory-level CLAUDE.md lives in a subdirectory (for example packages/web/CLAUDE.md) and applies only when Claude Code is operating inside that subdirectory subtree.

Source ↗

Understanding the CLAUDE.md hierarchy is not just a vocabulary test. It is the architectural lens through which the CCA-F exam asks you to diagnose broken configurations, onboard teammates correctly, and avoid leaking personal preferences into shared repositories.

The Three Scoping Levels — User, Project, Directory

Each level of the CLAUDE.md hierarchy serves a specific audience and lives in a specific filesystem location. Misplacing a file by one level is the single most common Domain 3.1 exam trap, so internalize these locations until they are reflexive.

User-Level — ~/.claude/CLAUDE.md

The user-level CLAUDE.md lives at ~/.claude/CLAUDE.md (the tilde expands to the user's home directory — /Users/<name>/ on macOS, /home/<name>/ on Linux, C:\Users\<name>\ on Windows). This file is personal to the operating-system account that owns it. It is not committed to any shared repository. It is not seen by teammates. It is loaded by Claude Code every time the user opens a session, regardless of which project they are working in.

Good candidates for the user-level CLAUDE.md:

  • "Always address me as Jaric, not the user."
  • "Prefer pnpm over npm and yarn for personal scripts."
  • "Use 正體中文 for conversational replies and keep code comments in English."
  • "Default to dark-mode-friendly ANSI color output in terminal text."

Bad candidates (belong in project-level instead):

  • "This repository uses Astro 4 and the Cloudflare Pages adapter."
  • "All database migrations go through pnpm run migrate:new."

The dividing line is: if a teammate cloning the repository would need the instruction to work correctly, it belongs in project-level, not user-level. If the instruction reflects only your personal taste or environment, keep it at user-level.

Project-Level — .claude/CLAUDE.md or Root CLAUDE.md

The project-level CLAUDE.md is the shared repository memory. Claude Code recognizes two canonical locations for the project-level file:

  • <repo-root>/CLAUDE.md — a bare file at the top of the repository.
  • <repo-root>/.claude/CLAUDE.md — inside a .claude/ configuration directory.

Either location is valid; the bare root file is more discoverable and is the most common pattern in open-source Claude Code repositories. The .claude/ directory is preferred when you want to keep a collection of related configuration assets (commands, skills, rules, settings) grouped together.

The project-level file is committed to version control. Every teammate who clones the repository and runs claude inside it will automatically have these instructions loaded. This is the level for:

  • Tech-stack declarations ("This repo is Astro 4 + TypeScript + Cloudflare Pages").
  • Coding conventions ("Use functional React components with hooks; no class components").
  • Architecture constraints ("All database access goes through the db/ package; never import @prisma/client directly in route handlers").
  • Forbidden patterns ("Never use any in TypeScript; never commit files containing TODO or FIXME").
  • Test, build, and deploy commands that Claude should run or suggest.

Directory-Level — Nested CLAUDE.md

A directory-level CLAUDE.md sits inside a subdirectory of the repository and applies only when Claude Code's working context is inside that subtree. For example, in a monorepo with packages/api/, packages/web/, and docs/, each subdirectory can carry its own CLAUDE.md with rules specific to that module:

  • packages/api/CLAUDE.md — "This is the backend API. Use Hono for routing. All handlers must validate input with Zod."
  • packages/web/CLAUDE.md — "This is the Astro frontend. Use .astro components for pages, React islands only when interactivity is required."
  • docs/CLAUDE.md — "This is the documentation directory. Files are Markdown. Follow the docs/STYLE.md guide for headings and frontmatter."

When Claude Code is operating in packages/api/ it will load the user-level, project-level, and packages/api/CLAUDE.md files and merge them. When it moves to packages/web/ the API directory file is replaced by the web directory file. Only the nearest directory-level file on the path from the current working directory up to the repository root is loaded at a given moment — this is a frequent detail tested in scenario questions.

Every CLAUDE.md file on the effective path is merged at session startup. The merge is additive — directory-level instructions supplement project-level, which supplement user-level. A directory-level file does not replace the project-level file; the architect must remember that lower-scope files add rules on top of higher-scope rules rather than erasing them.

Source ↗

Hierarchy Precedence and Merge Semantics

The CLAUDE.md hierarchy does not use a single "winner takes all" model. Instead Claude Code assembles the effective instruction set by reading each applicable file and concatenating the instructions in order of specificity, with the most specific instructions appearing last so they naturally take precedence when Claude reasons about conflicts.

Load Order

When a session starts in <repo>/packages/web/src/routes/login/ the load order is:

  1. ~/.claude/CLAUDE.md (user-level)
  2. <repo>/CLAUDE.md or <repo>/.claude/CLAUDE.md (project-level)
  3. <repo>/packages/web/CLAUDE.md (directory-level — nearest match walking up the tree)

If a directory-level file also exists at <repo>/packages/web/src/routes/CLAUDE.md, it is loaded too; Claude Code walks the directory tree upward from the current working directory and picks up every CLAUDE.md along the way until it reaches the project root.

What Counts as a Conflict

Human-readable natural-language instructions do not collide the way structured keys do — "prefer pnpm" and "always use yarn" are both injected into the context and Claude resolves the apparent contradiction by weighting the more specific source (directory over project over user). In practice, however, well-designed CLAUDE.md files avoid conflicts by keeping each level focused on non-overlapping concerns: user-level for personal habits, project-level for shared conventions, directory-level for module-specific overrides.

Merge Is Additive, Not Replacing

A recurring CCA-F exam trap is the assumption that a directory-level file replaces the project-level file. It does not. If the project-level CLAUDE.md says "always write unit tests with Vitest," and the docs/CLAUDE.md says nothing about tests, the Vitest instruction is still in effect when Claude is working inside docs/. The directory file only adds instructions; it never deletes them.

@import Syntax for Modular Organization

As a repository grows, a monolithic CLAUDE.md file becomes hard to maintain — it accumulates sections on testing, deployment, style guides, architectural decisions, database rules, API contracts, and so on. Anthropic's solution is the @import syntax, which lets a CLAUDE.md file reference other Markdown files so each topic can live in its own focused document.

Syntax and Path Resolution

The @import directive takes a path relative to the file that contains the directive. For example, a root CLAUDE.md might look like:

# Repository Memory

This repository is an Astro 4 monorepo with Cloudflare Pages.

@import ./.claude/rules/typescript.md
@import ./.claude/rules/testing.md
@import ./.claude/rules/api-conventions.md
@import ./.claude/rules/database.md

At session startup, Claude Code reads the root CLAUDE.md, encounters each @import, resolves the path relative to the root directory, loads the target Markdown file, and substitutes its contents inline as if it had always been part of the main file.

Relative Path Rule

The path in @import is always relative to the file containing the directive, not to the current working directory and not to the repository root. If packages/web/CLAUDE.md contains @import ./rules/components.md, the resolver looks for packages/web/rules/components.md, not <repo-root>/rules/components.md.

Why Use @import?

  • Readability — each rule file can be 50–200 lines and focused on one topic, rather than one 2,000-line mega-file.
  • Reviewability — pull requests that touch only the testing rules can modify only testing.md, making diffs easy to read.
  • Reusability — a rule file can be imported from multiple CLAUDE.md entries (for example the project root and a specific package) without duplication.
  • Team ownership — different teams can own different imported files (the platform team owns database.md, the design system team owns components.md).

The @import <path> directive in a CLAUDE.md file loads an external Markdown file and inlines its contents into the effective instruction set at the position of the directive. The path is resolved relative to the file containing the @import statement, not relative to the current working directory.

Typical usage: a small orchestrating CLAUDE.md at the repo root contains only section headers and a list of @import directives pointing at focused rule files inside .claude/rules/.

Source ↗

.claude/rules/ — The Modular Rules Directory Pattern

The .claude/rules/ directory is the idiomatic home for the individual rule files that a root CLAUDE.md imports. It is not a Claude Code built-in feature in the sense of a magic path that is automatically loaded; rather, it is a naming convention that the community and Anthropic's own documentation recommend so that teams can find rule files consistently across repositories.

Typical Layout

<repo-root>/
├── CLAUDE.md                           # orchestrator with @import directives
└── .claude/
    ├── CLAUDE.md                        # (optional alternative project-level file)
    ├── rules/
    │   ├── typescript.md
    │   ├── testing.md
    │   ├── api-conventions.md
    │   ├── database.md
    │   ├── deployment.md
    │   └── security.md
    ├── commands/                        # custom slash commands (see 3.2)
    └── skills/                          # custom skills (see 3.2)

The orchestrator CLAUDE.md keeps the repository's high-level context and delegates specifics to the rule files:

# ExamHub Repository Memory

This is a Cloudflare-first monorepo for a cert-prep platform.
Phase 1 MVP targets 6 certifications in 12 languages.

## Core Rules

@import ./.claude/rules/typescript.md
@import ./.claude/rules/testing.md
@import ./.claude/rules/api-conventions.md
@import ./.claude/rules/database.md
@import ./.claude/rules/deployment.md
@import ./.claude/rules/security.md

## Project-Specific Conventions

- Always respond to the author in 正體中文.
- Never commit files containing `TODO` without a GitHub issue link.

Monolithic vs Modular — The Architect's Choice

A small repository (a single application, one or two engineers) can ship a single 100-line CLAUDE.md without any imports. A large repository (a monorepo with many packages and teams) needs the modular pattern almost immediately, because a monolith becomes unreviewable and unnavigable. The CCA-F exam routinely tests this judgment: when a scenario describes a growing team, overlapping conventions, or cross-team conflicts, the expected answer is to split the monolith into .claude/rules/ files and wire them together with @import.

The .claude/rules/ directory is the conventional location for storing the focused Markdown rule files that a root CLAUDE.md imports via @import. It is a team-organization pattern, not a magic path — Claude Code does not automatically load files in .claude/rules/ unless something in the effective CLAUDE.md chain imports them.

The pattern separates the orchestrator (a small CLAUDE.md with a few paragraphs and a list of imports) from the rules (focused files each covering one concern). Use it when a monolithic CLAUDE.md exceeds roughly 200 lines or when multiple teams need to own different rule surfaces.

Source ↗

The /memory Command — Verifying Loaded Memory Files

Claude Code exposes a slash command, /memory, that prints the list of CLAUDE.md files currently loaded into the session's memory, along with their paths and an indication of which scope each file belongs to. This is the primary diagnostic tool an architect uses when answers or behavior do not match what a repository's CLAUDE.md files suggest they should.

What /memory Shows

Running /memory in an active Claude Code session produces output along the lines of:

Loaded memory files:
  [user]      /Users/jaric/.claude/CLAUDE.md
  [project]   /Users/jaric/work/examhub/CLAUDE.md
  [project]   /Users/jaric/work/examhub/.claude/rules/typescript.md  (imported)
  [project]   /Users/jaric/work/examhub/.claude/rules/testing.md     (imported)
  [directory] /Users/jaric/work/examhub/packages/web/CLAUDE.md

The architect can immediately confirm:

  • Whether the expected user-level file is even loaded (it might be missing or at the wrong path).
  • Whether the project-level file was picked up (it won't be if Claude Code was started outside the repo).
  • Which @import targets were resolved (a missing file will simply not appear in the list).
  • Whether a directory-level file is active for the current working directory.

/memory as the First-Line Diagnostic

When a scenario question describes unexpected Claude behavior — "Claude is not following the testing conventions we documented" — the architect's first move is to run /memory and check whether the testing-rules file actually loaded. Often the fix is not "add more instructions" but "ensure the existing instructions are in scope."

Run /memory as the first step in diagnosing a configuration mismatch. The most common root cause is not a wrongly worded rule but a rule that is not loaded at all — either because the file sits at the wrong path, because an @import directive points at a file that does not exist, or because Claude Code was started from a directory outside the repository root and never picked up the project-level CLAUDE.md.

Source ↗

Plain-Language Explanation: CLAUDE.md Hierarchy

Abstract scoping rules become intuitive when you anchor them to everyday systems you already know. Four very different analogies cover the full sweep of the CLAUDE.md hierarchy.

Analogy 1: The Kitchen — Personal Taste, House Recipe, Station Rule

Picture a large restaurant kitchen where three layers of instructions coexist without conflict.

The personal notebook each chef carries in their apron is the user-level CLAUDE.md. It contains taste preferences ("I always reduce my sauces a little further than the recipe says") and personal habits ("I prefer a chef's knife to a santoku"). Nobody else sees this notebook. It travels with the chef from job to job. When the chef walks into a new restaurant, the personal notebook still governs their instincts.

The house recipe book bolted to the pass is the project-level CLAUDE.md. It defines the restaurant's conventions — "beef is cooked to medium-rare unless the customer requests otherwise," "all plates are wiped with a linen cloth before they leave the pass," "the soup of the day rotates on a weekly schedule." Every cook in the restaurant follows this book. New hires receive a copy on their first day.

The laminated card taped above each station is the directory-level CLAUDE.md. The fish station card says "all fish is patted dry before it touches the pan." The pastry station card says "chocolate tempering is done on marble, never on metal." These cards add station-specific rules on top of the house recipe — they do not replace it. A cook at the fish station still follows the house rule about medium-rare beef if they are ever pulled to the grill.

Mapping it back: the CLAUDE.md hierarchy merges all three layers whenever a cook (Claude Code) starts working at a station (a directory). Personal notebook (user), house book (project), and station card (directory) are all open at the same time.

Analogy 2: Dress Code — Personal Wardrobe, Office Policy, Building Sign

Imagine arriving at an office building for a normal workday.

You decide in your closet at home what you feel like wearing — blue shirt, khakis, brown shoes. This is the user-level layer, invisible to others, applied across every office you ever work at.

Your company's HR policy adds a layer: "business casual between 09:00 and 18:00," "no open-toed shoes on the production floor," "company-branded jacket in client meetings." This applies to everyone employed by the company and is codified in the employee handbook — the project-level CLAUDE.md equivalent.

Finally, a sign at the door of a specific room adds a final layer: "clean room — shoe covers required beyond this point." You still follow HR policy about the branded jacket, you still wear the blue shirt you chose at home, and you additionally put on shoe covers. The clean-room sign does not replace the dress code; it adds one specific rule on top. This is the directory-level CLAUDE.md.

The common CCA-F mistake is to assume the clean-room sign replaces HR policy. It does not. Merges are additive.

Analogy 3: Open-Book Exam — The Reference Materials You Bring

You sit down at an open-book exam with three stacks of material on your desk.

  • Your personal study notes (user-level CLAUDE.md) are with you at every exam you ever take. They reflect your learning style — colored highlighters, margin doodles, mnemonic tables.
  • The textbook assigned for this course (project-level CLAUDE.md) is the canonical reference everyone in the class uses. It defines the shared vocabulary.
  • The supplementary handout for this specific question section (directory-level CLAUDE.md) gives local rules — "use the simplified Euler method, not Runge-Kutta, for this section."

When you answer a question, you draw from all three stacks at once. Each stack is layered on top of the next, with the most specific one (the handout) overriding when there is a direct conflict. This is exactly how the CLAUDE.md hierarchy merges at session start.

Analogy 4: Toolbox — Personal Wrench, Shop Policy, Job-Site Notice

A mechanic's personal toolbox goes everywhere with them — it is the user-level layer. The shop's standard operating procedures hang on the wall of every bay — the project-level layer. The job-site notice pinned to the hood of the customer's car today — "this vehicle's airbag is active; do not disconnect the battery without the bulletin 24-A procedure" — is the directory-level layer.

The mechanic works with all three at once. The CLAUDE.md hierarchy does the same for Claude Code.

What to Put in CLAUDE.md — and What to Keep Out

Getting the hierarchy right also means putting content at the correct scope. Two rules of thumb guide the decision.

Include

  • Persistent context that Claude should know across every session — tech stack, architectural constraints, coding conventions, forbidden patterns.
  • Stable rules that change at the cadence of architectural decisions, not at the cadence of individual tasks.
  • Cross-cutting conventions — security rules, logging requirements, error-handling patterns — that apply to many files the agent will touch.
  • Discovery aids — pointers to key files ("the routing table is in src/router.ts") and key commands ("the test suite runs with pnpm test").

Keep Out

  • Secrets, credentials, API keys, connection stringsCLAUDE.md files are read as prompt context and may be logged; treat them as if they were checked into git (they often are) and never put credentials in them.
  • Per-task instructions — "for this ticket, refactor the checkout flow" belongs in the conversation prompt, not in CLAUDE.md.
  • Volatile data — release notes, dated TODO lists, sprint goals; these age quickly and pollute context.
  • Long-form tutorials — link to external documentation instead; the goal of CLAUDE.md is to be compact.

A frequent Domain 3.1 exam trap is the answer choice "put the new feature's spec into CLAUDE.md so Claude remembers it across sessions." This is wrong on two counts: per-task content belongs in the prompt (or in a slash command), and bloating CLAUDE.md with volatile data accelerates the context-pollution problem the /compact command was designed to mitigate.

If a scenario mentions "short-lived task notes," the correct place is the prompt or a scoped slash command, not CLAUDE.md.

Source ↗

Teammate Onboarding — The Classic Diagnosis Pattern

One of the signature CCA-F exam patterns for Domain 3.1 is the teammate-not-getting-instructions scenario. Read carefully whenever a question introduces a new engineer joining a team and reports that they are "not seeing the expected behavior" from Claude Code.

The Scenario Template

The scenario typically reads something like this:

An architect has configured Claude Code to follow the team's React conventions. The architect's own sessions follow the conventions correctly. A new engineer joins the team, clones the repository, and runs claude. The new engineer reports that Claude is ignoring the conventions. Nothing else has changed in the repository. What is the most likely cause?

The distractor answers usually include:

  • (A) The new engineer needs to upgrade their Claude Code client.
  • (B) The conventions were written in a way Claude cannot parse.
  • (C) The conventions are configured at the user level on the original architect's machine (~/.claude/CLAUDE.md) and are therefore not shared via version control.
  • (D) The new engineer needs to run /memory to reload the rules.

The correct answer is (C). The diagnostic chain is: if the architect's machine shows the right behavior and the new engineer's does not, and nothing else has changed, then the instructions must be in a location that travels with the architect but not with the repository. The only such location is the user-level CLAUDE.md.

The Architect's Remedy

The fix is to move the instructions from user-level to project-level:

  1. Copy (or cut) the relevant sections from ~/.claude/CLAUDE.md.
  2. Paste them into <repo-root>/CLAUDE.md (or a dedicated file under .claude/rules/ imported from the root).
  3. Commit to version control.
  4. Ask the new engineer to git pull and re-open Claude Code.

After the fix, both engineers' /memory output should show the convention file loaded from the project scope.

The teammate-not-receiving-instructions diagnosis is the single most heavily tested Domain 3.1 exam pattern. The correct answer is almost always that instructions are sitting at user level when they should be at project level. User-level files are not version-controlled and therefore do not reach teammates.

Whenever a scenario contrasts "works on my machine" with "does not work on teammate's machine" and the content in question is a behavioral rule or convention, the root cause is a scope mismatch, not a bug in Claude Code.

Source ↗

CLAUDE.md in CI/CD — The Non-Interactive Context

The Claude Code for Continuous Integration scenario cluster on the CCA-F exam routinely combines Domain 3.1 (CLAUDE.md hierarchy) with Domain 3.6 (CI/CD integration). In a CI context, Claude Code runs non-interactively — typically via the -p flag — and reads CLAUDE.md files just as an interactive session would.

What Changes in CI

  • The OS user running the CI job is usually a bot account like github-actions, so the user-level CLAUDE.md at ~/.claude/CLAUDE.md is not the architect's personal file — it is whatever file lives in the CI runner's home directory (most often nothing).
  • The project-level CLAUDE.md is picked up exactly as in local development, because CI runners check out the repository and run Claude Code from inside it.
  • Directory-level files work identically, scoped to the working directory of the CI step.

What Stays the Same

  • Hierarchy precedence and merge rules do not change between interactive and non-interactive sessions.
  • @import resolution works the same way.
  • /memory works the same way, but because CI is non-interactive, you must dump memory state via a script if you need to diagnose a CI run.

Why This Matters for the Exam

A CCA-F question may describe a CI pipeline in which "Claude Code in CI is not following the same conventions as the architect's local sessions." The diagnosis mirrors the teammate-onboarding pattern: the local rules are probably at user level on the architect's machine. Moving them to project level not only fixes the teammate onboarding problem but also fixes the CI mismatch in one change.

Common Exam Traps — Domain 3.1 CLAUDE.md Hierarchy

The CCA-F exam exploits four recurring trap patterns tied to the CLAUDE.md hierarchy. Internalize each one and the corresponding countermeasure.

Trap 1: Directory-Level Replaces Project-Level

The most common trap. Answer choices imply that a directory-level CLAUDE.md replaces the project-level file. It does not. Merges are always additive. A directory-level file supplements higher levels; it cannot silence them.

Trap 2: User-Level Files Are Shared With Teammates

A distractor claims that writing a convention in the user-level CLAUDE.md is sufficient because "everyone on the team uses Claude Code." This is false: user-level files live in each OS user's home directory and are never transmitted via git. Teammates will not see them. Instructions that need to reach teammates belong at project level.

Trap 3: @import Paths Are Absolute or Repo-Rooted

A distractor claims @import resolves paths relative to the repository root. It does not — @import resolves relative to the file containing the directive. If you move a rule file, every @import that points at it must be reviewed.

Trap 4: .claude/rules/ Is Automatically Loaded

A distractor claims that files under .claude/rules/ are automatically loaded by Claude Code. They are not. .claude/rules/ is a convention for where to keep rule files; the files only take effect if something in the effective CLAUDE.md chain imports them via @import. A team that drops rule files into .claude/rules/ without wiring up @import will find that /memory shows the files are not loaded.

The four classic Domain 3.1 trap patterns, restated as reflex rules:

  1. Directory-level supplements, never replaces.
  2. User-level never travels with the repository; always project-level for shared rules.
  3. @import paths resolve relative to the file, not the repo root.
  4. .claude/rules/ is a convention; files there do nothing unless @import'd.

On exam day, if an answer choice violates any of these four rules, eliminate it immediately.

Source ↗

What to Memorize Before Exam Day

The CLAUDE.md hierarchy topic rewards a small set of memorized facts.

CCA-F Domain 3.1 cheat facts for CLAUDE.md hierarchy:

  • 3 levels: user, project, directory.
  • User location: ~/.claude/CLAUDE.md (NOT committed, NOT shared).
  • Project locations: <repo>/CLAUDE.md or <repo>/.claude/CLAUDE.md (committed, shared).
  • Directory location: <subdir>/CLAUDE.md (committed, applies only inside subtree).
  • Merge is additive: directory supplements project supplements user; no replacement.
  • Precedence: more specific wins on conflict — directory > project > user.
  • @import resolution: relative to the file containing the directive.
  • .claude/rules/: convention only; requires @import to take effect.
  • /memory: prints all loaded files; first-line diagnostic tool.
  • Teammate not seeing rules: instructions are at user level; move them to project level.
  • Exam: 60 Q / 120 min / pass 720; Domain 3 is 20% (12 of 60 Q); claude-code-claude-md-hierarchy heat score 0.80.

Source ↗

Practice Anchors — Task 3.1 Scenario Questions

Practice questions tied to CLAUDE.md hierarchy cluster into four recognizable shapes. Each shape maps to a specific diagnostic pattern the CCA-F expects an architect to internalize. Detailed versions with full explanations live in the ExamHub CCA-F question bank.

Shape A — Teammate Onboarding Failure

A new engineer joins a team, clones the repository, runs Claude Code, and reports that conventions are not being followed although the architect who wrote them sees correct behavior. Expected answer: the conventions are in ~/.claude/CLAUDE.md (user-level) and need to be relocated to a project-level file so version control distributes them. This is the Code Generation with Claude Code scenario's canonical trap.

Shape B — Monolithic CLAUDE.md Becoming Unreviewable

A growing team reports that their single 2,500-line CLAUDE.md is painful to review in pull requests, and changes from one team routinely conflict with another team's. Expected answer: refactor into .claude/rules/*.md files, wire up with @import directives from an orchestrator CLAUDE.md, and assign CODEOWNERS per rule file. Distractors involving "make the file shorter by removing rules" are wrong because the rules themselves are correct — the organization is broken.

Shape C — CI Pipeline Not Following Local Conventions

A CI pipeline running Claude Code with the -p flag produces output that ignores conventions the architect applied locally. Expected answer: the conventions live at user level on the architect's machine and are absent on the CI runner; moving them to project level fixes both CI and teammate onboarding in one change.

Shape D — @import Target Not Loading

A developer adds @import ./rules/testing.md at the top of the project-level CLAUDE.md, but /memory does not show the file as loaded, and the testing conventions are ignored. Expected answer: the path is relative to the file containing the directive; either the file does not exist at <repo>/rules/testing.md or the architect meant ./.claude/rules/testing.md. Running /memory confirms which files are loaded and helps pinpoint the broken path.

CCA-F Recognition Depth vs CCP-P Build Depth

The CCA-F is positioned as a foundational, architecture-level certification. It tests whether you can recognize the correct scoping for a rule, diagnose a misplaced file from a scenario description, and decide whether a given situation calls for user, project, or directory level.

The higher-tier Claude Certified Professional and Claude Certified Practitioner programs, when they launch, will test build-level depth — authoring complex .claude/rules/ hierarchies with @import chains, integrating CLAUDE.md merges with custom skills and slash commands, and writing CI validation for memory-file correctness.

For CCA-F, stay at the recognition and judgment layer:

  • Know the three paths exactly.
  • Know that merges are additive.
  • Know the user-vs-project diagnosis pattern by heart.
  • Know what /memory, @import, and .claude/rules/ do and do not do.

If you catch yourself writing custom validation scripts or hand-tracing @import resolution through ten files, you have drifted into implementation depth the CCA-F does not require.

CLAUDE.md Hierarchy Frequently Asked Questions (FAQ)

What is the difference between user-level, project-level, and directory-level CLAUDE.md for the CCA-F exam?

User-level CLAUDE.md lives at ~/.claude/CLAUDE.md, applies to every session run by that operating-system user, and is not shared via version control — it is personal to the machine. Project-level CLAUDE.md lives at the repository root (or inside .claude/), is committed to git, and applies to every session opened inside the repository for every teammate. Directory-level CLAUDE.md lives inside a subdirectory, is committed to git, and applies only when Claude Code is operating inside that subtree. The CCA-F expects reflexive recognition of which level a given rule belongs at.

Why is my new teammate not getting the Claude Code instructions I configured?

Almost certainly because the instructions are in your user-level CLAUDE.md at ~/.claude/CLAUDE.md, which lives on your personal machine and is never transmitted via the git repository. The fix is to move the instructions into the project-level CLAUDE.md at the repository root (or into a file under .claude/rules/ imported from the root), commit the change, and ask the teammate to git pull. This is the most frequently tested Domain 3.1 exam pattern — if a CCA-F scenario contrasts "works on my machine" with "does not work on teammate's machine," the answer is scope mismatch.

Does a directory-level CLAUDE.md replace the project-level CLAUDE.md?

No. Merges across the CLAUDE.md hierarchy are additive, not replacing. A directory-level file supplements the project-level file; both are loaded and merged at session start. If the project-level file says "use Vitest for tests" and a subdirectory file says nothing about tests, the Vitest rule is still in effect inside that subdirectory. This additive-merge semantics is one of the most heavily tested exam traps — answer choices that describe a lower level "replacing" a higher level are wrong.

How does @import resolve paths in CLAUDE.md?

@import <path> resolves the path relative to the file that contains the directive, not relative to the repository root and not relative to the current working directory. If packages/web/CLAUDE.md contains @import ./rules/components.md, Claude Code looks for packages/web/rules/components.md. This rule is easy to misremember — the CCA-F often includes distractors claiming that @import resolves from the repo root. Memorize "relative to the file that imports it."

What is the .claude/rules/ directory and does Claude Code automatically load files in it?

.claude/rules/ is a community-convention home for the focused Markdown rule files that a root CLAUDE.md imports via @import. Claude Code does not automatically load files in .claude/rules/ — they only take effect when something in the effective CLAUDE.md chain imports them. If you drop a file into .claude/rules/ and never add a corresponding @import, the file does nothing. This is a CCA-F trap pattern: distractors that describe .claude/rules/ as "auto-loaded" are wrong.

What does the /memory command do and when should I use it?

/memory is a Claude Code slash command that lists every CLAUDE.md file currently loaded into the session, along with the scope (user, project, or directory) and any files pulled in via @import. Use it as your first-line diagnostic whenever Claude's behavior does not match what your CLAUDE.md files say it should — often the root cause is a file that is not loaded at all (wrong path, missing @import target, or Claude Code started outside the repository) rather than a poorly worded rule. On the CCA-F, any scenario that says "the rules are ignored" should prompt you to think first about whether the rules are even loaded.

What should I put in CLAUDE.md and what should I keep out?

Put persistent context that applies across every session — tech stack declarations, coding conventions, architectural constraints, forbidden patterns, pointers to key files and commands. Keep secrets and credentials out (the file is prompt context and is often committed to git). Keep per-task instructions out — those belong in the conversation prompt or in a custom slash command. Keep volatile data out — release notes, sprint goals, ticket descriptions age too quickly. The CCA-F tests this judgment frequently: if a scenario mentions short-lived task notes, the correct scope is the prompt, not CLAUDE.md.

Further Reading

Related ExamHub topics: Custom Slash Commands and Skills, Path-Specific Rules and Conditional Convention Loading, Plan Mode vs Direct Execution, MCP Server Integration into Claude Code, Built-In Tools Selection and Application.

Official sources