1. Writing a Good CLAUDE.md
A well-structured CLAUDE.md is the single most impactful way to improve Claude Code’s output for your project. Humanlayer has an excellent guide covering what to include, how to structure it, and common pitfalls.Writing a good Claude.md
Comprehensive guide by Humanlayer on creating effective CLAUDE.md files
2. CLAUDE.md in Large Monorepos
When working with Claude Code in a monorepo, understanding how CLAUDE.md files are loaded into context is crucial for organizing your project instructions effectively.
The Two Loading Mechanisms
Claude Code uses two distinct mechanisms for loading CLAUDE.md files:Ancestor Loading (UP the directory tree)
Ancestor Loading (UP the directory tree)
When you start Claude Code, it walks upward from your current working directory toward the filesystem root and loads every CLAUDE.md it finds along the way. These files are loaded immediately at startup.
Descendant Loading (DOWN the directory tree)
Descendant Loading (DOWN the directory tree)
CLAUDE.md files in subdirectories below your current working directory are NOT loaded at launch. They are only included when Claude reads files in those subdirectories during your session. This is known as lazy loading.
Example Monorepo Structure
Consider a typical monorepo with separate directories for different components:Scenario 1: Running Claude Code from the Root Directory
When you run Claude Code from/mymonorepo/:
| File | Loaded at Launch? | Reason |
|---|---|---|
/mymonorepo/CLAUDE.md | ✅ Yes | It’s your current working directory |
/mymonorepo/frontend/CLAUDE.md | ❌ No | Loaded only when you read/edit files in frontend/ |
/mymonorepo/backend/CLAUDE.md | ❌ No | Loaded only when you read/edit files in backend/ |
/mymonorepo/api/CLAUDE.md | ❌ No | Loaded only when you read/edit files in api/ |
Scenario 2: Running Claude Code from a Component Directory
When you run Claude Code from/mymonorepo/frontend/:
| File | Loaded at Launch? | Reason |
|---|---|---|
/mymonorepo/CLAUDE.md | ✅ Yes | It’s an ancestor directory |
/mymonorepo/frontend/CLAUDE.md | ✅ Yes | It’s your current working directory |
/mymonorepo/backend/CLAUDE.md | ❌ No | Different branch of the directory tree |
/mymonorepo/api/CLAUDE.md | ❌ No | Different branch of the directory tree |
Key Takeaways
Ancestors Always Load
Claude walks UP the directory tree and loads all CLAUDE.md files it finds. This ensures you always have access to root-level, repository-wide instructions.
Descendants Load Lazily
Subdirectory CLAUDE.md files only load when you interact with files in those subdirectories. This prevents irrelevant context from bloating your session.
Siblings Never Load
If you’re working in
frontend/, you won’t get backend/CLAUDE.md or api/CLAUDE.md loaded into context.Global CLAUDE.md
You can also place a CLAUDE.md at
~/.claude/CLAUDE.md in your home folder, which applies to ALL Claude Code sessions regardless of project.Why This Design Works for Monorepos
Shared instructions propagate down
Root-level CLAUDE.md contains repository-wide conventions, coding standards, and common patterns that apply everywhere.
Component-specific instructions stay isolated
Frontend developers don’t need backend-specific instructions cluttering their context, and vice versa.
Best Practices
Put shared conventions in root CLAUDE.md
Put shared conventions in root CLAUDE.md
Put component-specific instructions in component CLAUDE.md
Put component-specific instructions in component CLAUDE.md
Framework-specific patterns, component architecture, testing conventions unique to that component.
Use CLAUDE.local.md for personal preferences
Use CLAUDE.local.md for personal preferences
Add it to
.gitignore for instructions that shouldn’t be shared with the team.Sources
Memory Documentation
Official Claude Code memory documentation
Boris Cherny on X
Clarification on CLAUDE.md loading behavior
Writing a good Claude.md
Humanlayer’s comprehensive guide
