Two Loading Mechanisms
1. Ancestor Loading (UP the tree)
When you start Claude Code, it walks UP from your current directory to the root, loading everyCLAUDE.md it finds.
Key Insight
Running from
packages/api/: loads root, packages, and api CLAUDE.md files.Running from packages/web/: loads root, packages, and web CLAUDE.md files.Siblings never load each other.2. Descendant Loading (DOWN, lazy)
When Claude reads or edits a file in a subdirectory, it lazy-loads that directory’s CLAUDE.md.This happens automatically. You don’t control it.
What This Means for Monorepos
Good Structure
Root CLAUDE.md (< 60 lines ideal, < 150 max)
Keep it lean. This loads every session regardless of where you work.Package CLAUDE.md
Detailed, package-specific context. Only loads when working in that package.CLAUDE.local.md
For personal preferences. Gitignored.Skills Loading (Different from CLAUDE.md)
Skills do NOT follow ancestor/descendant loading. They have fixed discovery locations:
Skills from nested
.claude/skills/ directories ARE discovered automatically when Claude accesses files in those directories.
Key difference: skill descriptions are always in context (for the
/ menu), but full skill content is only loaded on invocation. This keeps context lean.Character Budget
If you have many skills, they share a character budget for descriptions. SetSLASH_COMMAND_TOOL_CHAR_BUDGET env var to increase the limit if needed.
Agent Memory (Persistent per Agent)
Agents withmemory: user get their own MEMORY.md:
- First 200 lines injected at agent startup
- Agent auto-curates: creates topic files, links from MEMORY.md
- Three scopes:
user(global),project(per-project),local(per-directory)
Memory Systems Comparison
| System | Scope | Managed By | When Loaded |
|---|---|---|---|
| CLAUDE.md | Project | You | Every session (ancestors), lazy (descendants) |
| CLAUDE.local.md | Personal | You | Every session (gitignored) |
| Auto Memory | User | Claude | Session start (first 200 lines) |
| Agent Memory | Per-agent | Agent | Agent invocation |
/memory command | User | You | On demand |
| Pro-Workflow DB | User | Hooks | Session start (via SessionStart hook) |