User / Project / Directory Levels
Where each CLAUDE.md lives and who it applies to.
User / Project / Directory Levels is a free Claude Architect lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Claude Architect learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Three Places a CLAUDE.md Can Live
Claude Code reads memory from three levels, and each one answers a different question: who does this rule apply to?
- User level —
~/.claude/CLAUDE.md: your personal preferences, on your machine only. - Project level —
./CLAUDE.mdor.claude/CLAUDE.md: shared with the whole team via version control. - Directory level — a
CLAUDE.mdinside a subfolder: scoped to that subtree only.
Knowing which file a rule belongs in is a core Claude Certified Architect skill. Put it in the wrong place and either your teammates miss it, or your personal habits leak into everyone's workflow.
User Level — Personal, NOT Shared
The user-level file at ~/.claude/CLAUDE.md lives in your home directory. It applies to every project you open on this machine, but it travels with you, not the repo.
Critically, it is NOT shared via version control. A new teammate cloning the repo will never see it. So it is the right home for personal taste: your preferred commit-message style, how chatty you like responses, or shell aliases you favor.
It is the wrong home for anything the team must agree on — coding standards, build commands, security rules.
# ~/.claude/CLAUDE.md (personal, machine-local, never committed)
## My preferences
- Keep explanations short; show the command, not a paragraph.
- Prefer `rg` over `grep` and `fd` over `find` on my machine.
- Use Conventional Commits for messages.Project Level — Shared via VCS
The project-level file lives at the repo root as ./CLAUDE.md (or .claude/CLAUDE.md). Because it sits inside the repository, it is committed and shared via version control.
That is exactly what you want for rules the whole team relies on: the build command, test framework, architectural conventions, directory layout, and anything a new contributor needs on day one.
Rule of thumb: if a fresh clone would break without it, it belongs in the project-level CLAUDE.md — not in your personal user file.
# ./CLAUDE.md (repo root — committed, shared by everyone)
## Build & Test
- Build: yarn build
- Test: yarn test --runInBand
- Lint must pass before every commit.
## Conventions
- NestJS modules under src/<feature>/.
- All DB access goes through the repository layer, never inline SQL.Directory Level — Scoped to a Subtree
A CLAUDE.md placed inside a subfolder is directory-scoped: it applies only when Claude is working within that subtree. This keeps narrow, local rules close to the code they govern.
Example: a frontend/CLAUDE.md can hold React/Tailwind conventions that make no sense for the backend, while services/payments/CLAUDE.md can carry rules that only matter for billing code.
Directory-level files are still committed (they live in the repo), so they are shared — but their reach is the folder, not the whole project.
# frontend/CLAUDE.md (scoped to the frontend subtree)
## UI conventions (apply only under frontend/)
- Components are function components with hooks; no class components.
- Style with Tailwind utility classes; avoid inline style objects.
- Co-locate tests as Component.test.tsx next to the component.How the Levels Combine
The levels are additive context, not mutually exclusive. When you work in a subfolder, Claude can draw on the user file, the project file, and the directory file together.
Think of it as concentric scopes:
- User — broadest reach (every project), narrowest audience (just you).
- Project — whole repo, whole team.
- Directory — one subtree, whole team.
So the question is never only "how specific is this rule?" but also "who needs to see it — me, or everyone?" Audience decides user vs project; scope decides project vs directory.
The Classic Mistake: Team Rules in the User File
The most common anti-pattern: putting a rule everyone depends on into ~/.claude/CLAUDE.md. It works perfectly for you — so the gap is invisible — but because the user file is never shared via VCS, new teammates miss it entirely.
Symptoms: Claude follows the convention on your machine and ignores it on a colleague's, and nobody can figure out why. The fix is always the same: move shared rules down into the project-level (or directory-level) CLAUDE.md so they ship with the repo.
Modularize with @path Imports
A CLAUDE.md does not have to be one giant file. You can pull in other files with @path imports, which keeps each file focused and readable.
For example, a project file can import a shared standards document instead of inlining hundreds of lines. This makes the hierarchy easier to maintain and lets you reuse the same standards across files.
# ./CLAUDE.md (project root)
## Engineering standards
@./standards/coding-style.md
@./standards/security.md
## Build
- Build: yarn buildPath-Scoped Rules with .claude/rules/
A monolithic CLAUDE.md loads into context for every task — even when most of it is irrelevant — wasting tokens. A cleaner pattern for narrow rules is .claude/rules/ files with YAML frontmatter.
Each rule file declares a paths pattern, and it loads only when you are editing matching files. This gives you directory-level precision while saving context, because rules that don't match the current file are never pulled in.
# .claude/rules/migrations.md
---
paths:
- "db/migrations/**"
---
- Every migration must be reversible (provide a down step).
- Never edit a migration that has already shipped; add a new one.Editing Memory: /memory and /init
You don't have to hand-edit these files in an external editor. Inside Claude Code, the /memory command opens and edits the CLAUDE.md memory, and changes persist across sessions.
For a brand-new repository, /init bootstraps a project-level CLAUDE.md by documenting the codebase, giving you a sensible starting point you can then refine.
Choosing which file /memory writes to still comes back to the same decision: personal (user) versus shared (project or directory).
# In an interactive Claude Code session:
/init # generate a project-level CLAUDE.md from the codebase
/memory # open and edit CLAUDE.md; edits persist across sessionsSkills and Commands Follow the Same Split
This user-versus-project split is not unique to CLAUDE.md — it is a consistent Claude Code pattern. Skills and commands use the exact same two scopes:
- Project scope —
.claude/skills/and.claude/commands/in the repo are shared via VCS. - User scope —
~/.claude/skills/is personal.
Note that .claude/commands/ is the legacy form and .claude/skills/ is the current one, but the scoping rule is identical: repo = team, home = you. Learn the split once and it applies everywhere.
Keep Secrets Out of Committed Files
Because project-level and directory-level files are committed to version control, treat them like public code: never put secrets in them. The same discipline applies to a project-scoped .mcp.json (shared in VCS) versus the personal ~/.claude.json.
For tokens and keys, reference environment variables — for example ${GITHUB_TOKEN} — instead of pasting the raw value. The shared file says which variable to use; the actual secret stays in the environment, out of the repo and out of CLAUDE.md.
// .mcp.json (committed — references env vars, never raw secrets)
{
"mcpServers": {
"github": {
"command": "github-mcp",
"env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
}
}
}Quick Check: Where Does the Rule Go?
Your team agrees on a build command and a test framework that every contributor must use. A new engineer just cloned the repo. Where should this rule live so that Claude Code applies it for the whole team from day one?
Recap: Audience and Scope Decide the Level
Pick the level by answering two questions — who and where:
- User (
~/.claude/CLAUDE.md): personal, every project, NOT shared via VCS — new teammates miss it. Use for personal preferences only. - Project (
./CLAUDE.md): shared via VCS, whole team, whole repo. The home for build commands and conventions everyone needs. - Directory (subfolder
CLAUDE.md): shared via VCS but scoped to one subtree.
Keep files lean with @path imports and load narrow rules on demand via .claude/rules/ with paths frontmatter. Never commit secrets — reference env vars like ${GITHUB_TOKEN}. The biggest trap to avoid: putting team rules in your personal user file, where everyone else will silently never see them.
Frequently asked questions
Is the “User / Project / Directory Levels” lesson free?
Yes — the full text of “User / Project / Directory Levels” is free to read here on the web, and the Claude Architect course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Claude Architect course, upgrade to CoddyKit PRO.
What will I learn in “User / Project / Directory Levels”?
Where each CLAUDE.md lives and who it applies to. You practise Claude Architect with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Claude Architect?
No prior experience is required. Claude Architect on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “User / Project / Directory Levels” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Claude Architect lesson?
Yes. Every Claude Architect lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- User / Project / Directory Levels
- The @path Import Syntax
- .claude/rules/ with Frontmatter Paths
- Monolith vs Modular Rules