[FEATURE] Provide way to exclude parent CLAUDE.md files from auto-loading in subdirectories
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When working in a subdirectory of a large monorepo, Claude Code recursively loads all parent CLAUDE.md files into context with no way to opt out. This causes large irrelevant documentation to consume context tokens unnecessarily, thereby degrading performance and usefulness of Claude Code.
Per the memory documentation:
Claude Code reads memories recursively: starting in the cwd, Claude Code recurses up to (but not including) the root directory / and reads any CLAUDE.md or CLAUDE.local.md files it finds.
This behavior is problematic for monorepos with multiple teams/tech stacks where parent-level documentation is irrelevant to subdirectory work.
Example Scenario
monorepo/
├── CLAUDE.md (40k+ chars - Go microservices docs)
├── services/
│ ├── ui-app/ # Frontend app
│ │ ├── CLAUDE.md # Frontend-specific docs
│ │ └── packages/
│ │ └── app/ # <- Working directory
│ │ └── CLAUDE.md
Currently loaded: All 3 CLAUDE.md files, including backend Go service documentation that's irrelevant to the working directory.
Desired: Only load the 2 UI-related CLAUDE.md files, excluding the one in root directory.
Proposed Solution
The ideal solution is some sort of setting or configuration knob to customize CLAUDE.md loading, that can be checked in to main repo (something akin to a .gitignore).
Alternative Solutions
Tried denying permission to read from CLAUDE.md in .claude/settings.json - this doesn't work as this controls tool uses by Claude Code but not auto-loading CLAUDE.md into the context window.
Priority
High - Significant impact on productivity
Feature Category
Configuration and settings
Use Case Example
_No response_
Additional Context
Related issues:
- #3232 - Context duplication in worktrees (closed as not planned)
- #15332 - Conditionally skip
~/.claude/CLAUDE.mdbased on working directory (closed as duplicate of #3232)
This issue has 9 comments on GitHub. Read the full discussion on GitHub ↗