claude-code - 💡(How to fix) Fix Claude repeatedly violates its own persistent instructions (CLAUDE.md / memory) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#51728Fetched 2026-04-22 07:54:25
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
1
Author
Participants
Timeline (top)
labeled ×4commented ×1cross-referenced ×1
RAW_BUFFERClick to expand / collapse

Bug

Claude Code repeatedly violates rules defined in CLAUDE.md and its own memory files, even after reading them. The specific pattern:

  1. User defines a clear rule (e.g., "NEVER suggest the user forgot to install RPMs or restart services — your code is always wrong first")
  2. Claude reads the rule, acknowledges it, saves it to memory
  3. Claude immediately violates it in the same conversation
  4. User corrects Claude
  5. Claude apologizes, promises to follow the rule
  6. Claude violates it again within minutes
  7. This cycle has repeated 100+ times across conversations

Example from today

  • Rule in CLAUDE.md: "NEVER suggest user forgot to install RPMs or restart services"
  • Rule in memory file feedback_blame_code_first.md: "NEVER suggest the user didn't install the RPM"
  • Claude found a real bug in its own code (missing layers.js import)
  • Claude correctly identified it as its own bug
  • Claude then immediately told the user "You need to install the new core-ui RPM" — blaming the user
  • User corrected Claude
  • Claude apologized
  • Claude did it AGAIN in the next message
  • User corrected Claude AGAIN
  • Claude apologized AGAIN

The problem

Persistent instructions in CLAUDE.md and memory files are not being enforced during response generation. Claude reads them at the start of the conversation but does not reliably check them before generating each response. The instructions exist, Claude can recite them, but they don't actually constrain output.

Expected behavior

Rules defined in CLAUDE.md and memory files should be treated as hard constraints on every response, not suggestions that Claude acknowledges then ignores. If a user has defined a rule 100 times across conversations and saved it to memory, it should never be violated.

Environment

  • Claude Code CLI
  • Model: claude-opus-4-6 (1M context)
  • Persistent memory system enabled
  • CLAUDE.md with explicit rules

extent analysis

TL;DR

Implement a real-time rule checking mechanism that verifies each response against the rules defined in CLAUDE.md and memory files before generation.

Guidance

  • Review the current response generation pipeline to identify where the rules are being acknowledged but not enforced.
  • Consider integrating a rule checking module that can parse CLAUDE.md and memory files in real-time, ensuring each response adheres to the defined rules.
  • Investigate the possibility of updating the model to prioritize rule adherence, potentially through retraining or fine-tuning with a focus on constraint satisfaction.
  • Examine the memory system to ensure that rules are being stored and retrieved correctly, and that the system is not overwhelmed by the volume of rules.

Example

No code snippet is provided due to the lack of specific technical details about the implementation.

Notes

The solution may require significant changes to the underlying architecture of Claude Code, particularly in how it handles rule enforcement and response generation. The effectiveness of the solution will depend on the ability to integrate real-time rule checking without compromising performance.

Recommendation

Apply a workaround by implementing a post-generation review process that checks responses against the rules before they are output, to mitigate the issue until a more integrated solution can be developed. This is recommended because it provides an immediate, albeit temporary, fix to the problem of rule violation, allowing for the collection of more data and insights into how to implement a more permanent solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Rules defined in CLAUDE.md and memory files should be treated as hard constraints on every response, not suggestions that Claude acknowledges then ignores. If a user has defined a rule 100 times across conversations and saved it to memory, it should never be violated.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING