Blog1 October 20269 min readby Madhur

Claude Code memory: making it remember between sessions

Every new Claude Code chat starts from zero. Here are five real ways to give it memory between sessions, what each one is actually good at, where it falls over, and which ones stack.

A white card on a whiteboard headed “Where were we, Claude?”, listing CLAUDE.md for rules that always hold, --resume for yesterday’s exact chat, PROGRESS.md for where the work stands, and Claude Mem or Deiko for memory that fills itself, with “stack them!” scrawled beside it in marker.

Monday morning. New terminal, new chat.

"Right, so the coupon bug. The discount applies twice if you edit the cart after checkout opens. We fixed the display on Friday but not the actual charge. And we decided the server owns the maths, remember? No? Okay."

Four paragraphs later you're back where you were on Friday, minus twenty minutes.

This isn't Claude Code being forgetful. It's by design. In Anthropic's own words, "each Claude Code session begins with a fresh context window". Whatever carries over is whatever you, or a tool, put there. Here are the options I've actually used, roughly in the order you'd reach for them.

CLAUDE.md and auto memory: where Claude Code memory files live

Claude Code ships with two memory systems, and both load at the start of every session.

CLAUDE.md is the one you write. It's a Markdown file of instructions, and it can live in a few places:

Files in your working directory and every folder above it load at launch. Ones in subfolders load when Claude reads files there. A CLAUDE.md can pull in other files with @path/to/file, relative to the file doing the importing, up to four hops deep. Imports don't save context, though: the imported file loads at launch too. For rules that matter to part of the codebase, .claude/rules/ files with a paths: glob load only when Claude touches matching files.

Auto memory is the one Claude writes. It's on by default. As Claude works, it saves notes for itself in ~/.claude/projects/<project>/memory/: your preferences, your corrections, decisions it can't work out from the code. A MEMORY.md index keeps one line per memory, and its first 200 lines or 25KB load into every session. The detail sits in topic files that Claude reads when it needs them. It's per repository, shared across worktrees, and stays on that machine.

Saying "remember that the API tests need a local Redis" goes to auto memory. Saying "add this to CLAUDE.md" goes to CLAUDE.md. /memory lists every file, opens any of them in your editor, and has the switch to turn auto memory off. /context shows what actually loaded this session, which is the first thing to check when Claude seems to be ignoring you.

My own auto memory index for Deiko is about two dozen one-liners. My commit message style. Never auto-play a video file at me. It's genuinely good at that sort of thing.

Where it falls short:

--continue and --resume: pick up a previous session

The bluntest fix is not to start a new chat at all. From the CLI reference:

Long chats compact. As you approach the limit, Claude Code replaces the conversation with a structured summary: your requests, files touched, errors and fixes, pending tasks. Full tool output and intermediate reasoning are gone. CLAUDE.md and auto memory are re-read from disk afterwards, along with up to five of the most recently modified files. You can steer it with /compact focus on the coupon charge, so the summary keeps what you care about rather than what it guesses.

Good at: picking up exactly where one chat stopped, with every detail. Nothing to install.

Where it falls short: you get the whole conversation back, dead ends included, and it's one session. If the coupon work spanned three chats and a detour into the login page, you're choosing which one to reopen and hoping it's the right one. Transcripts also don't live forever: Claude Code deletes old ones after its cleanupPeriodDays retention period.

A progress file (a memory bank) the agent keeps

This is the pattern most people land on, and it's a good one. Keep a short Markdown file of where the work stands and have the agent update it before it finishes. Anthropic's own write-up on harnesses for long-running agents does exactly this with a claude-progress.txt alongside git history, so each new session can "read the git logs and progress files to get up to speed".

# PROGRESS.md
## Now
Coupon applies twice when the cart is edited after checkout opens.
## Tried
- Recalculating in CartSummary: fixed the display, not the charge.
## Decided
- The server computes the discount. The client only shows it.
## Next
- Test: edit cart, then apply coupon, then pay.

Then wire it into CLAUDE.md:

## Work in progress
@PROGRESS.md
Before you finish, update PROGRESS.md under Now, Tried, Decided, Next.
Keep it under 40 lines. Delete what's done.

Good at: it's free, plain text, readable by every agent you'll ever use, and you can see every change in git. The "Decided" section earns its keep: it stops Monday's agent cheerfully re-proposing what you ruled out on Friday.

Where it falls short: the agent forgets to update it. Not always, but often enough: it's an instruction, and instructions aren't guaranteed. A Stop hook that checks the file was touched fixes that, if you're happy writing one. One file per repo also turns into soup the moment you have two things in flight, so people end up with docs/tasks/coupon-bug.md and friends, and now you're the librarian. And committed on a branch, it merge-conflicts with itself.

Claude Mem: a memory plugin that records the agent

Claude Mem is an open-source plugin (Apache 2.0) that takes the "remember to update the file" problem off your plate entirely. From its README:

Install is npx claude-mem install, or /plugin install claude-mem from inside Claude Code. It needs Node 20+, and installs Bun and uv if they're missing. Worth knowing where the summarising cost lives: the installer offers a sign-in for its hosted observer, free for up to 14 days, after which memory falls back to your Anthropic plan unless you subscribe. You can also pick your own OpenRouter or Gemini key, or pass a --provider flag and skip the sign-in.

Good at: zero effort after install. You change nothing about how you work, and you get a searchable trail of which files the agent read, what it ran and what it learned.

Where it falls short: it remembers what the agent did, which isn't always what you meant. A tool log knows CartSummary.tsx was edited. It doesn't know you said "the charge, not the display". There are also more moving parts than a text file: a worker, a vector database and a summarising model.

Deiko: memory per piece of work

Full disclosure: I make this one, so weigh what follows accordingly.

Deiko starts from the other end. You double-tap Right Option, point at the thing on screen and say what's wrong, and it hands your agent a brief: your words, crops of what you pointed at, the text under the cursor. Every brief is then filed into the task it continues, the piece of work rather than the session. Each task keeps a note of where it stands, what was decided, and what agents reported back, and the next brief on that task carries it.

So on Monday you point at the checkout and say "still charging twice". Deiko files it under the coupon task, and Monday's agent is told the display fix was done, the server owns the discount, and the charge is still open. Different chat, possibly a different agent, same starting point.

When an agent finishes a brief it calls save_outcome with four headings: Did, Decided, Open, Files. In Claude Code, a Stop hook checks whether it did, and if the agent is about to finish without saving, it's asked once to save first. The local deiko-memory MCP server also gives agents search_briefs, list_tasks, get_task and get_brief, so it can look up "the chart thing from last week" itself. One click in Settings connects Claude Code, Codex, Cursor, Gemini CLI, VS Code and Antigravity. A board on your Mac lets you move briefs and edit or forget note lines; the memory page has the tour.

Where it falls short: it's macOS 14+ on Apple silicon only. It remembers your briefs, so a prompt you type straight into Claude Code isn't on the board. It keeps a short report per brief, not a log of every tool call, which is exactly Claude Mem's strength. Browser chats like ChatGPT get the task's history inside the brief but can't write back. And filing sends titles and summaries to a model for sorting; everything is stored on your Mac. If you're weighing the two plugins, I've compared Deiko and Claude Mem side by side.

Which one should you use?

Who writes itWhat it remembersOther agents?Setup
CLAUDE.mdYouRules that always hold, per project or per youVia AGENTS.mdA file
Auto memoryClaudeYour preferences and corrections, per repoNoOn by default
--continue / --resumeNobodyOne whole conversation, compacted when longNoA flag
Progress fileThe agent, when it remembersWhere the work stands, per fileYesTwo files
Claude MemHooks and a modelWhat the agent did, per sessionSeveralPlugin and worker
DeikoYour briefs, plus agent reportsEach piece of work you asked forYes, MCP agentsMac app

They stack, and most people should stack two. Keep CLAUDE.md for rules that are true every single session, and use one of the others for work that's still moving. The one thing I'd avoid is putting in-flight work into CLAUDE.md. It'll still be loading "the coupon bug is half fixed" in March.

tl;dr CLAUDE.md for rules that always hold. Then one thing for work in progress: --resume, a progress file, Claude Mem or Deiko, depending on how your week looks.

Questions people ask

Does Claude Code remember previous conversations?

Not by itself. Every session starts with a fresh context window. What carries over is your CLAUDE.md files and auto memory, which load at the start of every session, and any conversation you reopen with claude --continue or claude --resume.

Where does Claude Code store auto memory?

In ~/.claude/projects/<project>/memory/, one folder per git repository, shared across its worktrees. MEMORY.md is the index; its first 200 lines or 25KB load into every session, and the topic files beside it are read when Claude needs them. Run /memory to browse or edit them.

What is the difference between CLAUDE.md and auto memory?

You write CLAUDE.md: instructions and rules such as build commands and conventions. Claude writes auto memory: things it learned from your corrections and preferences. Both load at the start of every session, and both are context Claude tries to follow, not settings it is forced to obey.

How do I resume a Claude Code session?

claude --continue (or -c) opens the most recent conversation in the current directory. claude --resume (or -r) opens a picker, or takes a session ID or name. Name a session with claude -n "name" or /rename so it is easy to find later.

Is there an MCP server for Claude Code memory?

Yes, several. Claude Mem gives Claude Code search, timeline and get_observations tools over what earlier sessions did. Deiko's local deiko-memory server has search_briefs, list_tasks, get_task, get_brief and save_outcome, and connects to Claude Code, Codex, Cursor, Gemini CLI, VS Code and Antigravity.

Is there a Claude Code memory plugin?

Yes, several. Claude Mem is a plugin that records what the agent does through hooks and brings it back next session. Deiko connects a local MCP memory server to Claude Code from its Settings, built from what you point at and say, with a Stop hook so the agent saves a report. Both are open source; here is how they differ.