supercompact

skill
Security Audit
Fail
Health Warn
  • License — License: MIT
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Low visibility — Only 6 GitHub stars
Code Fail
  • rm -rf — Recursive force deletion command in scripts/check.sh
  • exec() — Shell command execution in src/cli.ts
  • exec() — Shell command execution in src/estimate.ts
Permissions Pass
  • Permissions — No dangerous permissions requested

No AI report is available for this listing yet.

SUMMARY

Cut up to 95% of tokens from Claude Code sessions without losing conversation history

README.md

npx supercompact measure running against 3289 real Claude Code sessions

npm version checks node 18 and up zero runtime dependencies MIT license

Up to 95% of the tokens in a heavy Claude Code session are tool traffic. supercompact strips that traffic out of the transcript on disk and gives you back the context window.

Every human message stays. Every assistant response stays. There is no model summarising your conversation and no loss of detail. You keep everything you agreed on, lose the machine's scratch work, and resume the session right where you left off.

Run this first. It reads your local sessions, calculates the token split across your history, and writes nothing:

npx supercompact measure
  3289 sessions, 365.5M tokens of context

  removed                   229.3M    63%  ████████████████··········
  starting context          112.3M    31%  ████████··················
  kept verbatim              24.0M     7%  ██························

  removed is tool calls and their results.
  starting context is your MCP tools, skills, CLAUDE.md files and so on.
  kept verbatim is every message you and Claude sent.

  your last 3 sessions

  session                                    now     after  starting  removed
  a4abe3a1-d4e9-4c99-823d-2d7d947564ce      274k       87k       58k      68%
  a8feeb50-76ad-424d-b150-df1e9185373d      998k      613k       49k      39%
  0f729543-99e5-4e56-8d31-ef3bcd0a2b47      563k      179k       51k      68%

  after is what the session weighs once it has been supercompacted.

  Your newest session starts with 58k already loaded. (You should fix this btw)

  436 of your sessions passed 200k tokens. The middle one drops by 87%.
  Your heaviest session held 1.0M tokens. 3k of it was the two of you talking.

  Context sizes are the numbers the API reported on each turn, not an estimate.
  The keep options hold some tool results back, and the preview prices them.

  Try it on this machine:  npx supercompact --preview

Never throw away a session

Tool traffic is almost everything in a Claude Code transcript. Files read, shell commands, test runs, and build logs account for up to 95 percent of the variable tokens in a working session. The actual conversation is a fraction of the file.

When a session gets heavy, the standard move is to abandon it and start over. You throw away the history, re-explain the architecture from scratch, and waste time catching the agent back up.

I built this so sessions never have to die. When you strip the tool noise, the session stops being disposable. You keep the agreements, the architectural decisions, and the conclusions the agent reached. The evidence is gone, but the context stays.

How this differs from /compact

Claude Code has a built-in /compact command. That command sends your conversation to a model and asks for a summary. The original wording is replaced with a paraphrase, and detail is lost.

supercompact does not use a model. It executes a direct rewrite of the JSONL session file on disk. Every human message and every assistant response stays character for character.

Usage

Install globally or run it with npx.

npm install -g supercompact

By default, supercompact creates a new session file and leaves your original transcript untouched:

supercompact
kept 724 messages from you and 774 from Claude
  was  3.4 MB, 233 tool calls
  now  1.3 MB, about 180k tokens

  new session  1f4df052-7cea-4af3-97fc-e990d7dd707c
  resume it    cd '/Users/you/dev/agents' && claude --resume 1f4df052-7cea-4af3-97fc-e990d7dd707c

  0f729543 was not touched.

To rewrite the current session under its existing ID and name:

supercompact --in-place

--in-place writes a full backup copy of the original file before modifying anything. It also leaves the trailing entries alone so an active turn continues working.

Claude Code loads transcripts when it starts up. It does not monitor the file for changes while running. Resume the session to load the stripped state:

claude --resume <id>

To check the token reduction without writing anything:

supercompact --preview

Reference

Commands

supercompact                 copy the current session, stripped
supercompact <id>            copy that session
supercompact --in-place      rewrite it, same id and name
supercompact --preview       token cost, writes nothing
supercompact measure         the split across all your sessions
supercompact list            recent sessions
supercompact help            show the help
supercompact version         print the version

Options

--no-tools         drop the calls without recording what ran
--keep-last N      keep the newest N messages unchanged
--keep-tools N     keep the newest N tool results
--unique-tools     with --keep-tools, repeated identical calls count once
--preview          print the token savings without writing any files
--in-place         rewrite the session file instead of making a copy
--json             output machine-readable JSON
--limit N          number of sessions to display with list
--project-dir P    look in project directory P instead of current directory

<id> is the first few characters of a session id, which list prints.

Inside Claude Code

supercompact includes a slash command and an agent skill under agent/.

If you installed globally:

mkdir -p ~/.claude/commands ~/.claude/skills
cp $(npm root -g)/supercompact/agent/commands/supercompact.md ~/.claude/commands/
cp -r $(npm root -g)/supercompact/agent/skills/supercompact ~/.claude/skills/

Or from a cloned repo:

mkdir -p ~/.claude/commands ~/.claude/skills
cp agent/commands/supercompact.md ~/.claude/commands/
cp -r agent/skills/supercompact ~/.claude/skills/

Run /supercompact inside a session to shrink the active transcript in place:

/supercompact [tools] [keep N] [preview]
  • tools is the default: the call names stay, the output goes.
  • keep 10 leaves the last 10 messages unchanged.
  • preview calculates the savings without writing anything.
  • copy writes a new session instead of modifying the active file.

The skill lets Claude Code measure its own transcript and strip tool traffic autonomously when asked.

Inside omp

omp gets its own /supercompact, written as an omp extension rather than a wrapper around the CLI. It does the same job on omp's session format, and the session switches to the reduced copy immediately, with no resume step. The original file is never written to.

mkdir -p ~/.omp/agent/extensions
cd ~/.omp/agent/extensions
curl -fsSLO https://raw.githubusercontent.com/SignedAdam/supercompact/main/agent/omp/extensions/supercompact.ts
curl -fsSLO https://raw.githubusercontent.com/SignedAdam/supercompact/main/agent/omp/extensions/recap.ts

Restart omp, then:

/supercompact [--keep=N] [--nolines] [--dry]
/recap [--keep=N] [--dry]
  • Tool calls, tool results and reasoning go. Each removed call stays as one line, such as bash: git fetch, unless you pass --nolines.
  • Assistant turns left next to each other are merged, and their token usage is added together.
  • --keep=3 is the default: the last 3 rounds keep their real tool calls.
  • Only the live branch is copied. Earlier compactions and /clear are respected.
  • --dry reports the before and after and changes nothing.
  • /recap runs the same reduction, then asks the model for two lists: what was done and what is still open.

recap.ts imports supercompact.ts, so keep both in the same folder. If omp can also see the Claude Code skill above (for example through ~/.agents/skills), add supercompact under skills.ignoredSkills in ~/.omp/agent/config.yml. Otherwise the agent may run the CLI instead of the slash command.

Details

  • Node.js 18 or higher. Tested on Node 18 and 22 in CI.
  • Zero runtime dependencies.
  • 60 tests run against throwaway session trees in CI on macOS and Ubuntu.
  • Windows is untested.
  • MIT license. Author Adam Albastov. Source code on GitHub.

Reviews (0)

No results found