Selective offline compaction for Claude Code sessions. You choose a split point - by topic or by count - and decant summarizes everything before it while keeping the rest intact. The output matches Claude Code's native format, so claude --resume just works.
Unlike the built-in compaction, which summarizes the entire session, decant lets you preserve recent context and only compress the old parts. Pick a topic ("keep everything about the API refactor") or a count ("keep the last 5 exchanges") and it handles the rest.
git clone https://github.com/TKasperczyk/decant.git
cd decant
python -m venv .venv
source .venv/bin/activate
pip install -e .decant list
decant list --project claude-memorydecant show <session-id>
decant show <session-id> --fullKeep everything from a topic onward, summarize everything before it:
decant compact <session-id> --topic "API refactor"
decant compact <session-id> --topic "the bug fix" --model sonnetKeep the last N user turns, summarize the rest:
decant compact <session-id> --last 5
decant compact <session-id> --last 10 --model opus--model haiku|sonnet|opus- which model to use for boundary finding and summarization (default: haiku)--strip- remove noise (progress ticks, thinking blocks, metadata, oversized tool output) before compaction--dry-run- preview what would happen without touching anything--no-backup- skip creating a.bakfile (not recommended)
Session IDs can be the full UUID, a prefix (minimum 6 chars), or a direct path to a .jsonl file.
- Parses the session JSONL and reconstructs the conversation tree via
parentUuidchains - Finds the boundary message, either by asking an LLM to locate a topic, or by counting user turns from the end
- Optionally strips noise (progress ticks, thinking blocks, metadata, oversized tool output)
- Sends the head section to the LLM for summarization
- Writes a summary record matching Claude Code's native format (
{type, summary, leafUuid}) - Sets the boundary message as the new tree root (
parentUuid: null) - Drops all head messages and their sidechains, keeps everything from the boundary forward
A timestamped backup is created before any modifications.
Decant needs Anthropic API access for the LLM calls. It checks these in order:
ANTHROPIC_API_KEYorOPENCODE_API_KEYenvironment variableANTHROPIC_AUTH_TOKENenvironment variable- Claude Code OAuth credentials (
~/.claude/.credentials.json)
If you're already authenticated with Claude Code, it just works. Decant reuses those credentials with automatic token refresh.
You're pouring the conversation through a filter. The clear, recent context comes through. The sediment stays behind as a summary.