Skip to main content

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

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

  1. sessionbook claude calls os.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 in os.waitpid() and never touches stdin/stdout.
  2. After the child exits, the parent reads JSONL session files from ~/.claude/projects/ that were modified during the session.
  3. Each session's user and assistant turns are extracted (with requestId collapsing for streamed responses), along with thinking blocks, user choices, and sub-agent references.
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sessionbook-0.2.0.tar.gz (39.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sessionbook-0.2.0-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file sessionbook-0.2.0.tar.gz.

File metadata

  • Download URL: sessionbook-0.2.0.tar.gz
  • Upload date:
  • Size: 39.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sessionbook-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3c95ee5c6c0d8626ec50e114e9ba7678297f9dc0342cf8d6c7b599d1f4def36c
MD5 bfa55e80fe4ec1692984fdd84c32019c
BLAKE2b-256 b8ac8bb6e0c5b156e5767f312c2c0b4dc0894c5df63ec30df20d2f3a120d6c0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sessionbook-0.2.0.tar.gz:

Publisher: publish.yml on jamesnordlund/sessionbook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sessionbook-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: sessionbook-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sessionbook-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 025217793baf54476f8e3e5f3085cd9a0fc190e490ad4ea44a638e2e8d2566fc
MD5 ca72c8fbe8c7852657da7666abe1648d
BLAKE2b-256 26983f5ad71e5128932a9035e970be12c630030d113fbbe690d51e33a9c830eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for sessionbook-0.2.0-py3-none-any.whl:

Publisher: publish.yml on jamesnordlund/sessionbook

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page