Claude Code Compaction Viewer
A TUI and CLI tool for inspecting Claude Code conversation history and compaction events.
# Try it now — no install needed
uvx ccviewer --scan
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:
- A
systemmessage withsubtype: "compact_boundary"andcompactMetadata(trigger type, pre-compaction token count) - A
usermessage withisCompactSummary: truecontaining 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
Release files for ccviewer 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ccviewer-0.1.0.tar.gz | 10.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ccviewer-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.3 kB
Release files / ccviewer-0.1.0.tar.gz
| Download URL | ccviewer-0.1.0.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df1af04098aa48f7a9f6bfe63583daf70b818f2999b6919ef17139d16b6612f1
|
|
BLAKE2b-256 checksum How to use checksums |
f99349f9a865f02d60f994166e5ceb1bd0aa6be8dfc3bfc9d281f05a0f08d9f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.5
|
Release files / ccviewer-0.1.0-py3-none-any.whl
| Download URL | ccviewer-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ebe05f54be62f9a70a2a97c94ee150b544725c9ee20508983611d75aff6ead7
|
|
BLAKE2b-256 checksum How to use checksums |
f7cd77ca4d3f4d07b2a2e7ac16198598263358aa0ca68f8b247a2768349ece7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.5
|