Claude-Mnemo
Structured memory system for Claude Code. Captures every tool call in real time, extracts observations and turn summaries via a background agent, and feeds them back into future sessions — so conversations start with context, not from scratch.
How It Works
Claude-Mnemo hooks into five points of the Claude Code lifecycle:
| Hook | Trigger | What it does |
|---|
| SessionStart | Session begins / resumes / clears / post-compact | Injects persona plus recent sessions/diary index; resume and post-compact also receive current state and session milestones |
| UserPromptSubmit | Every user message | Creates (or resumes) the session + a new turn row in SQLite |
| PostToolUse | Every tool call | Writes a raw observation (tool_name + input + result), enqueues it for extraction, wakes the worker |
| Stop | Agent finishes a turn | Backfills the assistant response + tool counts, enqueues a turn-stop job |
| PreCompact | Main agent is about to compact | Synchronously flushes the worker queue for this session and pushes a final session summary |
Extraction does not run inside the hook process. Hooks write to SQLite and return; a long-lived worker (Bun HTTP server on 127.0.0.1:37778) picks up the work asynchronously, sends it to Mnemosyne (an isolated Claude Agent SDK query session), and writes the extracted titles, content, insights, tags, and types back into the same database.
Data Model
Session [S12] one per conversation
Turn [T3] one per user prompt (promptNumber scoped to session)
Observation [O87] one per tool call
Turns carry a type tag: 🔴 bugfix · 🟣 feature · 🔄 refactor · ✅ change · 🔵 discovery · ⚖️ decision.
Queue + Crash Safety
All pending extraction work lives in a single pending_queue table keyed by a monotonic seq (AUTOINCREMENT). Hooks write to pending_queue inside the same SQLite transaction as the observation or turn-stop update, so a crashed worker or killed hook never drops work — the next worker boot resumes from the queue in FIFO order.
Installation
In Claude Code, add the marketplace and install:
/plugin marketplace add KawaiiLLM/claude-mnemo
/plugin install claude-mnemo
Bun is the only runtime dependency — bun-runner.js auto-installs it if missing. Marketplace and source installs ship with prebuilt plugin/scripts/*.cjs entrypoints, so hooks, MCP, and the worker run without a post-install build.
From Source
git clone https://github.com/KawaiiLLM/claude-mnemo.git
cd claude-mnemo
npm install
npm run build
Then symlink the built plugin:
ln -s "$(pwd)/plugin" ~/.claude/plugins/claude-mnemo
For contributors, npm run build refreshes the committed release artifacts in plugin/scripts/.
Usage
Once installed, Claude-Mnemo works automatically — hooks fire on every session, the worker extracts in the background, and SessionStart injects context on the next launch.
Three read axes plus one write path are exposed to the main agent:
recall (MCP tool) — content axis: search past work for the why — design rationale, rejected alternatives, decisions, user corrections. For what the code does now, read the source first.
timeline (MCP tool) — temporal axis: the decision arc of a single session — turns, milestone digest, phase overview, gaps, tool bursts, and compact boundary.
mnemo-replay (skill) — raw axis: direct reads of the source JSONL transcript and the SQLite database, for exact bytes.
remember (MCP tool) — the single write path; the background worker uses it to persist every extraction.
recall — the why-axis
Source records what the code does; it never records why. recall is the index over past sessions where that rationale lives — reach for it before reconstructing a design story from code (which yields confident-but-wrong answers), and for prior work ("did we already do this?", "how did we fix X last time?").
recall() # recent sessions
recall(query="auth race") # FTS across all layers
recall(query="type:bugfix file:src/auth.ts") # typed filters
recall(query="cookie session:S12") # full-text search within one session
recall(time="-7d") # relative time window
recall(id="S12") # session summary
recall(id="S12/T3") # turn by promptNumber
recall(id="S12/T3..7", depth="expanded") # turn range with content
recall(id="S12/T3/O*") # observations in a turn
recall(id="O87", depth="expanded") # specific observation