Session Memory

Persistent context across Claude Code sessions: what gets written to disk and how it rehydrates later

memorycontext

Some Claude Code bundles include a disk-backed “session memory” feature: a structured notes file that the runtime can update during a session and re-inject later.

This is reverse engineered from a shipped bundle. Treat the details as “observed behavior,” not a stable public contract.

What You’ll Learn


How It Works

Session Memory runs in the background, periodically extracting important information into a structured markdown file. No commands to run, no manual saving.

The key property is cadence: it updates often enough to stay useful, but not so often that it becomes noise.

Storage location (conceptual):

[claude-code data dir]/session-memory/
├── config/
│   ├── template.md      # Custom template (optional)
│   └── prompt.md        # Custom extraction prompt (optional)
└── [session-id].md      # Your session notes

Files are plain markdown. You can read them, edit them, or delete them.


What Gets Captured

Session Memory writes a structured notes file. The shape matters, because it makes the memory scan-friendly and stable under edits.

The sections are roughly:

Under the hood, the note-taking step is intentionally constrained (paraphrased):


Back Into the Context Window

When enabled, saved memory can be loaded at the start of a new session. The runtime wraps it in a caution header so the model does not blindly assume it’s relevant.

The injection is wrapped in a “be careful” header so the model does not blindly assume the memories are relevant. It’s closer to:


Customization

Want different sections? Different extraction logic? Both are customizable.


What This Means

This is the operational point of view: memory is reliability engineering for long-lived work.

Instead of relying on “whatever the model remembers,” the system maintains a user-auditable state file that can survive:

The files are yours. They’re on your disk, in plain markdown, editable and deletable. The agent can learn from them, but you control them.

Practical Risks (And How To Design Around Them)

← Back to all posts