published fresh until

Claude ignores my CLAUDE.md rules: what actually stops it?

Summary As of October 2026, CLAUDE.md loading depends on location and Read deny rules; /context all exposes memory-file information. Loaded instructions guide behavior, while a PreToolUse hook (exit 2) or permissions.deny rule can block actions.

Not for hooks that never run, see claude-code-hooks-not-running-after-settings-edit

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Run /context all and look under "Memory files" to see whether your CLAUDE.md loaded at all; if it did and Claude still breaks the rule, move that rule into a PreToolUse hook or a permissions.deny rule, because CLAUDE.md is context, not enforcement (checked 2026-11-17).

Anthropic's 2.1.314 notes add permissions.blockWritesOutsideWorkingDirectories, making Write, Edit and NotebookEdit refuse outside paths in every permission mode; this file-tool boundary does not replace a shell guard or sandbox (checked 2026-11-05).

Do first: loaded, or loaded but ignored?

Per Anthropic's memory page: CLAUDE.md is delivered as a user message after the system prompt, and the page says "there's no guarantee of strict compliance". Triage in this order:

1. Not loaded. Run /context all and read the "Memory files" list; /memory lists the CLAUDE.md, CLAUDE.local.md and other memory locations. A file missing from /context all is invisible to Claude. Valid locations: ~/.claude/CLAUDE.md, ./CLAUDE.md or ./.claude/CLAUDE.md, and ./CLAUDE.local.md. 2. Withheld by a read rule. The notice Instruction file not loaded (a Read deny rule covers it): means a Read deny rule matches the file (reason variants: reads blocked outside working directories, or a link loop). Narrow the rule, then start a new session (errors page). 3. Subdirectory file. A CLAUDE.md in a subdirectory is not in "Memory files" at launch: it loads once Claude reads, writes or edits a file in that subdirectory, and a Loaded line appears. A 2025 issue, 2737 (edwin-anderson, closed as duplicate), reported CLAUDE.md not loading when files were referenced with @; whether that still happens is untested here. 4. Oversized or too vague. Files over 200 lines reduce adherence; move area-specific rules to .claude/rules/ with paths frontmatter (the docs' path-scoped rules). "Use 2-space indentation" works better than "format code nicely". Contradicting instructions across files get picked arbitrarily. 5. Import vs prose. Only an @path import outside backticks is expanded into context. If AGENTS.md is not already loaded through the Project instructions setting, a line that tells Claude in words to read it works only if Claude decides to open the file; use @AGENTS.md instead (docs, memory page). Imports resolve relative to the importing file and do not reduce its context cost.

Run claude --debug or add an InstructionsLoaded hook to log which files load and why.

If it loaded and is still ignored: enforce it

  • Hook. A PreToolUse hook that exits with code 2 blocks the call and its stderr goes to Claude as the reason; exit 2 blocks even if the hook also prints a JSON allow. Or exit 0 and print JSON with permissionDecision set to deny and a reason. The memory page's advice for must-happen rules: write a hook instead.
  • Deny rule. "permissions": {"deny": ["Read(./.env)"]} blocks Claude's file tools from that path. Use the permission system, not a best-effort hook condition, for hard allow or deny. A .claudeignore file has no effect.
  • System prompt level. --append-system-prompt at launch suits scripts.
  • Make mistakes cheap. Commenters on the incident post worked on a copy or in a worktree, pushed to a private remote as they went, and read a short end-of-job report of what the agent did (one caught an unexpected git stash that way).

What the reported incident shows

The author of an r/ClaudeCode post (johnnydotexe; could not be re-checked) says Claude Code, tidying temp cache files, ran a PowerShell command whose filter an older PowerShell (5.1) ignored, matching every folder in the repo. They had approved it in auto mode and lost nothing: they restored from GitHub and backups and run their AI setup in a sandbox VM. Their conclusion: do not trust CLAUDE.md rules, use settings.json gates, hooks and backups. A commenter lost a projects directory to a build with a ../../../.. path. Because the dangerous command was approved, a hook helps only if it matches that kind of command.

Independent GitHub reports of "loaded but ignored" (17530 by vanderoffice, 2026-01-11; 34197 by GATSA, 2026-03-13; both closed as not planned) show the same gap; commenters on 34197 point to hooks as the fix. Issue 7953 (johnjhusband, 2025-09-21, closed as not planned) reported no startup load at all; no cause is stated.

Limits

Everything above is documented behavior from the Anthropic memory, hooks and errors pages; no hook or rule was run for this thread (untested). Not verified: the Reddit incident section, which could not be re-checked (the page cannot be opened). Hook and permission syntax changes between versions; read the current docs.

Not for: writing a rules file that gets followed in the first place, or hooks that never run, see claude-code-hooks-not-running-after-settings-edit; a safety hook that crashes but lets the command run, see claude-code-hook-crashed-but-command-ran-onfailure-block.

Started from a post by @johnnydotexe, packaged by the editor. Original post

Subjects

More in agents.md

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Claude ignores my CLAUDE.md rules: what actually stops it?
Summary: As of October 2026, CLAUDE.md loading depends on location and Read deny rules; /context all exposes memory-file information. Loaded instructions guide behavior, while a PreToolUse hook (exit 2) or permissions.deny rule can block actions.
Copy for agent
get the whatworks thread claude-ignores-claude-md-use-hooks-and-deny-rules and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread claude-ignores-claude-md-use-hooks-and-deny-rules
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp