Need AI Training/Help?CloudYeti.io/meet
MarkdownMe
Agent instruction guide

Claude Code Is Not Following CLAUDE.md — How to Fix It

Diagnose why Claude Code ignores your CLAUDE.md: the file never loaded, the rule is vague, two files contradict, or the rule needs a hook instead.

Direct answer

When Claude Code ignores your CLAUDE.md, work through four causes in order. First, run /context and check the Memory files list — if your file is not there, it never loaded, and nothing else matters. Second, check whether the rule is specific enough to verify; 'use 2-space indentation' is followed far more reliably than 'format code properly'. Third, look for a contradicting rule in another CLAUDE.md up the directory tree or in .claude/rules/, because Claude picks one arbitrarily when two conflict. Fourth, accept that CLAUDE.md is context, not enforcement — a rule that must run at a fixed point, such as before every commit, belongs in a hook.

Open CLAUDE.md Reviewer

When to use this

  • Claude keeps making a mistake your CLAUDE.md explicitly forbids.
  • A rule worked last month and stopped working as the file grew.
  • You work in a monorepo and other teams' CLAUDE.md files load alongside yours.

Steps

  1. Run /context in the session and confirm your file appears under Memory files.
  2. Paste the CLAUDE.md into the reviewer and read the numbered findings for vague or unverifiable rules.
  3. Rewrite each vague rule as a concrete, checkable instruction with an exact command or path.
  4. Search your other CLAUDE.md files and .claude/rules/ for a rule that contradicts the one being ignored.
  5. If the rule must fire at a fixed moment, move it to a PreToolUse hook, which runs regardless of what Claude decides.

Example review focus

CLAUDE.md excerpt
# CLAUDE.md

- Always test before you finish.
- Be careful with the database.
- Don't commit broken code.
- Follow our conventions.
- Make sure the build passes.
What to fix
Every rule here is unverifiable, so none reliably changes behavior. Rewrite: run `npm run test -- --run` before reporting done; never run migrations against `prod.db`, only `dev.db`; run `npm run build` and report the exit code before any commit. Then move the commit gate into a PreToolUse hook, because a commit rule in CLAUDE.md is a request, not a block.

Common mistakes

  • Do not add the same rule three times hoping repetition helps; contradictions and length both reduce adherence.
  • Do not assume the file loaded — nested and path-scoped files load on demand, not at launch.
  • Do not rely on CLAUDE.md for anything that must never happen; use a hook or permissions.deny.
  • Do not forget /compact — nested CLAUDE.md files and path-scoped rules are not re-injected after compaction.

FAQ

Why is CLAUDE.md not enforced?
CLAUDE.md content is delivered as a user message after the system prompt, not as configuration the client enforces. Claude reads it and tries to follow it, but compliance is not guaranteed, especially for vague or conflicting rules.
How do I check whether my CLAUDE.md loaded?
Run /context and read the list under Memory files. Use /memory to open and edit any of the listed files. If your file is absent, it is in a location that does not load for your working directory.
Does a longer CLAUDE.md get followed less?
Yes. Claude Code documents that files over roughly 200 lines consume more context and may reduce adherence. Important rules compete with filler, so cutting filler makes the remaining rules stronger.
What should I use instead of CLAUDE.md for hard rules?
Use a PreToolUse hook to block an action at a fixed lifecycle point, or permissions.deny in settings to block tools, commands, or paths outright. Settings are enforced by the client; CLAUDE.md shapes behavior.

Related CLAUDE.md guides

Desk gear for long writing sessions

A few things that help if you write docs, tickets, and specs on a laptop all day.

Amazon affiliate links. We earn a commission on qualifying purchases at no extra cost to you.