CLAUDE.md @import not working
An @path import that fails loads nothing and says nothing. The line stays in context as plain text, Claude never sees the file, and you find out weeks later when a rule you thought was loaded turns out never to have been. I put every failing shape I know of into one CLAUDE.md, ran a headless Claude Code 2.1.328 session against it, and asked which files it could see. Here are the eight reasons, with the fix for each.
Quick check. Is there a full stop, colon, comma or bracket touching the end of the path? That's cause 1, and the most common one. If not, run /context all and look under Memory files: an import that expanded is listed there with the file that imported it. Not listed means not loaded.
How imports work
The memory docs set the rules in a few sentences. "CLAUDE.md files can import additional files using @path/to/import syntax. Imported files are expanded and loaded into context alongside the CLAUDE.md that references them." Paths can be relative or absolute, and "relative paths resolve relative to the file containing the import, not the working directory." Imported files can import more files "with a maximum depth of four hops". And "import parsing skips Markdown code spans and fenced code blocks", so a path in backticks is text.
Two things the docs don't spell out but which follow from the parser: the path is everything after @ up to the next whitespace, and the @ has to start a word. Most failures come from those two facts.
1. Punctuation stuck to the path
Write Follow @docs/style.md. and Claude Code looks for a file named style.md., with the full stop. It doesn't exist, so nothing loads. The same happens with a colon (@docs/conventions.md: keep them), a comma, a semicolon and a closing bracket: (see @docs/testing.md) asks for testing.md). These are the first three warnings in the lint output below, and all three files were missing from the headless session.
The reporter of #86060 had a workflow file sit unused for a long time because of a trailing colon. The fix is the same every time: put the import on its own line, or leave a space on both sides of it.
2. A space in the path
The path ends at the first space, so @Design Docs/api.md imports a file called Design, which doesn't exist. The docs cover this: "put a backslash before each space. Without the backslashes, the path ends at the first space, even when the import is on a line of its own. A path wrapped in quotes isn't imported at all, with or without the backslashes." In the test, @Design\ Docs/api.md loaded and the unescaped line didn't. #96192 is the same thing on an iCloud Drive path. Renaming the folder is the fix that survives a reformat; the backslash works until someone's editor strips it.
3. Relative to the file, not to your folder
This one bit me while building the fixture. docs/chain1.md contained @docs/chain2.md, and the linter reported chain2 as missing even though it was right there. It was right: the import is resolved relative to docs/chain1.md, so it points at docs/docs/chain2.md. Inside an imported file, write the path from that file's folder (@chain2.md), not from the project root. The same rule means a shared file imported from two places needs a different relative path in each, or an absolute one.
4. The fifth hop
CLAUDE.md imports chain1, which imports chain2, and so on. Four hops load; the fifth file is dropped without a message. In the test docs/chain4.md was visible and docs/chain5.md wasn't, which matches the documented limit. You'll hit this with a "rules index" file that imports topic files that import detail files. The fix is to flatten: import the far file from the CLAUDE.md itself.
5. Backticks, code blocks and tag blocks
Two of these are by design and one is a bug. By design: a path inside backticks or a fenced code block is skipped, so `@docs/literal.md` is a mention, not an import. That's how you write about a file without loading it.
The bug: an import on the line after an HTML-style tag such as <role>, with no blank line between, is skipped until the next blank line. That's #110857, filed 18 November, and it reproduces on 2.1.328. This fixture has four one-line files, each with its own marker word:
@a.md
@b.md
<role>
@c.md
</role>
@d.md Asked which markers it could see, the session listed three:
$ claude -p "List every MARKER word in your instructions" --setting-sources project
MARKER-A
MARKER-B
MARKER-D c.md never loaded. Imports on consecutive lines (a.md, b.md) both loaded here, so the Windows desktop report in #111064 is a different case I couldn't reproduce on a Mac. If you wrap sections of your CLAUDE.md in tags, put a blank line after the opening tag or move the imports out of the block.
6. An ancestor file, started from a subfolder
Start Claude Code in packages/api and the CLAUDE.md in the repository root loads too; that's documented. What didn't load in my test is that root file's @shared.md import. The body of the ancestor file arrived, its import didn't. Started from the root, both arrived. This is #78697, open since July with comments into November. One commenter says the interactive session asks whether to load the imported file on first launch from the subfolder; my runs were headless, where there's nobody to answer, so I can only vouch for the headless result.
If your root CLAUDE.md is a one-line @AGENTS.md and people open sessions inside packages, assume the shared file is not loaded for them. Either start sessions at the root, or put the text in the root CLAUDE.md itself instead of importing it. CLAUDE.md in a monorepo has the full picture of what loads from which start folder.
7. Outside the project: the approval dialog
An import whose path resolves outside the working folder, like @~/.claude/shared.md, is "external", and the docs are clear about what happens: "The first time Claude Code encounters external imports in a project, it shows an approval dialog listing the files. If you decline, the imports stay disabled and the dialog doesn't appear again." So one wrong keypress turns the import off for that project, for good, with nothing in the file to show it. The dialog is there "to protect you from files other people commit to a shared project". Imports in your own ~/.claude/CLAUDE.md load without it.
Three consequences. Teammates don't have your home-folder file, so an external import in a committed CLAUDE.md is a rule only you get. A headless claude -p run can't answer the dialog. And the VS Code extension has an open report, #99032, of external imports loading in the terminal but not in the panel. The linter's import-outside-root warning is the one on line 11 of the lint output below.
8. A file that never expands imports
One I couldn't test but will pass on: #98010 reports that a user-scope ~/.claude/CLAUDE.local.md loads its own text but never expands the @path lines inside it, with the literal lines reaching the model instead. The docs describe CLAUDE.local.md at the project root, where it "loads alongside CLAUDE.md and is treated the same way"; the user-scope variant isn't documented, so if you rely on it, check with /context all before trusting an import there.
The test, and what loaded
The fixture CLAUDE.md, with a README and a docs/ folder of one-line files beside it:
# Project
See @README.md for the overview.
Follow @docs/style.md.
Conventions: @docs/conventions.md: keep them.
(see @docs/testing.md)
`@docs/literal.md` is just text.
@Design Docs/api.md
@Design\ Docs/api.md
@docs/chain1.md
@~/.claude/shared.md
@docs/missing.md Lint finds the three punctuation cases, the space, the fifth hop, the external path and the missing file, each with the path as Claude Code will read it:
$ npx -y asitis@0.4.8 lint
CLAUDE.md:4:1 warning broken-import "@docs/style.md." is not loaded: Claude Code reads the path as "docs/style.md.", with the "." on the end, and no file has that name. Put a space before the "." or drop it
CLAUDE.md:5:1 warning broken-import "@docs/conventions.md:" is not loaded: Claude Code reads the path as "docs/conventions.md:", with the ":" on the end, and no file has that name. Put a space before the ":" or drop it
CLAUDE.md:6:1 warning broken-import "@docs/testing.md)" is not loaded: Claude Code reads the path as "docs/testing.md)", with the ")" on the end, and no file has that name. Put a space before the ")" or drop it
CLAUDE.md:8:1 note broken-import "@Design" is read as an import but the file does not exist. If this is not a file, wrap it in backticks
CLAUDE.md:10:1 warning broken-import "@docs/chain1.md -> @chain2.md -> @chain3.md -> @chain4.md -> @chain5.md": the last file is 5 hops from this one and Claude Code follows imports only 4 hops deep, so it is not loaded. Import it from a file closer to this one
CLAUDE.md:11:1 warning import-outside-root "@~/.claude/shared.md" imports from your home folder. Claude Code asks for approval of external imports; teammates will not have this file
CLAUDE.md:12:1 warning broken-import "@docs/missing.md" is read as an import but the file does not exist. Fix the path or remove the line
Linted 1 file: 0 errors, 6 warnings, 1 note. The load view shows the same thing as a tree, which is the quickest way to see where a chain stops:
$ npx -y asitis@0.4.8 loads . --tool claude-code
Claude Code: about 92 tokens at launch from 7 files
At launch
1. CLAUDE.md, about 66 tokens, project instructions
2. README.md, about 3 tokens, imported by CLAUDE.md
3. @docs/style.md.: not loaded as written (see lint_steering), not counted
4. @docs/conventions.md:: not loaded as written (see lint_steering), not counted
5. @docs/testing.md): not loaded as written (see lint_steering), not counted
6. Design Docs/api.md, about 5 tokens, imported by CLAUDE.md
7. docs/chain1.md, about 3 tokens, imported by CLAUDE.md
8. docs/chain2.md, about 3 tokens, imported by docs/chain1.md
9. docs/chain3.md, about 3 tokens, imported by docs/chain2.md
10. docs/chain4.md, about 9 tokens, imported by docs/chain3.md
11. @~/.claude/shared.md: outside the allowed folder (home), not counted
12. @docs/missing.md: missing, not counted Then the real thing. I ran claude -p on 2.1.328 with tools disabled and asked for every marker word in its instructions. It listed the markers from Design Docs/api.md (the escaped import) and chain4.md, and nothing from style, conventions, testing, literal, chain5 or the home-folder file. That matches the lint output line for line. One detail from the run: Claude Code refuses to load a CLAUDE.md that sits in a session scratchpad folder, and the debug log says so ([CLAUDE.md] not loading ...: it, or what it links to, is in a session's scratchpad), so don't test inside a folder laid out like claude/<project>/<session id>/scratchpad.
Confirm what loaded
/context all. The debug guide says to run it first "to confirm whether your CLAUDE.md, rules, or skill descriptions are present at all". Expanded imports appear under Memory files with the importing file.- An
InstructionsLoadedhook. The memory docs suggest it "to log which CLAUDE.md and rules files are loaded, when they load, and why". The smallest version appends each event to a file:{ "hooks": { "InstructionsLoaded": [ { "hooks": [ { "type": "command", "command": "cat >> ~/.claude/loaded.log" } ] } ] } } claude --debug. The session log in~/.claude/debug/names files it refused to load and why.- Ask. Put a distinctive word in the imported file and ask Claude to quote it. If it can't, the text never arrived, and rewording the rule won't help.
- Lint before the session.
npx -y asitis@0.4.8 lintreads every import the way Claude Code does, follows chains four hops and reports the ones that load nothing. It only sees files inside the folder you point it at, so check~/.claude/CLAUDE.mdby hand.
Check your file
Paste a CLAUDE.md into the steering file checker and every @import is listed with the path Claude Code will actually look for. The plugin's /asitis:md-loads prints the import tree for a folder, four hops deep, with the files that are dropped and why.
Open the steering file checker
To check every steering file in a project from inside Claude Code, including links, @imports and what loads every session, install the free AsItIs plugin. It is read-only and makes no network calls.
claude plugin marketplace add Katta041/asitis-agent-tools
claude plugin install asitis@asitis About the pluginSource on GitHub
MIT licensed. A star on GitHub helps other people find it.
Questions
How do I check which imports Claude Code expanded?
Run /context all in the session and read the list under Memory files; an import that expanded is listed with the file that imported it. If a file you expect is missing there, it did not load. For a log you can grep, add an InstructionsLoaded hook. Outside a session, asitis loads prints the import tree for a folder and marks each import that is read differently from how it was written.
Does splitting CLAUDE.md into imports save tokens?
No. The docs say imports "help you organize a long file but don't reduce its context cost, because imported files load together with the CLAUDE.md that imports them". Every imported file counts toward the length warning as a separate file. To cut what loads every session, move part-of-the-codebase instructions into a path-scoped rule under .claude/rules/, which loads only when Claude works on a matching file.
Can I import AGENTS.md from CLAUDE.md?
Yes. A CLAUDE.md whose first line is @AGENTS.md loads the shared file first and the Claude-specific text after it, and the docs recommend exactly that when a project has both files. Keep the import on its own line with nothing after it. If Claude Code is already reading AGENTS.md directly, the import is skipped rather than loaded twice.
How many levels deep can imports go?
Four hops. The docs say imported files "can recursively import other files, with a maximum depth of four hops". In my test a chain of four loaded and the fifth file did not, with no message. If a chain is that deep, import the far file from the CLAUDE.md itself.
Do Codex or Gemini CLI read the same @imports?
Gemini CLI has its own @file.md import syntax in GEMINI.md, with a default depth of five. The Codex AGENTS.md docs describe no import syntax at all: Codex reads the chain of AGENTS.md files from the repository root down, and anything you link is read only if the agent decides to open it. Keep anything Codex must see in the AGENTS.md text itself.
See what an agent changed in your CLAUDE.md. Keep or revert each change.
The linter is free and needs no signup. I'm also building a desktop editor for the markdown your agents write and read. It shows what an agent changed since you last looked, lets you keep or revert each change, and never touches a line you didn't edit. No release date yet. One email to confirm, one when the paid beta opens, one when 1.0 ships. $29 once for a founding licence, with 24 months of updates.
Or add the linter to CI, no email needed.
Your address is stored with Cloudflare, which hosts this site. No IP address is kept. See the privacy policy.
Related: Claude Code ignores my CLAUDE.md, .claude/rules not loading, CLAUDE.md in a monorepo, AGENTS.md vs CLAUDE.md.
Sources, read on 23 November 2026: Claude Code docs, Import additional files, How CLAUDE.md files load and Troubleshoot memory issues in How Claude remembers your project, and Debug your configuration; GitHub issues #110857, #111064, #99032, #98010, #86060, #96192 and #78697 on anthropics/claude-code. Quotes are exact. Test runs: Claude Code 2.1.328 in headless mode with tools disabled, on macOS, 23 November 2026; command output from asitis 0.4.8 on the same fixture, trimmed for width.