Claude Code Memory

How developers are solving Claude Code's amnesia problem — and the open-source MCP solution that does it automatically.

17,000+ Claude Code users affected

The Problem: Claude Code Forgets Everything

Every /compact is a fresh start

Claude Code is powerful inside a session. But between sessions, it has amnesia. Every new conversation starts from zero. On a complex project, this means spending the first few minutes re-explaining your architecture, your decisions, your conventions — before you can do any real work.

"Every time I hit /compact, Claude forgets everything we just worked on. All those architecture decisions we debated? Gone. That bug fix we finally figured out? Vanished. Client preferences I mentioned three times? Claude asks again. It's like Groundhog Day, except I'm the one who has to repeat myself." — Mohamed Ali, DEV Community (Feb 11, 2026)

How Developers Are Solving It

Two independent developers built MCP servers specifically for Claude Code memory persistence. Both discovered the same approach: watch the /compact hook, intercept the context, save it somewhere persistent, then restore it on the next session.

MemCP

By Mohamed Ali. Blocks Claude with "save your work first" when /compact fires. Gentle reminders every 10 turns if nothing saved yet.

DEV Community · Feb 2026 Read the full story →

memory-mcp

By Yuval. Two-tier architecture: CLAUDE.md (~150 lines) for session briefing + vector store for detailed memories. Uses Claude Code's built-in hooks.

DEV Community · Jan 2026 Read the architecture →

mcp-memory-keeper

Open-source MCP server for persistent context management in AI coding assistants. GitHub: mkreyman/mcp-memory-keeper.

GitHub Open Source

★ agent-memory

Open-source MCP server that works with Claude Code, Cursor, and any MCP client. No configuration needed. JSON/SQLite/Redis backends. TTL. AES encryption.

MIT License · No API Key Required

The Architecture That Makes It Work

Yuval's architecture article describes the key insight that shapes all Claude Code memory solutions:

Claude Code already has two features that make memory possible

  1. CLAUDE.md — Claude Code reads this file at every session start. Whatever is in it becomes part of Claude's initial context.
  2. Hook system — Shell commands that fire after every response (Stop), before context compaction (PreCompact), and at session end (SessionEnd).

These two features, combined, are everything you need for persistent memory. The hooks capture knowledge. CLAUDE.md delivers it. No custom protocols, no external databases.

Two-Tier Memory Architecture

Tier Storage Content When Used
Tier 1 CLAUDE.md ~150 lines of compact briefing Every session start
Tier 2 Vector store / JSON Full memories, decisions, preferences When Claude searches or asks
★ agent-memory JSON / SQLite / Redis Everything above + TTL + encryption Always — MCP tools

Quick Setup: Give Claude Code Memory in 3 Steps

  1. Install agent-memory
    pip install agent-memory
  2. Run the MCP server
    python -m agent_memory.mcp_server
  3. Configure Claude Code to use it
    Add the MCP server URL to your Claude Code MCP config
⚠ This requires Claude Code to support custom MCP servers. Check your Claude Code configuration for MCP server settings.

What Gets Saved

With a persistent memory system, Claude Code remembers:

Open Source Solutions Compared

Solution Type Claude-Specific Encryption TTL License
MemCP MCP Server Yes (hooks) Open
memory-mcp MCP Server Yes Open
mcp-memory-keeper MCP Server Partial MIT
agent-memory MCP Server Yes (universal) AES-256 Yes MIT

The Real Problem /compact Solves

You might think /compact is the enemy. But it's actually necessary — Claude's context window is finite, and long conversations need to be compressed to stay productive.

The real problem is that compaction destroys valuable context that should be saved, not lost. The solution isn't to avoid /compact — it's to intercept it and save the context before it disappears.

"There's a constraint that shaped everything: Claude Code already reads a file called CLAUDE.md on every session start. Whatever is in that file becomes part of Claude's initial context. Claude Code also has a hook system. These two features, combined, are everything you need for persistent memory." — Yuval, The Architecture of Persistent Memory for Claude Code

Get Started

agent-memory on GitHub Try the Live Demo