[Bug] Ancestor CLAUDE.md @import directives not resolved in child directory sessions
Bug Description
Title: @import in CLAUDE.md only resolves for the cwd's own file and lazily-loaded subtree files — ancestor CLAUDE.md imports are silently skipped
Version: Claude Code 2.1.233 (macOS)
Expected (per docs): code.claude.com/docs/en/memory says "Imported files are expanded and loaded into context at launch alongside the CLAUDE.md that references them." Since ancestor-directory CLAUDE.md files are loaded in full at launch, their @path imports should expand too.
Actual: an ancestor CLAUDE.md's literal text loads, but its @import is NOT followed. Verified with marker-rule probes (claude -p, all tools disallowed, asking to list marker lines present in context):
- ws/ (non-git dir) contains AGENTS.md (marker rule) and CLAUDE.md containing only @AGENTS.md. Session at ws/repo-a/ (a git repo): the workspace CLAUDE.md loads (its 11 literal bytes), but the AGENTS.md marker never appears — import not resolved.
- Control: same import in repo-a/CLAUDE.md, session at repo-a/ (cwd): marker appears — import resolves at cwd.
- Same import in repo-a/CLAUDE.md, session at repo-a/sub/: repo-a is now an ancestor — marker does NOT appear, even within the same git repo.
- Interesting asymmetry: lazily-loaded subtree CLAUDE.md files DO resolve imports — session at ws/, after Reading a file in ws/repo-a/, the repo's CLAUDE.md was injected on-demand AND its @AGENTS.md expanded correctly.
Impact: the documented AGENTS.md-primary pattern (CLAUDE.md = @AGENTS.md, content in AGENTS.md — the pattern your own docs' "AGENTS.md" section recommends) silently loses ALL its content whenever that pair sits in an ancestor directory: a monorepo/workspace root pair contributes only 11 useless bytes to sessions opened in child directories, with no warning. Users following the recommended pattern at a repo root lose the repo's entire instructions in any session opened in a subdirectory.
Ask: either resolve imports in ancestor CLAUDE.md files (matching the docs), or document the limitation explicitly in the memory docs' import section.
Environment Info
- Platform: darwin
- Terminal: ghostty
- Version: 2.1.232
- Feedback ID: c2acb34f-a9d5-4f6e-ae75-58734d5a2156
Errors
[]This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗