Session Summary CLI
Restores bounded working context from a Claude Code session transcript:
finds sessions on disk (list) and prints a digest of verbatim quotes from
the tail of a chosen session (load). The digest is never an agent-written
summary — every line comes straight from the transcript: user prompts,
assistant text, tool calls with their key argument, and system errors.
Bounded, not schema-strict
The Claude Code transcript format keeps growing new root event types and
new field shapes on existing ones. This parser treats that as normal: an
unrecognized root type is skipped silently (never a parse failure for the
rest of the line's siblings — see [claude_session_types::events::SessionEvent::Unknown]),
and a handful of known fields (message.content, toolUseResult) accept
more than one wire shape rather than dropping the whole event.
Reads are byte-budgeted, not full-file scans
Both list and load read a bounded window from the end of the file
(read_tail_lines) with a single seek plus one read — cost is
proportional to the window, not to file size, so a multi-gigabyte
transcript loads in well under a second. Session titles can lag behind a
large tail window on a very bursty session, so title detection falls back
to a small bounded read from the start of the file (read_head_lines)
when the tail window doesn't carry one.
Topic selection
In priority order: the session's own custom-title (Claude Code's UI
title), then ai-title (model-generated), then last-prompt (latest
verbatim human prompt), then the first genuine human-typed prompt in the
session (skipping harness-injected meta turns, command-palette
injections, and tool-result-only turns) — never a generic placeholder
unless none of the above exist at all.