CLAUDE.md Configuration Hierarchy
CoreConfigure CLAUDE.md files with appropriate hierarchy, scoping, and modular organization · Difficulty 2/5
Explanation
Claude Code reads project instructions from multiple configuration sources with a specific precedence order.
Configuration Sources
- Project CLAUDE.md: Root-level
CLAUDE.mdor.claude/CLAUDE.md-- loaded for every conversation - Directory CLAUDE.md: Subdirectory
CLAUDE.mdfiles -- additive context when working in those directories - User-level:
~/.claude/CLAUDE.md-- personal instructions, lowest priority, not version-controlled - Rules directory:
.claude/rules/files with optional glob patterns -- topic-specific, conditionally loaded
Key Rules
- Project scope beats user scope: Same-named project skills/configs override user ones
- No caching across sessions: CLAUDE.md is read fresh each session
- New team members: If a guideline only exists in user-level files, new team members won't get it
Common Mistake
Team puts guidelines in each developer's ~/.claude/CLAUDE.md instead of the project's .claude/CLAUDE.md. New developers who join don't receive those guidelines. Solution: move shared guidelines to project scope.
The /memory Command
Use /memory to verify which memory files are loaded and diagnose inconsistent behavior across sessions. This helps identify when instructions are missing or incorrectly scoped.
Key Takeaways
- Project CLAUDE.md is loaded for every conversation; user-level has lowest priority
- Shared team guidelines must be in project scope, not user scope
- CLAUDE.md is read fresh each session, no cross-session caching
- Use /memory to verify which configuration files are loaded
Related Concepts
Test Yourself
1 / 3Your CLAUDE.md has over 400 lines. You want Claude to always follow coding standards and testing conventions, but only apply PR review, deployment, and migration guidance when performing those tasks. What's the most effective restructuring?