Stop paying Claude to re‑read your whole conversation.
On every step, Claude Code sends everything said so far back to the model. tokentrim keeps that history small. On 135 real conversations that meant 75% less re-read and usage limits that lasted 4.0× longer.
$ git clone https://github.com/suncal/tokentrim && tokentrim/bin/tokentrim replayShows what tokentrim would have saved on your own past sessions. Installs nothing.
$ claude plugin marketplace add suncal/tokentrim && claude plugin install tokentrim@tokentrimAdds the hooks plus /tokentrim:replay, /tokentrim:dashboard and /tokentrim:share. The earlier-summarising window needs the full install.
$ git clone https://github.com/suncal/tokentrim && tokentrim/bin/tokentrim installEverything, including earlier summarising, where most of the saving comes from. Backs up your settings first; tokentrim uninstall undoes it exactly.
The author's own sessions. The replay shows you yours.
The hidden cost
Your limit isn't spent on new work. It's spent re-reading old work.
An agent loop re-sends the entire conversation on every step. A long session carrying 400k tokens pays for those 400k again on step 301. About 97% of the tokens Claude Code bills are this re-reading.
| Shrinking tool output only | tokentrim | |
|---|---|---|
| What it targets | Tool output size | The history re-read on every step |
| Saving on the same 135 conversations | 6.9% | 75% less re-read |
| Proof before you install | Usually a vendor benchmark | ✓ A replay of your own transcripts |
How it works
Measure, trim, prove it. In about a minute.
See where tokens went
tokentrim audit reads the transcripts Claude Code already keeps on your machine and shows which sessions and habits burn your limit.
Get your own number
tokentrim replay runs your past sessions through the rules before you install anything. You get your number, not ours.
Keep context small
tokentrim install adds a few Claude Code hooks and an earlier summarise point. It backs up your settings first, and uninstall undoes it exactly.
Compacts the conversation before it balloons. This is where most of the savings come from.
3 strengthsBrowser screenshots are taken at half scale, which costs a quarter of the tokens. Clicks still land in the right place.
¼ the tokensA whole-file read over 40 KB gets an outline first. Asking again lets the full read through.
losslessHead and tail kept, repeated lines collapsed, progress bars stripped. The full output is saved to disk.
losslessJSON minified, empty fields and base64 blobs dropped. Nothing in a list is ever removed.
full copy on diskTells you, not Claude, when a conversation is getting heavy and a fresh one would be cheaper.
0 tokensLive dashboard
A live dashboard that changes Claude Code for you.
Watch usage rise and fall minute by minute, with recommendations based on your own sessions. Each one has an Apply button. Switch a setting off and your own value comes back.
Opus while planning, Sonnet while doing the work (Claude Code's opusplan), or Sonnet for everything. One click.
new sessionsExplore and Task sub-agents run on Sonnet or Haiku. Your main conversation keeps its model.
new sessionsMedium or low effort spends fewer thinking tokens on routine work.
new sessionsA dollar cap per day across every session. A note at 80%, and new prompts held once you pass it. Start a message with ++ to send it anyway.
next messageBack after the prompt cache expired? It tells you what your next message will re-write, and when /clear is cheaper.
next messageQuick chores like renames, formatting or git running on Opus get a short note that Sonnet does them for less.
next messageThe dashboard shows which Claude Code versions on your machine read each setting, so nothing silently does nothing.
Security & privacy
It sees every tool call. So it's built to be boring and safe.
tokentrim runs as Claude Code hooks. Here is exactly what stays on your machine, what leaves it, and how you stay in control.
Never leaves your machine
- Prompts, code and transcripts. Read locally from
~/.claudeto measure usage. Never uploaded. - Full tool output. Trimmed for Claude, with the complete copy kept on your disk.
- Your settings. Backed up before install and restored on uninstall.
- No network calls by default. Standard-library Python. The only exception is opt-in:
live --deploysends totals to your own Cloudflare page.
Sent only if you choose Pro
- License check: your key and a machine label, to Polar.
- Hosted dashboard: usage totals and project folder names. Never prompts or code.
- Slack: opt-in, weekly totals only, with a test message first.
- Payment: handled entirely by Polar. We never see your card.
Fails open
If a hook errors, Claude Code carries on as if tokentrim weren't there.
Instant kill switch
"enabled": false in its config turns every hook off at once.
Tested on every change
The full suite runs in CI on macOS and Linux, Python 3.9, 3.11 and 3.13.
Open to audit
Apache-2.0 source. Report issues privately; you get a reply within 3 days.
The honest numbers
Why we don't promise 90%.
Claude Code's own system prompt and tool list cost 40–60k tokens on every step, and no setting removes them. Anyone promising 90% across all your work is measuring one noisy command, or not measuring.
So tokentrim shows its working: a replay of real transcripts, every estimate labelled, and three strength settings with the trade-off spelled out.
- The trade-off is realSummarising sooner means Claude forgets detail sooner. The default, strong, behaves close to Claude Code's old 200k window. Balanced is gentler; max is cheapest.
- Cost drops less than tokensRe-reads are cheap per token and output isn't touched, so billed cost and limit burn fall about 55–70%, not 75%.
- Your number will differShort sessions re-read little, so they save little. That's why the replay comes first, before you install anything.
- Not affiliated with Anthropictokentrim uses Claude Code's public hooks and settings. It doesn't patch Claude Code or touch your account.
Pricing
The token cutting is free. Pro keeps the savings going.
Pro puts the live dashboard on any device with nothing to host, and keeps watch for you with a Monday report and budget alerts.
Free
Everything that cuts tokens. Open source.
- All hooks and 3 strength profiles
- Audit and replay on your sessions
- Live dashboard and one-click smart settings
- Daily budget guard, cold-cache alert, model advisor
- Shareable savings card
- Hosted dashboard on your phone
- Weekly digest and budget
Pro Lifetime
Pay once, keep it. Only for the first 500 buyers. After that, Pro is monthly only.
- Everything in Free
- Hosted live dashboard on any device: sign in with your key
- Change your settings from your phone
- Monday digest in plain English
- Weekly token budget, checked daily, alert at 80%
- Slack weekly totals (totals only)
- Up to 3 machines
- All future Pro updates
Pro Monthly
Same Pro features, billed monthly. Cancel any time.
- Everything in Free
- Hosted live dashboard on any device: sign in with your key
- Change your settings from your phone
- Monday digest in plain English
- Weekly token budget, checked daily, alert at 80%
- Slack weekly totals (totals only)
- Up to 3 machines
For teams
A shared dashboard with everyone's spend, savings and budgets is in the works. Want a teardown of where your team's Claude spend goes now, with a fix list? Ask for a paid audit.
tokentrim pro activate <key>
Does anything leave my machine?
No. The free tool reads transcripts Claude Code already stores locally and never sends them anywhere. Pro's license check sends only your key and a machine label. The hosted Pro dashboard receives totals and project folder names only, never prompts or code. Slack posting is opt-in and sends weekly totals only.
Plugin or full install: which should I use?
The plugin is one command and adds the hooks plus /tokentrim:replay, /tokentrim:dashboard and /tokentrim:share. A plugin can't set the compaction window, which is where most of the saving comes from, so also run tokentrim install from a clone if you want it. Having both is safe: the plugin's hooks stand down while the full install's hooks are active, so nothing runs twice.
Can it pick the best model for each message?
Not per message: Claude Code has no switch for that. Smart model uses Claude Code's own opusplan (Opus plans, Sonnet does the work), and pairs well with cheaper sub-agents, lower effort and the model advisor. Model changes apply to new sessions; /model in a session still wins.
I'm on a Pro or Max plan, not paying per token. Does this help?
Yes, and it's the main reason most people use it. Plan limits are spent on the same tokens, so re-reading less means hitting the 5-hour and weekly limits later. On the author's usage, limits lasted 4.0× longer.
Will Claude forget things?
It summarises earlier, so very old detail in a long conversation gets condensed sooner. The default profile behaves close to how Claude Code worked with a 200k window. If you notice it, switch to balanced with one command.
How do I undo it?
tokentrim uninstall removes exactly what install added. Your settings were backed up before install, your own hooks are left alone, and one config flag turns every hook off instantly. Remove the plugin with claude plugin uninstall tokentrim@tokentrim.
What do I need?
Claude Code and Python 3.9 or newer. No packages to install. It's tested on macOS and Linux. The Pro Monday digest schedules itself on macOS; elsewhere you can run tokentrim digest from your own scheduler.
How does the lifetime deal work?
$49 once for the first 500 buyers, with all future Pro updates. After that, Pro is $9 a month. Either way you get a license key by email that works on up to 3 machines; move it with tokentrim pro deactivate.
Find out what your conversations are costing you.
One command, about a minute, nothing installed. If the number is small, you've lost nothing.