[BUG] Claude Code forgets persistent memory instructions after context compaction
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code supports a persistent memory file (MEMORY.md) where users can store preferences and workflow rules. These rules are followed correctly at the start
of a conversation, but after a context compaction event occurs, Claude appears to lose adherence to those instructions — even though the memory file is still
loaded.
In my case, I have a rule requiring a specific sequence of steps before editing files on a remote server (backup → pull → edit → push). Claude followed this
correctly before compaction, but after the conversation was compacted and summarized, it started skipping those steps and editing files incorrectly.
The likely cause is that the compaction summary does not adequately preserve the context of persistent memory instructions, causing Claude to revert to default
behavior rather than re-reading the memory file.
What Should Happen?
Expected behavior: Claude should re-read and re-apply MEMORY.md instructions after every compaction, treating it as a hard constraint regardless of
conversation state.
Suggested fix: After compaction, explicitly re-load and re-enforce persistent memory file contents before continuing the conversation.
Error Messages/Logs
Steps to Reproduce
- Create a MEMORY.md file with a strict workflow rule (e.g. "always do X before Y")
- Start a conversation — verify Claude follows the rule correctly
- Continue the conversation until context compaction occurs (look for the "This session is being continued from a previous conversation that ran out of
context" banner)
- After compaction, ask Claude to perform a task that requires the rule from MEMORY.md
- Observe that Claude proceeds without following the rule, despite MEMORY.md still being loaded
Note: The rule does not need to be complex. In my case it was a 5-step file editing sequence. Claude followed it correctly before compaction, skipped it
entirely after.
Claude Model
Not sure / Multiple models
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.70
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗