Memory, persistent state across sessions

Without memory, your agent starts every conversation from scratch. You re-explain who you are, what you prefer, and what you're working on. Every. Single. Time. Memory fixes that. Claude Code maintains a persistent file-based memory that travels with you across sessions, so the agent builds up context about your work the way a good employee does, a little more useful every week instead of starting from zero every Monday.

The mental model.

Claude Code's memory is a small folder of markdown files with a single index file called MEMORY.md. Each memory is one file, usually short (a few sentences to a page). The index lists them all with one-line descriptions. At the start of every session, Claude reads the index, so it knows what memories are available. When a memory becomes relevant, Claude opens the specific file for the full content.

That's the whole system. It's plain text, version-controllable if you want, inspectable, editable. Not a vector database or a magic layer. Just files.

The four kinds of memory worth keeping.

Not everything belongs in memory. There are four specific types that earn their keep:

~ four kinds of memory worth keeping ~

The split matters. User memories let the agent tailor its voice to you; feedback memories prevent repeated corrections; project memories give the agent context it can't derive from the code; reference memories point it at where external info lives.

What to save. What NOT to save.

This is the part most people get wrong. Over-saving bloats the index and kills signal-to-noise. Under-saving means the agent relearns the same things every session. Here's the test:

~ worth saving vs not worth saving ~

The rule behind the rule: if you can derive it from the code or the commit history, don't memorize it. Memory is for things that aren't written down anywhere else. The user's preferred response length isn't in git; memorize it. The fact that UserService has a create method IS in git; don't memorize it.

Memory hygiene. The stuff most people skip.

The three failure modes you'll hit.

  1. Stale memory. A claim in memory stops being true. "User is working on auth rewrite" is saved; six months later, the auth rewrite shipped. The agent still acts as if auth is in progress. Fix: check the current state before acting on memory. If memory contradicts reality, trust reality and update the memory.
  2. Context bloat. You've been using the agent for a year and have 80 memories. Every session starts with a wall of text. The signal-to-noise drops. Fix: prune aggressively. A memory that hasn't been relevant in 30 days is a candidate to delete.
  3. Wrong inferences. The agent reads "user prefers React" and applies it to a backend-only question. Memories are snapshots; the agent needs to judge when they apply. Make your memories specific enough that misapplication is hard.

When memory really shines.

Memory isn't magic. But when it's working, the difference is huge:

How to control it manually.

You don't have to wait for the agent to capture things. Just tell it:

Explicit control is especially useful early on when you're still teaching the agent what matters. After a month or two, most memory management happens automatically - you just live your work and the agent captures the useful bits as they come up.

The bottom line.

Memory turns an agent from a stranger into a coworker. It's not the flashiest feature of Claude Code, but it's the one that makes the agent feel like it's yours. Spend a little time pruning and curating, and what you get back is an assistant that knows you, knows your work, and doesn't make you repeat yourself.