[BUG] @imports in a parent-directory CLAUDE.md are silently ignored
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.md is discovered in a parent directory of the cwd, its content is loaded but any @import lines inside it are not resolved. The imported file's content never reaches the context, and nothing reports an error.
The same CLAUDE.md resolves its imports correctly when the cwd is that directory. Import resolution appears to be tied to the cwd rather than to the file being processed.
This fails silently. The config file is present, correct, and discovered — and the imported half of the context is simply absent. There is no error, no warning, and the file still appears as loaded.
What Should Happen?
CLAUDE.md is documented as being discovered from parent directories, and @path imports are a documented CLAUDE.md feature. A parent-directory CLAUDE.md should contribute the same content regardless of how deep the cwd sits, including anything it imports.
Error Messages/Logs
No error is produced. That is the bug — the import is dropped silently.
Steps to Reproduce
Three files, no git repo required:
- Create the tree:
mkdir -p /tmp/repro/nested/deeper
printf 'The secret fruit is DAMSON-FROM-IMPORT.\n' > /tmp/repro/IMPORTED.md
printf '@IMPORTED.md\n' > /tmp/repro/CLAUDE.md
- Ask the same question from three different working directories:
Q='Answer from context only, no tools, one line. What is the secret fruit? If you have no such note, reply exactly: NOT LOADED'
cd /tmp/repro && echo "$Q" | claude -p # -> DAMSON-FROM-IMPORT
cd /tmp/repro/nested && echo "$Q" | claude -p # -> NOT LOADED
cd /tmp/repro/nested/deeper && echo "$Q" | claude -p # -> NOT LOADED
- Now replace the import with the identical content inline, and repeat from the nested directory:
printf 'The secret fruit is DAMSON-INLINE.\n' > /tmp/repro/CLAUDE.md
cd /tmp/repro/nested/deeper && echo "$Q" | claude -p # -> DAMSON-INLINE
Step 3 is the control that isolates the fault: the parent file is found and read from a nested cwd. Only the @import inside it is skipped.
| Parent CLAUDE.md contains | cwd = /tmp/repro | cwd = /tmp/repro/nested | cwd = /tmp/repro/nested/deeper |
|---|---|---|---|
| The content inline | loads | loads | loads |
| @IMPORTED.md (relative) | loads | NOT LOADED | NOT LOADED |
| @/tmp/repro/IMPORTED.md (absolute) | loads | NOT LOADED | NOT LOADED |
Absolute paths fail identically, so this is not relative-path resolution against the wrong base directory — the import is not processed at all.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.211 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Non-interactive/CI environment
Additional Information
Why this matters. Two common patterns break, both silently.
A workspace or monorepo root that carries shared context. A CLAUDE.md at the root of a tree of repos loads for every session started below it, but anything it imports never does — that file is never the cwd, so its imports never resolve. There is no arrangement of paths that fixes this; the content has to be inlined.
The CLAUDE.md → AGENTS.md projection. Teams standardising on AGENTS.md as the tool-agnostic source of truth reduce CLAUDE.md to a single @AGENTS.md line. That works when the session starts at the repo root, and silently drops the entire file the moment someone starts one in src/ or docs/. The repo looks correctly configured either way. The only symptom is an agent that has quietly forgotten its project conventions — which reads as the model being unhelpful rather than as a config fault.
Suggested fix. Resolve @import lines relative to the file that contains them, for every CLAUDE.md in the discovery chain rather than only the one in the cwd.
Failing that, a warning when an import in a discovered CLAUDE.md is skipped would turn a silent context loss into something diagnosable. At present neither /context nor --debug indicates that an import was dropped; the file is reported as loaded.