Claude-Mem: Persistent Memory for Claude Code Across Sessions
github7 min readFebruary 5, 2026

Claude-Mem: Persistent Memory for Claude Code Across Sessions

Claude-Mem is a plugin for Claude Code that provides persistent memory across sessions by capturing, compressing, and intelligently injecting relevant context. Created by thedotmack, it solves the 'amnesia problem' where AI agents forget previous work when starting new sessions.

Yuval Avidani

Yuval Avidani

Author

Key Takeaway

Claude-Mem is a plugin for Claude Code that gives AI agents persistent memory across sessions without overloading the context window. Created by thedotmack, it automatically captures what the agent does, compresses it intelligently, and injects only relevant context when needed - solving the 'amnesia problem' we all face in long-running projects.

What is Claude-Mem?

Claude-Mem is a sophisticated memory layer for Claude Code that maintains continuity across coding sessions. The project claude-mem solves the problem of AI agents starting fresh every session, losing all context from previous work - a challenge we all face when building complex projects with AI assistance over multiple days or weeks.

In technical terms, it's a plugin that captures observations (tool usage, file changes, decisions), compresses them using AI summarization, and employs a 'progressive disclosure' strategy to inject relevant historical context without burning through our token budget.

The Problem We All Know

Here's a scenario that happens to us constantly: We're three days into building a feature with Claude Code. The agent helped us refactor our authentication system on Monday. Tuesday, we switched branches to fix a critical bug. Wednesday morning, we return to finish the auth work - and Claude acts like it's seeing our codebase for the first time. All that context about our architectural decisions, the patterns we established, the edge cases we discussed - gone.

The root cause isn't Claude's intelligence. It's the fundamental constraint of context windows. Every session starts with a blank slate. Sure, we can manually paste in previous conversations or code snippets, but that approach doesn't scale. We either burn thousands of tokens on history (expensive and slow), or we lose continuity (frustrating and inefficient).

Existing tools try different approaches - some use heavyweight vector databases that require infrastructure setup, others rely on simple keyword search that misses nuanced context. We needed something that balances memory with efficiency, something that 'just works' without requiring us to become database administrators.

How Claude-Mem Works

Claude-Mem takes a layered approach to agent memory - think of it like how our own memory works, with different levels of detail.

At its core, the plugin runs alongside Claude Code and observes everything the agent does. When Claude uses a tool, modifies a file, or makes a decision, Claude-Mem captures that as an 'observation'. But here's where it gets clever: Instead of storing raw transcripts (which would quickly become massive), it uses AI to compress these observations into dense, searchable summaries.

The compression happens in layers. Recent work stays detailed. Older work gets progressively more summarized. This mirrors how we naturally remember things - we recall yesterday's meeting in detail, but last month's meeting as a high-level summary.

When we start a new session, Claude-Mem employs what it calls 'progressive disclosure'. First, it injects a high-level context overview - essentially telling Claude, "Yesterday you refactored the auth system, last week you built the payment integration." If Claude needs more details about something specific, it can request deeper history, and Claude-Mem retrieves the relevant compressed observations.

Quick Start

Here's how we get started with Claude-Mem:

# Install the plugin
git clone https://github.com/thedotmack/claude-mem.git
cd claude-mem
pip install -e .

# Configure for your Claude Code setup
cp config.example.json config.json
# Edit config.json with your preferences

# Start using it - it runs automatically alongside Claude Code
code .
# Claude-Mem is now capturing and compressing your session

A Real Example

Let's say we're building a web app and we worked with Claude on Monday to set up our database models. Tuesday we're starting fresh on the API layer. Here's what happens behind the scenes:

# What Claude-Mem captured from Monday (simplified)
{
  "session_id": "2026-02-03",
  "observations": [
    {
      "type": "file_change",
      "file": "models/user.py",
      "summary": "Created User model with email validation"
    },
    {
      "type": "decision",
      "context": "Chose SQLAlchemy over Django ORM for flexibility"
    }
  ],
  "compressed_summary": "Built database models with SQLAlchemy..."
}

# What gets injected Tuesday morning
# High-level first:
"Previous session: You set up database models using SQLAlchemy. 
User model includes email validation."

# Detailed context only if Claude asks:
if claude.asks_about("database decisions"):
    inject_detailed_history("Chose SQLAlchemy because...")

Key Features

  • Automatic Observation Capture - Every tool usage, file change, and decision gets logged without us having to do anything. It's like having a silent note-taker in every session.
  • AI-Powered Compression - Uses LLMs to intelligently summarize history, preserving what matters and discarding noise. Think of it like how we naturally summarize a long meeting into a few key points.
  • Progressive Disclosure - Starts with high-level context and only fetches details when needed, managing our token budget intelligently. It's the difference between reading a book's table of contents versus reading every chapter.
  • Vector Search Integration - Works with Chroma for semantic search, so Claude can find relevant past context even when keywords don't match exactly. If Claude is working on 'user authentication' it can find previous work on 'login system'.
  • JSONL Storage - Stores everything in simple text format, one observation per line. Easy to read, easy to debug, easy to version control. No database to manage.
  • Local Web Viewer - Includes a browser interface where we can actually see what the agent remembers. Transparency matters when debugging why Claude made a particular decision.

When to Use Claude-Mem vs. Alternatives

Claude-Mem shines in long-running development projects where continuity matters - building complex applications over days or weeks, maintaining codebases where architectural decisions need to be remembered, working across multiple Git branches where context switches are frequent.

Other tools in this space take different approaches. Some use RAG (Retrieval Augmented Generation) systems with heavy infrastructure requirements - powerful but complex to set up. Others rely on simple file-based context injection - lightweight but not intelligent about what to inject. Claude-Mem sits in a sweet spot: intelligent enough to be useful, simple enough to actually deploy.

For quick, single-session tasks, Claude-Mem might be overkill - the native Claude Code context is fine. But once we're into day two of a project, having persistent memory becomes essential. In my view, this is infrastructure that should eventually be built into Claude Code itself, but until then, Claude-Mem fills a critical gap.

My Take - Will I Use This?

In my view, this addresses a real pain point that makes long-term AI pair programming frustrating. The 'amnesia problem' isn't just annoying - it actively limits what we can build with AI agents. Every time we restart a session and have to re-explain context, we're paying a tax in time and tokens.

The progressive disclosure approach is particularly smart. It solves the fundamental tension between 'remember everything' (expensive) and 'remember nothing' (useless) by being selective about detail levels. That's exactly the kind of practical engineering we need in AI tooling.

The limitation to watch: Compression quality depends entirely on which LLM we use for summarization. A weak summarization model will lose important nuances. The tool also requires some tuning - how much context to inject, how aggressive to be with compression, when to fetch deep history. It's not quite 'set and forget' yet.

For our workflow at YUV.AI, where we're constantly building and iterating on AI agent projects across multiple branches and sessions, this is exactly what we need. The JSONL storage means we can version control the agent's memory alongside our code, which opens up interesting possibilities for team collaboration.

Check out the repository: claude-mem on GitHub

Frequently Asked Questions

What is Claude-Mem?

Claude-Mem is a plugin for Claude Code that provides persistent memory across sessions by capturing agent observations, compressing them intelligently, and injecting relevant context when needed.

Who created Claude-Mem?

Claude-Mem was created by thedotmack, a developer focused on improving AI agent workflows and context management.

When should we use Claude-Mem?

Use Claude-Mem when working on projects that span multiple sessions, especially when switching between Git branches or when architectural decisions from previous sessions need to be maintained.

What are the alternatives to Claude-Mem?

Alternatives include full RAG systems with vector databases (more powerful but complex to set up), simple file-based context injection (lightweight but not intelligent), or manually managing context by copying previous conversations (time-consuming and doesn't scale).

What are the limitations of Claude-Mem?

The main limitations are that compression quality depends on the LLM used for summarization, it requires tuning to find the right balance of injected context, and it's still early-stage software that may need configuration adjustments for different workflows.

Comments