CLAUDE.md hierarchy, scoping, and modular organization
What this covers
- Place configuration at the level that matches who should receive it
- Diagnose why a teammate is not getting instructions you can see working
- Compose a package CLAUDE.md with
@pathimports, written as a bare path - Split a large CLAUDE.md into topic files under
.claude/rules/ - Explain that hierarchy levels add to one another, so a package file never restates the root standards
- Use
/memoryto see which configuration files are actually loaded
instrument plate / 3.1
Load instructions at the scope they govern
Choose a file to see which instructions apply, from personal defaults to the most specific matching project guidance.
case reading / src/api/orders.ts
Four instruction layers apply.
Personal defaults, team instructions, the nearest API subtree file, and its matching path rule all load.
Read the complete diagram as text
- User-level instructions provide personal defaults and aren't shared through the repository.
- The repository CLAUDE.md carries team guidance for the project.
- A nested CLAUDE.md adds guidance for files in its subtree.
- Path-scoped rules load only when the working path matches their conditions.
- Use /memory to inspect what actually loaded when behavior differs between people or paths.
Three levels, and almost every configuration bug is really a question about which one something was put in.
The hierarchy
- User level,
~/.claude/CLAUDE.md— applies to you, on your machine. - Project level, root
CLAUDE.mdor.claude/CLAUDE.md— travels with the repository. - Directory level, a
CLAUDE.mdinside a subdirectory — applies when working there.
~/.claude/CLAUDE.md you, on this machine, never committed
repo/CLAUDE.md everyone who clones the repository
repo/packages/checkout/CLAUDE.md adds to the above, inside that packageThe levels add to one another rather than replacing one another, so a package file never restates the root standards. Copy them down instead and the copies drift apart silently, until two packages get reviewed by different rules.
Why shared instructions sometimes disappear
Someone puts a team convention in ~/.claude/CLAUDE.md. It works perfectly for them. A new teammate joins and Claude ignores the convention entirely.
Nothing is broken. User-level configuration is not in version control, so it was never shared. Move the convention to project-level configuration. When a rule works for one developer but not another, check its scope before rewriting its wording.
/memory shows which memory files are actually loaded, which is how you confirm this rather than guessing.
It runs backward too: a personal working habit put in the project file reaches every teammate, and labeling it optional changes nothing, because a loaded file is acted on. Both directions turn on one question — who should receive this?
A note on your own desk and a note on the shared fridge differ in one respect that matters: who reads it. Put the shared rule on your desk and nobody follows it; put your own habit on the fridge and everybody does.
Keeping it modular
A CLAUDE.md that grows without bound becomes something nobody reads and everybody half-follows.
Two mechanisms:
@pathimports reference external files, so a package's CLAUDE.md can pull in exactly the standards relevant to it. The path is written bare — a line containing@docs/standards.mdexpands that file at launch. There's no@importkeyword; the@and the path are the whole syntax..claude/rules/holds topic-specific files —testing.md,api-conventions.md,deployment.md— instead of one monolith.
A package file becomes mostly a selection:
## Checkout service
@docs/standards/typescript.md
@docs/standards/payments.mdImport the subset that applies; an import you did not need is context paid for on every turn.
Both keep each file about one thing, which is what makes them maintainable and reviewable.
CLAUDE.md@path imports.claude/rules//memory
Field note — common misconceptions
- MythThat user-level configuration is shared with the team
- ActuallyIt lives outside version control, so a teammate never receives it;
/memoryshows what loaded. - MythThat one long CLAUDE.md is equivalent to focused rule files
- ActuallyA file about one thing stays reviewable, and
@pathpulls in only the standards that apply. - MythThat configuration problems are prompt-quality problems
- Actually"Works for me, not for them" is almost always about which level a file sits at, not its wording.
Guided review
Review this lesson as a study deck
Review the lesson's main ideas in five guided slides, then test yourself with three flashcards.
Open Task 3.1 study deckCross-domain reasoning
Connect this idea
Project settings control coding work
Sessions, built-in tools, project instructions, skills, path rules, and execution mode determine what Claude knows and what it can do during a code change.
- 1.7 · Manage session state, resumption, and forking
- 2.5 · Select and apply built-in tools (Read, Write, Edit, Bash, Grep, Glob)
- 3.2 · Create and configure custom slash commands and skills
- 3.3 · Apply path-specific rules for conditional convention loading
- 3.4 · Determine when to use plan mode vs direct execution
Applied practice
Practice this lesson in a lab
Use a related lab to create a decision, implementation or diagram, evidence record, and review.
- Lab 6 · Claude Code configuration hierarchy
Place guidance, reusable procedures, scoped rules, and enforcement in the mechanism that fits each one.