`@import` in ancestor-directory CLAUDE.md is never expanded — only the cwd-level CLAUDE.md's imports work

Status Open
Maintainer reply None cached
Activity 1 comment · opened Jul 19, 2026

Environment

  • Claude Code v2.1.212, Linux (Ubuntu 24.04 ARM64)
  • Also reproduced with both relative and absolute import paths

Description

Per the docs (https://code.claude.com/docs/en/memory), @path imports are "expanded and loaded into context at launch alongside the CLAUDE.md that references them", and CLAUDE.md files in the directory hierarchy above the working directory are loaded in full at launch.

In practice, imports are only expanded for the CLAUDE.md located at the cwd. For CLAUDE.md files in ancestor directories, the file body is injected as documented, but any @path import lines inside it are silently ignored — regardless of whether the import path is relative or absolute.

Reproduction

mkdir -p /tmp/import-test/sub

cat > /tmp/import-test/imported-rules.md <<'EOF'
# Test rules
- Secret codename: teal-turtle-7742
EOF

cat > /tmp/import-test/CLAUDE.md <<'EOF'
# Test project
@./imported-rules.md
EOF

# (a) cwd = directory containing CLAUDE.md → import IS expanded
cd /tmp/import-test
claude -p "If the injected context contains 'Secret codename', answer its value; otherwise answer exactly 'absent'. Do not read any files."
# → teal-turtle-7742

# (b) cwd = subdirectory (CLAUDE.md is now an ancestor memory file) → import NOT expanded
cd /tmp/import-test/sub
claude -p "If the injected context contains 'Secret codename', answer its value; otherwise answer exactly 'absent'. Do not read any files."
# → absent

Control check for (b): a marker written directly into the ancestor CLAUDE.md body is visible from sub/ — so the ancestor file itself is injected; only its imports are dropped. Replacing the relative import with an absolute path (@/tmp/import-test/imported-rules.md) does not change the result.

Note on probing: asking the model "did you read file X?" produces false negatives (imports are spliced without provenance markers), so the repro asks for a content marker instead.

Expected

Ancestor CLAUDE.md imports expand at launch, same as cwd-level imports — or, if the cwd-only behavior is intended, the memory docs should state it explicitly.

Impact

Workspace/monorepo setups that factor shared org-wide rules into a separate file imported by a workspace-root CLAUDE.md silently lose those rules in every sub-repo session. We had to abandon the import and inline the shared rules into the workspace CLAUDE.md body.

Possibly related

  • #4754 (relative imports resolved from cwd for $CLAUDE_CONFIG_DIR/CLAUDE.md)
  • #1041 (global CLAUDE.md imports not processed)
  • #7768 (multi-hop relative imports)

One additional observation while testing: for the cwd-level CLAUDE.md reached via a symlink, relative import paths resolve against the symlink-resolved real location of the file (matching the documented "relative to the file containing the import").

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗