Session checkpoint and recovery layer for Claude Code — resume interrupted sessions, export shareable HTML traces.
Project description
Claude Replay
Session checkpoint and recovery for Claude Code.
API errors, rate limits, and context overflow kill Claude Code sessions silently and everything you were mid-way through goes with them. Claude Replay hooks passively into every session, records what happened to a local SQLite store, and lets you resume from a structured briefing with one command.
Claude Code session
|
hooks (PreToolUse · PostToolUse · Stop)
|
v
~/.claude-replay/sessions.db ← events + checkpoints
|
+----+--------------------+
| | |
MCP tools Dashboard TUI
(resume) :8766 (browse)
Passive hooks write. MCP tools, the web dashboard, and the terminal UI read. Nothing leaves your machine.
Architecture
Passive hooks write to SQLite. MCP tools read from SQLite. Dashboard + TUI visualize SQLite. That's the whole system.
| Layer | File | Role |
|---|---|---|
| Store | claude_replay/store.py |
All DB access — sessions, events, checkpoints |
| Hooks | claude_replay/hooks.py |
Record tool calls + auto-checkpoint, dispatched by claude-replay hook <type> |
| Recovery | claude_replay/resume.py |
Generate a resume brief from a session |
| Export | claude_replay/export.py |
Render a session as a self-contained HTML trace |
| Server | claude_replay/server.py |
Starlette app — MCP SSE + JSON API + static dashboard |
| TUI | claude_replay/tui.py + tui_client.py |
Textual session browser over the JSON API |
| CLI | claude_replay/cli.py |
Every subcommand |
Port 8766 deliberately one above Claude Bridge's 8765, so the two siblings can run side by side without colliding.
Quickstart
1. Install
pip install claude-replay
Or from a clone if you'd like to hack on it:
git clone https://github.com/constripacity/Claude-Replay.git
cd Claude-Replay
pip install -e .[dev] # editable install with test/lint deps
pip install -e .[tui] # add the terminal UI deps (textual, httpx)
If
pip install -efails on your environment (a known hatchling editable-install quirk on some setups), install the deps directly instead:pip install mcp starlette uvicorn anyio textual httpx.
2. Install the hooks
This wires Replay into Claude Code by merging three hooks into ~/.claude/settings.json. It's idempotent and leaves any other tools' hooks untouched.
claude-replay install
✓ Installed Claude Replay hooks into ~/.claude/settings.json
PreToolUse → claude-replay hook pre-tool
PostToolUse → claude-replay hook post-tool
Stop → claude-replay hook stop
From now on, every Claude Code session is recorded automatically. Remove the hooks any time with claude-replay uninstall (it removes only Replay's hooks).
3. Start the server (dashboard + MCP tools)
claude-replay serve # defaults: 127.0.0.1:8766
claude-replay serve --port 9000 # custom port
claude-replay serve --host 0.0.0.0 # bind all interfaces
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Claude Replay — Session checkpoint & recovery server
Version: 0.1.0
DB: ~/.claude-replay/sessions.db
http://localhost:8766/ ← Dashboard
http://localhost:8766/sse ← MCP config
http://localhost:8766/api/state ← JSON state
http://localhost:8766/status ← Health check
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
4. (Optional) Register the MCP tools with Claude Code
So a running Claude Code session can call replay_resume, replay_checkpoint, etc. directly. Two ways:
SSE (alongside the dashboard — needs claude-replay serve running):
claude mcp add --transport sse -s user claude-replay http://localhost:8766/sse
stdio (no server process — the client launches Replay on demand):
claude mcp add -s user claude-replay -- claude-replay mcp
# or, without installing: uvx claude-replay mcp
Verify with claude mcp list claude-replay should show ✓ Connected. Inside an already-running session, type /mcp to re-handshake.
When a session dies
# What's the state of the last session?
claude-replay status
# Print a paste-ready resume brief (most recent session, or pass an id)
claude-replay resume
claude-replay resume <session-id>
# Browse every recorded session in the terminal
claude-replay tui # needs `claude-replay serve` running
# Export a session as a self-contained HTML trace
claude-replay export # → ~/.claude-replay/exports/<id>.html
Paste the resume output into a fresh Claude Code session and it picks up where the dead one left off objective, what was done, what's next, and which files were touched.
MCP Tools
Every connected Claude Code session gets these seven tools:
| Tool | Description |
|---|---|
replay_status |
Current session summary objective, status, how it ended, event/checkpoint counts, last activity |
replay_checkpoint |
Force a checkpoint of the current session now, with an optional note |
replay_resume |
Generate a structured resume brief for a session (default: most recent) |
replay_sessions |
List recent sessions with status, model, duration, checkpoint count |
replay_export |
Render a session as a self-contained HTML trace and return the path |
replay_search |
Full-text search across sessions (event payloads, objective, name, tags), ranked by match count |
replay_tag |
Name a session and add/remove tags for later retrieval |
CLI Reference
| Command | What it does |
|---|---|
claude-replay install |
Merge Replay's hooks into ~/.claude/settings.json (idempotent) |
claude-replay uninstall |
Remove only Replay's hooks |
claude-replay status |
Show the current/last session at a glance |
claude-replay sessions [--limit N] |
List recent sessions (with names + tags) |
claude-replay search <query> [--limit N] |
Full-text search across sessions, ranked by match count |
claude-replay resume [session_id] |
Print a resume brief (default: most recent) |
claude-replay export [session_id] [--output DIR] |
Render an HTML trace |
claude-replay tag [session_id] [--name N] [--add a,b] [--remove c] [--clear] |
Name or tag a session |
claude-replay prune [--older-than 30d] [--yes] |
Delete sessions with no recent activity (destructive) |
claude-replay serve [--host H] [--port P] |
Start the MCP + dashboard server (port 8766) |
claude-replay mcp |
Serve the MCP tools over stdio (for uvx claude-replay mcp / MCP clients) |
claude-replay tui [--url URL] |
Launch the terminal session browser |
claude-replay reset [--yes] |
Delete all recorded sessions (destructive) |
claude-replay hook <pre-tool|post-tool|stop> |
Internal — invoked by Claude Code's hooks |
Dashboard & TUI
Web dashboard (claude-replay serve, then open http://localhost:8766/) a vanilla-JS view that polls every 2 s: session list (with how-it-ended badge + tags), a live search box, per-session timeline, and one-click "Copy Resume Brief" / "Export HTML". No CDN, no build step.
Terminal UI (claude-replay tui) a Textual browser in the same dark theme. A session sidebar, a live event feed, and a detail inspector showing how the session ended, its tags, the latest checkpoint, and files touched. Keys:
↑↓ navigate Tab switch panel Space pause
r resume (copies the brief to your clipboard)
e export HTML trace
? help q quit
The TUI talks to the server over HTTP start claude-replay serve first (defaults to http://127.0.0.1:8766; point elsewhere with --url).
Configuration
| Env var | Default | Purpose |
|---|---|---|
CLAUDE_REPLAY_DB |
~/.claude-replay/sessions.db |
SQLite store location |
CLAUDE_SESSION_ID / CLAUDE_CODE_SESSION_ID |
— | Session identity (Claude Code sets this in the hook payload); falls back to these env vars, then to a hash of the project dir |
CLAUDE_REPLAY_CORS_ORIGIN |
localhost only | Comma-separated extra CORS origins for the server |
CLAUDE_REPLAY_NO_DASHBOARD |
— | Set to disable the static dashboard mount (MCP/JSON only) |
The hook path is offline-first by design: it makes no network calls and completes in well under 50 ms just the one SQLite write. Large tool payloads are truncated at 8 KB per event so the DB stays lean.
Development
pip install -e .[dev] # or install deps directly (see install note)
python -m pytest # full suite
ruff check .
Tests use an isolated tmp_path SQLite database (the fresh_db fixture) — they never touch your real ~/.claude-replay/sessions.db. See CONTRIBUTING.md for the scope and the coding rules.
License
MIT see LICENSE.
Sibling to Claude Bridge. Built under the Constripacity banner.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_replay-0.2.0.tar.gz.
File metadata
- Download URL: claude_replay-0.2.0.tar.gz
- Upload date:
- Size: 60.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c0302896896d8ed183dacb1e35107cf13d8549479bb47ed0ea8da1566e4ea4db
|
|
| MD5 |
7b76cd0be81199e9e60f5f25280c3d88
|
|
| BLAKE2b-256 |
1081cd09fbf8959964751aee0b7b2852f3d1993bf8cc9d66b7a76d061d2dd1f3
|
Provenance
The following attestation bundles were made for claude_replay-0.2.0.tar.gz:
Publisher:
publish.yml on constripacity/Claude-Replay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_replay-0.2.0.tar.gz -
Subject digest:
c0302896896d8ed183dacb1e35107cf13d8549479bb47ed0ea8da1566e4ea4db - Sigstore transparency entry: 1692976592
- Sigstore integration time:
-
Permalink:
constripacity/Claude-Replay@a6b6b8fc89c3955d40962ecd129404e1fe562eb9 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/constripacity
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a6b6b8fc89c3955d40962ecd129404e1fe562eb9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file claude_replay-0.2.0-py3-none-any.whl.
File metadata
- Download URL: claude_replay-0.2.0-py3-none-any.whl
- Upload date:
- Size: 47.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e570409373a82ec22925b84ac7d56a0fd1f7cfab81123918cf07a9c896ffbb58
|
|
| MD5 |
d3ac27df5776135fa334cbfad12e1c46
|
|
| BLAKE2b-256 |
d58e0880d3fe88a894e5856e6be88eec23bc6fd087005bf5d538c751367f3838
|
Provenance
The following attestation bundles were made for claude_replay-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on constripacity/Claude-Replay
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
claude_replay-0.2.0-py3-none-any.whl -
Subject digest:
e570409373a82ec22925b84ac7d56a0fd1f7cfab81123918cf07a9c896ffbb58 - Sigstore transparency entry: 1692976846
- Sigstore integration time:
-
Permalink:
constripacity/Claude-Replay@a6b6b8fc89c3955d40962ecd129404e1fe562eb9 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/constripacity
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a6b6b8fc89c3955d40962ecd129404e1fe562eb9 -
Trigger Event:
push
-
Statement type: