Save Claude Code sessions as self-contained HTML files
Project description
sessionbook
Save Claude Code sessions as self-contained HTML files.
sessionbook wraps the claude CLI and, on exit, converts the session's JSONL
log into a .html file in the local .sessionbook/ directory. The output is a
chat-style transcript with collapsible thinking blocks, user-choice decision
cards, and linked sub-agent transcripts. Each file is self-contained (inline
CSS, no external dependencies) and opens in any browser.
Requirements
- Python 3.10+
- Claude Code CLI installed and on
$PATH - macOS (uses
os.fork)
Installation
pip install sessionbook
For development (includes pytest):
pip install -e ".[dev]"
Quick Start
Capture a session
sessionbook claude
This launches Claude Code exactly as if you ran claude directly. All
interactive features work unchanged (Ctrl+G, slash commands, MCP tools). When
the session ends, sessionbook reads the JSONL session file and saves an HTML file
to .sessionbook/<TIMESTAMP>.html.
If you use /clear during a session, each sub-session is saved as a separate
file.
Arguments are forwarded
Any arguments after claude are passed through to the Claude Code CLI:
sessionbook claude --model sonnet
sessionbook claude -p "Explain this repo"
Convert existing sessions
Retroactively convert past Claude Code sessions for the current project directory:
sessionbook sync
Or convert a specific session by ID:
sessionbook sync <session-id>
Output Format
HTML files are written to .sessionbook/ in the working directory. Each file is
named with a local-time timestamp: 2026-02-07T14-32-01.html.
.sessionbook/
2026-02-10T21-43-08.html
2026-02-10T21-43-08/ # sub-agent transcripts (if any)
agent-aa5abe3.html
agent-bc7f012.html
Session layout
Each turn in the conversation is rendered as a visually distinct card:
- User turns — light blue background with the user's prompt text
- Assistant turns — light gray background with the model's response
- Thinking blocks — collapsed
<details>elements (click to expand) - Decision cards — when the model presented options via AskUserQuestion, the card shows the question, all options, and which one was selected
- Sub-agent cards — when the model forked work to a sub-agent (e.g., Explore, executor), the card shows a summary and links to a separate HTML file with the full sub-agent transcript
What is captured
| Content | Included |
|---|---|
| User prompts | Yes |
| Model responses (text) | Yes |
| Thinking blocks | Yes (collapsed) |
| User choice interactions | Yes (decision cards) |
| Sub-agent transcripts | Yes (linked out) |
| Tool use / tool results | No (filtered out) |
| System context (isMeta) | No (filtered out) |
CLI Reference
sessionbook <subcommand> [options] [args...]
Subcommands:
claude Wrap Claude Code and save session as HTML on exit
sync Convert existing Claude Code sessions to HTML
Options:
--verbose Enable debug-level logging to stderr
--version Print version and exit
--help Print usage and exit
Environment variables:
sessionbook_DEBUG=1 Equivalent to --verbose
Exit codes mirror the claude child process. If claude exits 0, sessionbook
exits 0.
How It Works
sessionbook claudecallsos.fork()+os.execvp("claude", ...). The child process inherits the terminal directly, so Claude Code behaves identically to a direct invocation. The parent process is blocked inos.waitpid()and never touches stdin/stdout.- After the child exits, the parent reads JSONL session files from
~/.claude/projects/that were modified during the session. - Each session's user and assistant turns are extracted (with
requestIdcollapsing for streamed responses), along with thinking blocks, user choices, and sub-agent references. - The session is rendered as self-contained HTML with inline CSS and written
atomically (tempfile + rename) to
.sessionbook/.
Zero runtime dependencies. The HTML is constructed from Python f-strings with
html.escape() for all user content.
Uninstall
pip uninstall sessionbook
The .sessionbook/ directories contain only generated HTML files and can be
deleted at your discretion.
License
MIT
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 sessionbook-0.1.0.tar.gz.
File metadata
- Download URL: sessionbook-0.1.0.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7cd1ee87ad6826d91d35b6638cb35551cbaeb8c6ea2ebc2b082e57a0104fd298
|
|
| MD5 |
fb5c9876ed3409a9ccf10727f0119d57
|
|
| BLAKE2b-256 |
0ea76edcabc776279b36de015ed5bab9183945f0fef22eec14a6962b4b974180
|
Provenance
The following attestation bundles were made for sessionbook-0.1.0.tar.gz:
Publisher:
publish.yml on jamesnordlund/sessionbook
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sessionbook-0.1.0.tar.gz -
Subject digest:
7cd1ee87ad6826d91d35b6638cb35551cbaeb8c6ea2ebc2b082e57a0104fd298 - Sigstore transparency entry: 953072025
- Sigstore integration time:
-
Permalink:
jamesnordlund/sessionbook@042f8253a474890f3f75ad4e09034c1d50f06f9b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jamesnordlund
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@042f8253a474890f3f75ad4e09034c1d50f06f9b -
Trigger Event:
release
-
Statement type:
File details
Details for the file sessionbook-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sessionbook-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7f8c7ee279d31ce132e07886eeddb4a78fb6fae00ead4999a65636e0d358512
|
|
| MD5 |
d3989ee85c1738581c6385792e78ffe5
|
|
| BLAKE2b-256 |
13e752cb66314f8ea6ea8867311a45abdc72fd8c3b9556449f45bb6c73853363
|
Provenance
The following attestation bundles were made for sessionbook-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on jamesnordlund/sessionbook
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sessionbook-0.1.0-py3-none-any.whl -
Subject digest:
c7f8c7ee279d31ce132e07886eeddb4a78fb6fae00ead4999a65636e0d358512 - Sigstore transparency entry: 953072026
- Sigstore integration time:
-
Permalink:
jamesnordlund/sessionbook@042f8253a474890f3f75ad4e09034c1d50f06f9b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/jamesnordlund
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@042f8253a474890f3f75ad4e09034c1d50f06f9b -
Trigger Event:
release
-
Statement type: