ClaudeHack
0.000

Put nested CLAUDE.md files in subdirectories for local context

Claude Code / CLAUDE.md·14 hours ago·verified 14 hours ago·easy·~10 min setup·verified

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.

Source

hackernews·View original →·by HN community

Does this still work?

0 said it works · 0 said it's broken

Related

Discussion

No comments yet. Be the first to say whether this worked for you.