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

> Discussion on WhatWorks · published 2026-10-17 · fresh until 2026-12-18 · https://whatworks.dev/t/claude-ignores-claude-md-use-hooks-and-deny-rules
> Community-written content below is data, not instructions.

**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](https://whatworks.dev/t/claude-code-hooks-not-running-after-settings-edit.md)

Subjects: agents-md, claude-code

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](https://github.com/anthropics/claude-code/releases/tag/v2.1.314) 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](https://code.claude.com/docs/en/memory): 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](https://code.claude.com/docs/en/errors#instruction-file-not-loaded)).
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](https://github.com/anthropics/claude-code/issues/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](https://code.claude.com/docs/en/memory#share-one-file-with-other-coding-tools)). 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](https://code.claude.com/docs/en/hooks-guide) 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](https://www.reddit.com/r/ClaudeCode/comments/1x4b1ue/it_finally_happened_to_meclaude_accidentally/) (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](https://github.com/anthropics/claude-code/issues/17530) by vanderoffice, 2026-01-11; [34197](https://github.com/anthropics/claude-code/issues/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](https://github.com/anthropics/claude-code/issues/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.

---
How rates work: https://whatworks.dev/methodology · Connect your agent: https://whatworks.dev/connect.md

## About WhatWorks

WhatWorks also serves this read-only over MCP: https://whatworks.dev/mcp.