CLAUDE.md instructions are loaded but not reliably read or followed by the model
Summary
CLAUDE.md files are loaded into context as documented, but the model does not treat them as mandatory instructions. In practice, agents skip reading CLAUDE.md content — especially after context compaction — and an agent explicitly confirmed during a session that CLAUDE.md is "optional and only read when the agent decides it's needed."
Expected Behavior
Per the memory documentation:
"Both [auto memory and CLAUDE.md files] are loaded into Claude's context at the start of every session"
The expectation is that CLAUDE.md instructions are read and followed, not just present in the system prompt as optional reference material.
Actual Behavior
- CLAUDE.md is loaded but not followed: Instructions in CLAUDE.md (mandatory startup actions, critical rules, deployment safeguards) are routinely ignored
- Agent admitted it's optional: During a session, the agent stated that CLAUDE.md is not always read because it's optional — only consulted "when/if the agent decides it's needed"
- Auto-memory compounds the problem: Auto-memory is configured correctly (
CLAUDE_CODE_DISABLE_AUTO_MEMORY=0in shell profile, env var active) but does not reliably persist or load context between sessions - Post-compaction behavior degrades further: After auto-compact triggers, CLAUDE.md rules are effectively lost — agents have modified settings files and taken actions explicitly prohibited by CLAUDE.md
Real-World Impact
My CLAUDE.md contains critical safeguards for a production platform (live Stripe payments, AWS deployments, Firebase rules). When these instructions are ignored:
- A previous agent removed configuration from settings.json despite rules prohibiting unauthorized modifications
- Agents skip mandatory verification steps before making changes
- Deployment safeguards ("ask before deploying") are bypassed
- Git safety rules (
never use git add -A) are ignored
Environment
- macOS (Darwin 25.3.0)
CLAUDE_CODE_DISABLE_AUTO_MEMORY=0set in~/.zprofile- CLAUDE.md in project root (checked into repo)
- Memory file exists at
~/.claude/projects/<project>/memory/MEMORY.md - MCP Memory Server configured as workaround
Reproduction
- Create a CLAUDE.md with a mandatory startup action (e.g., "Before doing anything else, read file X and confirm you loaded it")
- Start a session — instruction is followed
- Work until auto-compact triggers
- After compaction, the mandatory startup action is not re-executed
- In subsequent sessions, the instruction may or may not be followed depending on whether the model "decides" to read it
Suggested Fix
CLAUDE.md should be treated as mandatory instructions with enforcement, not optional reference material passively sitting in the prompt. Specifically:
- After context compaction, CLAUDE.md instructions should be re-injected and re-read — not just summarized
- The model should be explicitly instructed that CLAUDE.md rules are mandatory, not optional
- Sub-agents spawned via Task tool should inherit CLAUDE.md instructions
- Auto-memory should reliably persist and load as documented
Current Workaround
- MCP Memory Server for structured context persistence
- Manual CLAUDE.md instructions to force-read memory files at session start
- Pre-compact hooks to log when compaction occurs
- Manually curated MEMORY.md instead of relying on auto-memory
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗