Auto-memory not persisted across sessions despite standing instruction — causes significant token waste
Resolved 💬 2 comments Opened Jun 3, 2026 by svpk Closed Jul 8, 2026
Summary
Claude Code's auto-memory system failed to persist session summaries across sessions, even after the user explicitly instructed it to do so as a standing preference. This caused substantial token waste when context had to be rebuilt from scratch in subsequent sessions.
Behavior Observed
- User established a standing preference: "save a summary at the end of every session"
- Claude acknowledged the preference and saved it to the memory directory (
~/.claude/projects/.../memory/) - In the next session, Claude started fresh with no recollection of the previous session's findings
MEMORY.mdwas present but empty — nothing had been written to it despite the instruction- User had to spend significant tokens re-establishing context from the previous session
Root Cause (as diagnosed)
- The
Stophook was not configured, so there was no automated trigger to remind Claude to write memory at end of session - Claude relied on self-discipline to write memory files, which is not reliable across session boundaries
- When memory appeared missing, Claude defaulted to checking only
MEMORY.mdrather than falling back to session.jsonlfiles — making recovery harder than it needed to be
Impact
- Token waste: An entire session's worth of investigation findings had to be reconstructed, costing the user significant tokens
- Lost productivity: Multi-session investigations are broken if memory isn't reliably persisted
Suggested Improvements
Stophook by default or a built-in end-of-session memory checkpoint — don't rely on Claude voluntarily writing memory files- Memory write verification: If Claude was instructed to save memory and
MEMORY.mdis empty at session start, surface a warning rather than silently proceeding - Fallback documentation: Make it clearer in docs/UI that session
.jsonlfiles can be used to recover lost context - Onboarding prompt: When auto-memory is enabled, prompt the user to also configure a
Stophook to enforce saving
Workaround Applied
Added a Stop hook to ~/.claude/settings.json that injects a system message reminding Claude to write memory before finishing:
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "echo '{\"systemMessage\": \"MEMORY REMINDER: Before finishing, check if this session had any unsaved findings or progress. If so, write or update the relevant file in the memory directory.\"}'"
}
]
}
]
This should not be necessary for the feature to work reliably — it should be the default behavior when auto-memory is enabled.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗