Put nested CLAUDE.md files in subdirectories for local context
Keep the root CLAUDE.md short and drop domain-specific CLAUDE.md files under paths like src/db/ so Claude loads them only when it works in that area.
The problem
One giant root CLAUDE.md tries to document every subsystem, gets ignored mid-session, and wastes tokens on rules that do not apply to the current files.
The hack
Keep global rules in root CLAUDE.md under ~200 lines. Add `src/payments/CLAUDE.md` (and similar) with module-specific invariants — Claude loads nested files when it touches that directory.
Why it works
Widely confirmed by HN power users and Anthropic’s memory model: nested CLAUDE.md is automatic, path-local context. Pair with path-scoped `.claude/rules/` when you want frontmatter-controlled loading.
Setup
1. Trim root CLAUDE.md to team-wide rules only. 2. Create `src/<area>/CLAUDE.md` with that area’s invariants, commands, and pitfalls. 3. Ask Claude to edit a file in that area and run `/memory` or `/context` to confirm local memory loaded. 4. Avoid duplicating the same prose in root and nested files.
Discussion
No comments yet. Be the first to say whether this worked for you.