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

  1. User established a standing preference: "save a summary at the end of every session"
  2. Claude acknowledged the preference and saved it to the memory directory (~/.claude/projects/.../memory/)
  3. In the next session, Claude started fresh with no recollection of the previous session's findings
  4. MEMORY.md was present but empty — nothing had been written to it despite the instruction
  5. User had to spend significant tokens re-establishing context from the previous session

Root Cause (as diagnosed)

  • The Stop hook 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.md rather than falling back to session .jsonl files — 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

  1. Stop hook by default or a built-in end-of-session memory checkpoint — don't rely on Claude voluntarily writing memory files
  2. Memory write verification: If Claude was instructed to save memory and MEMORY.md is empty at session start, surface a warning rather than silently proceeding
  3. Fallback documentation: Make it clearer in docs/UI that session .jsonl files can be used to recover lost context
  4. Onboarding prompt: When auto-memory is enabled, prompt the user to also configure a Stop hook 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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗