AI product Open source

cc-prune

cc-prune is a Python command-line tool for surgical context recovery in Claude Code sessions. It removes already-processed tool output from a Claude transcript while preserving conversation text, reasoning, thinking blocks, transcript structure, and tool-call relationships; it does not summarize or truncate the retained content.

View repository Mentioned in 1 video ↓

Overview

The workflow measures actual API usage, inspects transcript byte buckets, optionally audits individual results, and clears selected buckets such as tool results, inputs, attachments, or orphaned command output. Clear operations use a character-length threshold, can protect a tail of recent records, create numbered snapshots, validate invariants, and support restoration. Its validation checks include unchanged record and UUID/parent-UUID chains, byte-identical thinking signatures, and matching tool-result and tool-use identifiers.

The tool operates on Claude Code JSONL transcripts under the user's .claude/projects directory and requires the session to be stopped before editing. It supports usage verification after pruning, snapshot listing and restoration, and density calculations based on measured token counts. The project states that the Claude Code transcript format is undocumented and version-sensitive, and that cleared results may need to be regenerated; it is distributed under the MIT license and requires Python 3.9 or later with no dependencies.

What cc-prune is used for

1 use taken from transcripts — each links to the moment in the video.

  • Removes already-processed tool output from Claude session transcripts without altering conversation or thinking blocks. It audits removals, creates numbered rollback snapshots, and verifies token counts against the API.

Videos mentioning cc-prune

1 in the library.