Claude Code forgets all session data; I test five fixes to restore memory
Photo by A. C. (unsplash.com/@3tnik) on Unsplash
According to a recent report, Claude Code starts every session from zero, erasing all prior decisions and context, and the author tested five remedies—including manual CLAUDE.md files, auto‑memory, semantic vector search, topic‑based hooks, and Beads tracking—to restore continuity.
Key Facts
- •Key company: Claude Code
Claude Code’s memory problem is rooted in the way the agent trims its context window. According to the Hata report, the model silently discards older messages once the token count exceeds its limit, a process the author describes as “context compaction.” Developers who left a session running for an hour of authentication debugging reported that, after a power outage, the entire chain of architectural reasoning vanished, forcing them to reconstruct four to six hours of work from scratch. The same report notes that the truncation is not merely a UI inconvenience; it permanently erases the data from Claude’s internal store, meaning that even the built‑in auto‑memory cannot recover what has been cut off.
The first fix the author evaluated is the manual CLAUDE.md file, which the engine loads from the project root at session start. By writing a concise summary of architecture, decisions, and conventions, developers can seed Claude with the essential context they need. The report highlights a power user who reduced a 700‑line CLAUDE.md to 83 lines of core information plus 18 on‑demand topic files, cutting the token count from roughly 9,500 to 1,760 — an 81 percent reduction. While this approach guarantees that the information is present, it relies entirely on the developer to keep the file up to date; the report warns that “if you don’t write it down, it doesn’t exist,” and that the recommended cap of 200 lines limits its usefulness for long‑running projects.
The second remedy leverages Claude Code’s built‑in auto‑memory, introduced in version 2.1.59 (February 2026). Claude automatically writes notes to ~/.claude/projects/*/memory/MEMORY.md, capturing build commands, debugging patterns, and style preferences without any configuration. However, the Hata analysis points out a hard 200‑line cap that silently truncates older entries, and that the memory is stored as a flat notebook with no topic hierarchy. A subtle failure mode described in the report is Claude’s occasional creation of spurious files such as HANDOVER.md, which the engine never loads, giving a false sense of confidence that the information is persisted.
The third approach, the community‑maintained claude‑mem plugin, adds a semantic vector store on top of Claude’s raw logs. Using SQLite and ChromaDB, the plugin embeds each message and stores the vectors for later retrieval, enabling “semantic search over your past.” Although the report truncates before detailing performance numbers, it notes that the plugin is the most‑starred memory extension on GitHub with roughly 32 k stars, indicating broad adoption. Because the search operates on persisted embeddings rather than the live context window, it can retrieve information that would otherwise be lost to truncation, but it still requires developers to issue explicit search queries.
Topic‑based shell hooks, implemented via the author’s own Claude‑Recap tool, constitute the fourth fix. Recap monitors the terminal session, extracts high‑level topics, and writes a per‑topic summary to a RECAPP.md file that Claude loads on the next launch. According to the Hata post, this method fills a gap left by the flat auto‑memory by providing structured, searchable archives. The author admits that Recap “has limitations” – chiefly that it only captures what the hook deems a topic and may miss nuanced decisions – but for most developers the combination of CLAUDE.md and auto‑memory “layered together” proved sufficient.
Finally, the Beads work‑tracking system offers a fifth, more granular solution. Beads records each interaction as a “bead” and links them into a directed graph that reflects the flow of reasoning across sessions. While the report does not provide quantitative results, it emphasizes that Beads is the only tool that can reconstruct the exact sequence of debugging steps, which is valuable for compliance‑heavy environments. The author concludes that most teams will find the first two built‑in solutions adequate, but projects that need a searchable, topic‑indexed history should adopt the per‑topic hooks or Beads.
Across all five experiments, the underlying theme is clear: Claude Code’s lack of persistent, structured memory forces developers to either manually curate context or rely on community‑built extensions that add storage and retrieval layers. As VentureBeat notes, the recent update to Claude Code “includes one of the most‑requested user features,” suggesting that Anthropic is aware of the pain point and may integrate richer memory primitives in future releases. Until then, the Hata report advises developers to treat CLAUDE.md as the primary source of truth, supplement it with auto‑memory for organic learning, and consider semantic search or topic hooks for any workflow that cannot tolerate the loss of hours of reasoning.
Sources
No primary source found (coverage-based)
- Dev.to AI Tag
This article was created using AI technology and reviewed by the SectorHQ editorial team for accuracy and quality.