Updated 2026-07-02

How to give Claude Code persistent memory across sessions

Session amnesia is a default, not a law. Here are your three options — and a 5-minute setup for the one that also remembers WHY.

Monday morning, new Claude Code session: “We deployed last week but it crashed. How did we fix it?”“I don't have access to previous sessions.” Thirty minutes of log-spelunking follow. Every Claude Code session starts from a blank context window; whatever you explained, decided, or debugged last time is gone unless you put it somewhere the next session can read.

Your three options

1. CLAUDE.md — static instructions

Claude Code automatically loads CLAUDE.md from your project root. It is the right place for stable facts: build commands, code style, architecture notes. Its limits: you edit it by hand, the whole file is loaded every session (so it can't grow unbounded), and it has no notion of “what we decided three sessions ago and why.”

2. The official memory MCP server

Anthropic ships @modelcontextprotocol/server-memory, a minimal knowledge graph (entities / relations / observations) stored in a JSONL file. Solid reference implementation; the agent must be prompted to save and query explicitly. See our detailed comparison.

3. linksee-memory — structured memory + drift detection

A local-first MCP server that stores memories in six layers (goal / context / emotion / implementation / caveat / learning) in one SQLite file, can capture sessions automatically via Claude Code hooks, and reconciles your locked decisions against what actually got committed.

Set up linksee-memory in 5 minutes

Step 1 — install

npx -y linksee-memory setup

The setup walks you through registering the MCP server for Claude Code (and other clients) and offers optional hooks for automatic session capture. Prefer doing it by hand? One command registers it user-wide:

claude mcp add -s user linksee -- npx -y linksee-memory

Tools appear as mcp__linksee__remember, mcp__linksee__recall, mcp__linksee__read_smart.

Step 2 — save your first memory

After a decision or a hard-won lesson, say “linksee this”. The agent stores it — not just the fact, but the layer it belongs to. A deploy postmortem becomes a caveat (“NextAuth sessions invalidate when JWT_SECRET rotates — redeploy affected projects in parallel”), which is permanently protected from forgetting.

Step 3 — recall in the next session

New session, same project: say “use linksee” before starting work. The agent pulls relevant memories — including the WHY behind past decisions — instead of asking you to re-explain.

Step 4 (optional) — make it automatic

Add “Use Linksee Memory” to your CLAUDE.md so recall happens without the spell, and let setup install the Stop hook so sessions are captured even when nobody says “save this.”

What you get beyond remembering

  • Drift detection: declare decisions as anchors; ask what's drifting? in any later session and get a reconciliation of reality vs. what you decided.
  • Token savings: read_smart returns diffs instead of full files on re-reads — measured 86% savings on a typical TypeScript edit, 99% on unchanged files.
  • Nothing leaves your machine: one SQLite file, zero network calls by default, no account.