Skip to main content

TUI and CLI for inspecting Claude Code conversation history and compaction events

Project description

Claude Code Compaction Viewer

A TUI and CLI tool for inspecting Claude Code conversation history and compaction events.

PyPI Python 3.11+ License: MIT

# Try it now — no install needed
uvx ccviewer --scan
image

What is compaction?

When a Claude Code session runs long, the context window fills up. Rather than crashing or losing everything, Claude Code performs compaction: it inserts a boundary marker in the conversation, generates a structured summary of everything before it, and continues with the summary replacing the full history in the active context.

The full conversation is preserved on disk in JSONL files at ~/.claude/projects/. This tool lets you see exactly what happened:

  • Where compaction boundaries were inserted
  • What the compressed summary contains (the "outcome" of compaction)
  • How many tokens were in context before each compaction triggered
  • Whether compaction was auto-triggered or manual (/compact)

Inspired by Tal Raviv's article on doing "brain surgery" on Claude Code.

Install

# With uv (recommended)
uv tool install ccviewer

# With pip
pip install ccviewer

# Or run directly without installing
uvx ccviewer --scan

Usage

Scan all conversations for compactions

ccv --scan

Prints a table of every Claude Code conversation across all your projects, highlighting which ones have compaction events:

Project                                  Session     Lines Compactions  Tokens In Tokens Out   Duration
─────────────────────────────────────────────────────────────────────────────────────────────────────────
~/Work/my-project                        a272d8b9…    3086           3       1.8k     262.4k       4.1h
~/Work/other-project                     f359f046…      79           0         36       3.8k       1min

View compaction summaries

ccv --summary ~/.claude/projects/<project>/<session>.jsonl

Prints full details for each compaction event — the trigger, token count, and the complete summary text that Claude sees after compaction.

Interactive TUI

ccv

Launches a full terminal UI:

  • Left sidebar: tree of all Claude Code projects and conversation files
  • Stats bar: message counts, token usage, model, duration
  • Compaction bar: highlighted summary of all compaction events
  • Message table: scrollable list of every message (user, assistant, tool calls, system)
  • Detail panel: full content of selected message with metadata

TUI Keybindings

Key Action
c Jump to next compaction boundary
Shift+C Jump to previous compaction boundary
s Show all compaction summaries in detail panel
t Toggle progress messages (hidden by default)
j / k Scroll down / up
q Quit

You can also open a specific file directly:

ccv ~/.claude/projects/<project>/<session>.jsonl

How Claude Code stores conversations

Claude Code saves every conversation as a JSONL file at:

~/.claude/projects/<project-path>/<session-uuid>.jsonl

Each line is a JSON object with a type field:

Type Description
user User messages and tool results
assistant Claude's responses, thinking, and tool calls
system System messages including compaction boundaries (subtype: "compact_boundary")
progress Progress updates for long-running tool calls
file-history-snapshot File state snapshots for undo

Compaction creates two adjacent lines:

  1. A system message with subtype: "compact_boundary" and compactMetadata (trigger type, pre-compaction token count)
  2. A user message with isCompactSummary: true containing the structured summary

The conversation continues after the summary. The full history stays in the file — the summary just becomes what's loaded into the active context window going forward.

Development

git clone https://github.com/swyxio/claude-compaction-viewer
cd claude-compaction-viewer
uv sync
uv run ccv --scan

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

ccviewer-0.1.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

ccviewer-0.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file ccviewer-0.1.0.tar.gz.

File metadata

  • Download URL: ccviewer-0.1.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.5

File hashes

Hashes for ccviewer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 df1af04098aa48f7a9f6bfe63583daf70b818f2999b6919ef17139d16b6612f1
MD5 752b6fc08e31ae6ab3b32e931fcea6ca
BLAKE2b-256 f99349f9a865f02d60f994166e5ceb1bd0aa6be8dfc3bfc9d281f05a0f08d9f6

See more details on using hashes here.

File details

Details for the file ccviewer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ccviewer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.5

File hashes

Hashes for ccviewer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3ebe05f54be62f9a70a2a97c94ee150b544725c9ee20508983611d75aff6ead7
MD5 1dcf2e3e6be70e0827676ef17624bd64
BLAKE2b-256 f7cd77ca4d3f4d07b2a2e7ac16198598263358aa0ca68f8b247a2768349ece7b

See more details on using hashes here.

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