[BUG] nested_traversal re-injects same CLAUDE.md into context on every file access in that directory
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When Claude Code reads a file in a subdirectory that has its own CLAUDE.md, the nested_traversal mechanism re-injects the same CLAUDE.md into the context window every time — even if it was already loaded earlier in the session. There is no deduplication.
This wastes context window capacity with redundant instruction content.
Evidence
I captured OTEL telemetry (api_request events with token counts) alongside InstructionsLoaded hook events for a single session. The data clearly shows context jumps each time the same CLAUDE.md is re-loaded.
Session: f3736323-1a26-460f-9dc9-845ee0c4c9b6
InstructionsLoaded events (same file loaded 3 times):
| Time | memory_type | load_reason | file_path |
|------|-------------|-------------|-----------|
| 03:52:12 | Project | nested_traversal | .../apps/web/CLAUDE.md |
| 04:03:57 | Project | nested_traversal | .../apps/web/CLAUDE.md |
| 04:04:14 | Project | nested_traversal | .../apps/web/CLAUDE.md |
Token counts from api_request OTEL events:
Time total_context_tokens
03:52:10 26,973 ← before first load of apps/web/CLAUDE.md
03:52:17 45,593 ← after first load (+18,620 tokens)
The same ~18k-token CLAUDE.md was injected into context 3 times during this session.
Expected Behavior
Once a CLAUDE.md file has been loaded via nested_traversal in a session, subsequent accesses to files in the same directory should not re-inject the same instruction content into context. Claude Code should deduplicate already-loaded instruction files.
Actual Behavior
Every file read that triggers nested_traversal re-injects the full content of the directory's CLAUDE.md, even if it was already loaded earlier in the same session. This causes unnecessary context window consumption.
Reproduction Steps
- Create a project with a large
CLAUDE.mdin a subdirectory (e.g.,apps/web/CLAUDE.md) - Enable OTEL telemetry to capture
api_requesttoken counts - Configure
InstructionsLoadedhook to log events - Start a session and ask Claude to read multiple files under
apps/web/ - Observe that
InstructionsLoadedfires forapps/web/CLAUDE.mdon each file access - Observe that
total_context_tokensjumps by the same amount each time
Impact
- Wastes context window budget (the scarcest resource in long sessions)
- Larger CLAUDE.md files amplify the waste
- Monorepos with many subdirectory CLAUDE.md files are especially affected
Environment
- Claude Code version: 2.1.72
- OS: macOS Darwin 25.2.0
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗