Claude Code ignoring your CLAUDE.md usually comes down to one of four things: the file never loaded, it's too long, it contradicts another instruction, or you wrote a hard rule as prose. Writing IMPORTANT in capitals fixes none of them. Anthropic's own docs say so.
The fix order that works: confirm the file is in context, cut it down, run the audit, then move anything that must never be broken out of CLAUDE.md and into a deny rule or a hook. Everything below is from the Claude Code memory docs and best practices as they read in late November 2026.
CLAUDE.md: system prompt or user message?
User message. The docs are direct about it: "CLAUDE.md content is delivered as a user message after the system prompt, not as part of the system prompt itself. Claude reads it and tries to follow it, but there's no guarantee of strict compliance."
That one sentence explains most "CLAUDE.md not followed" complaints. Your file isn't configuration. The docs' phrase is "context, not enforced configuration". The model reads it, weighs it against everything else in the conversation, and decides.
If you really need text at the system prompt level, there's a flag for it: --append-system-prompt. You pass it at launch, so the docs describe it as better suited to scripts and automation than to interactive use. For day-to-day work it's the wrong tool. The steps below are the right ones.
Step 1: check that Claude Code loaded your CLAUDE.md at all
Run /context all in a session and read the list under Memory files. If your file isn't there, Claude can't see it, and no amount of rewording will help.
Three ways a file that exists ends up missing:
- It's in a subdirectory. A
CLAUDE.mdbelow your working directory loads on demand, when Claude reads or edits a file in that folder. It never shows under Memory files at launch. - One of your own permission rules blocks it. A
Readdeny rule that covers the path stops the instruction file from loading. You get anInstruction file not loadednotice naming the reason. - You're expecting
AGENTS.mdto load and aCLAUDE.mdis in the way, or the reverse. That one has its own post: why your AGENTS.md isn't loading.
There's a smaller trap in the same area. Block-level HTML comments in CLAUDE.md are stripped before the content reaches Claude. That's useful for maintainer notes. It also means a rule you wrapped in <!-- --> while experimenting is gone from the context.
Step 2: CLAUDE.md not followed? Check the length first
The docs give a number: target under 200 lines per CLAUDE.md file. Their reason is blunt: "Longer files consume more context and reduce adherence."
Best practices puts it another way. CLAUDE.md loads into every session, so every line "takes a little of Claude's attention on every task, whether it's relevant or not". Your 40 lines about the release process are in the room while Claude fixes a typo.
Things the docs say about length that people get wrong:
- Splitting the file with
@pathimports doesn't help. Imported files load together with theCLAUDE.mdthat imports them, so the context cost is the same. Imports tidy the file. They don't shrink it. - Claude Code already warns you. If an instruction file is over the recommended length you see a warning at startup and in
/status. There's a second warning when files that are each fine add up past a combined limit. - A file over 4 MiB isn't truncated. It's skipped completely.
- On-demand files do get truncated. From v2.1.309, a subdirectory
CLAUDE.mdor path-scoped rule over a per-file limit (40,000 characters on a 200K context window) arrives as its first part plus a note telling Claude to read the rest. Until Claude chooses to, the later instructions aren't in context. Check withwc -m path/to/CLAUDE.md.
What should stay in the file? The docs' test: only what Claude couldn't work out from the code. Test and lint commands. Places where the code is misleading. Decisions that aren't in the repo. Anything you've corrected twice. Directory layouts and architecture overviews are the first things to cut, because Claude can read the repo. We go deeper on layout in how to structure CLAUDE.md for large projects.
Step 3: run /doctor prompt-audit
Claude Code has a built-in audit for exactly this. Run it in a session:
/doctor prompt-auditAccording to the docs it looks for instructions written for older models, references to files or commands that don't exist, and files that contradict each other. You get a report with proposed edits. Nothing in your files changes until you ask Claude to apply them.
By default the audit covers CLAUDE.md, CLAUDE.local.md and AGENTS.md, plus the rules, skills, commands, subagents and output styles under .claude/ and ~/.claude/. To audit one path, pass it: /doctor prompt-audit .claude/skills/deploy.
Two requirements. It needs Claude Code v2.1.283 or later, which the changelog dates to 25 September 2026. And it runs through the bundled /claude-api skill, so it's unavailable if bundled skills are turned off.
Plain /doctor is worth running too. For a checked-in CLAUDE.md it proposes trims: it cuts what Claude can derive from the codebase and keeps pitfalls, rationale and conventions that differ from tool defaults.
"Instructions written for older models" is the part to notice. The changelog describes the command as an audit for "prompting patterns written for older models". If your file has been collecting corrections since last year, some of them were aimed at a model you no longer run.
Step 4: look for instructions that fight each other
When two instructions contradict, the docs say Claude "may pick one arbitrarily". Not the newer one. Not the more specific one. Either.
The conflicts hide in three places.
Between your files. ~/.claude/CLAUDE.md, the project file, nested files and .claude/rules/ all load into the same context. The docs note that user rules load before project rules, and then add that neither set overrides the other. Load order isn't precedence.
Between your file and Claude Code itself. Claude Code adds its own guidance for commits and pull requests. If your CLAUDE.md sets commit rules and they keep getting ignored, the docs point at two settings: turn off the built-in guidance with includeGitInstructions, and set the attribution text with attribution. You may have been arguing with a default.
Between the file and the conversation. Instructions given only in chat can be lost at /compact. The project-root CLAUDE.md does: Claude Code re-reads it from disk and re-injects it. If a rule vanished halfway through a long session, it was probably never in the file.
Step 5: move part-of-the-codebase rules into .claude/rules/
A rule that only matters for API handlers shouldn't be read during a CSS fix. Path-scoped rules in .claude/rules/ load only when Claude works with matching files:
---
paths:
- "src/api/**/*.ts"
---
# API rules
- All endpoints validate input
- Use the standard error response formatSave that as .claude/rules/api.md. One warning from the docs: paths is the only frontmatter field Claude Code reads, and if the YAML doesn't parse, the rule loads as if it had no paths at all. A typo turns your narrow rule into one that loads every session. claude --debug shows the parse error.
When a rule must always hold: deny rules and hooks, not CLAUDE.md
This is the step that actually ends the "Claude Code ignoring CLAUDE.md" loop for hard rules.
Best practices splits every instruction into two kinds. Non-deterministic: you write it, the model reads it and decides. Deterministic: you configure it, and Claude Code enforces it "no matter what the model decided to do". CLAUDE.md is the first kind. Hooks, deny rules and managed settings are the second.
The docs' advice, quoted: "If something has to happen every time, make it a hook, a deny rule, or a managed setting. CLAUDE.md is for guidelines, and Claude is allowed to decide a guideline doesn't apply."
And on the capital letters: "If Claude keeps ignoring a line that is in CLAUDE.md, adding IMPORTANT probably won't fix it."
So Never read .env and Never push stop being sentences and become this, in .claude/settings.json:
{
"permissions": {
"deny": [
"Read(./.env)",
"Bash(git push *)"
]
}
}Don't oversell the Bash one. The permissions docs say a Bash rule matches the command text Claude writes and "isn't a security boundary around the program". Bash(git push *) stops git push origin main. It doesn't stop git -C . push origin main. For rules that depend on more than the command text, the docs send you to sandboxing or a PreToolUse hook.
Hooks are for steps and for checks with logic. A PreToolUse hook that exits with code 2 blocks the tool call, and the hooks guide has a ready script for protected files. A hook that returns a deny blocks the tool even in bypassPermissions mode.
The docs also warn against overdoing it. A hook is for a rule with zero exceptions. Prefer named exports has plenty, so it stays in CLAUDE.md.
The short version
/context all: is the file loaded?- Under 200 lines, and imports don't count as cutting.
/doctor prompt-audit: stale and contradicting instructions.includeGitInstructionsif your commit rules lose to the built-in ones..claude/rules/withpathsfor anything local to one part of the repo.- Deny rules and hooks for anything that can't have exceptions.
Is CLAUDE.md a system prompt or a user message? A user message, and that's fine. Use it for guidance, and give enforcement to the harness. If you're starting a new file, generate a short one for your stack and delete from there. If the same file has to serve other tools, the AGENTS.md compatibility matrix covers which of them read what.