Domain 3 · Lesson 1 · Claude Code Config (20%)

CLAUDE.md Hierarchy & Path-Specific Rules

Task Statements 3.1 & 3.3 — where config lives, why it's not shared, and glob-scoped rules.

Course progress: Domain 3 ▸ lesson 1 of ~4

The CLAUDE.md hierarchy

LevelLocationShared via VCS?
User~/.claude/CLAUDE.mdNo — personal only
Project.claude/CLAUDE.md or root CLAUDE.mdYes — committed, team-wide
Directorysubdirectory CLAUDE.mdYes, but scoped to that directory
The #1 diagnostic question A new teammate doesn't get the team's instructions. Why? They were placed in user-level ~/.claude/CLAUDE.md (personal, not version-controlled) instead of project-level config. Fix = move them to project scope so they ship with the repo.

Keeping CLAUDE.md modular

Path-specific rules (the glob trick)

.claude/rules/ files can carry YAML frontmatter with a paths: field of glob patterns. The rule loads only when editing matching files — reducing irrelevant context and token usage.

---
paths: ["**/*.test.tsx"]
---
# Testing conventions
Use React Testing Library; one describe block per component; …
When glob rules beat a directory CLAUDE.md When a convention must apply to files spread across many directories (test files sitting next to their components everywhere), a glob-scoped rule (**/*.test.tsx) applies by file type regardless of location. A directory CLAUDE.md is directory-bound and can't follow files scattered across the tree.

Check yourself

A newly onboarded developer isn't receiving the team's coding instructions that everyone else has. The most likely cause is that the instructions live in:
Correct: option 2. User-level config is personal and not version-controlled, so teammates never receive it. The fix is to move the instructions to project scope. The other locations are all shared via the repo.
Test files sit beside the code they test throughout the codebase, and all tests must follow one convention regardless of directory. Most maintainable approach:
Correct: option 1. Glob-scoped rules apply by file type across all directories automatically. Inference (2) is unreliable; per-directory CLAUDE.md (3) can't follow scattered files; manual skills (4) aren't automatic.
Decision rules Team must share it → project scope. Personal only → user scope. Convention spans scattered files → glob rule in .claude/rules/. Behavior inconsistent → /memory to see what loaded. Bloated CLAUDE.md → @import / split into rules.
Ask your teacher. Want load-order/precedence between user, project, and directory CLAUDE.md? Ask.