Cut what Claude reads.
trim is a free Claude Code plugin. It makes what Claude reads smaller (screenshots, command output, connector results, repeat file reads and big image files) and keeps the full version one Read away. It also shows what fills your fixed context and what trim has saved you.
Why use it
- Smaller reads, nothing lost. When trim shortens a result, it saves the full copy to a file and names the path in the result. Claude opens it only when it needs the part trim left out.
- Tokens are your usage. Fewer tokens per request means a longer session on a subscription, and a smaller bill on an API key.
- Local scripts only. trim is hooks and skills that run Python on your machine. No extra model calls, no background process, no network.
- One off switch per feature, and a report of what each one saved.
The problem: most of what Claude reads is not needed
Everything Claude reads lands in the context in full, and is re-sent with every later request until a compact. Five common cases:
- A screenshot costs about 673 tokens at full size. Half size is about 168, and is enough for most pages.
- A failing test run prints hundreds of passing lines. Claude needs the failures, the summary and the last lines.
- A connector result can carry base64 images, empty fields and the same log line 30 times.
- A big image file read from disk costs the same as a full-size screenshot. A 1,600 × 1,200 photo is about 2,560 tokens, and a 1,000 px copy is about 1,000.
- A file read twice with nothing changed puts the same text in the context again.
Trimming these by hand means remembering every time. trim does it before Claude reads them.
What you get
| Feature | What it delivers | How to use it |
|---|---|---|
| Half-size browser screenshots | About 75% fewer tokens per screenshot in the desktop app's built-in browser. Clicks still land. | Automatic. Claude can ask for full size with scale: 1. Off: TRIM_BROWSER_SCALE=off. |
| Command output caps | A long test or build run comes back with every failure, every summary line and the last 40 lines. About 80% fewer tokens in one demo (632 lines to 100). Error lines from tsc, npm, git, ESLint and make are kept too, and runs of progress or pass lines become one count line. Exit codes are kept. | Automatic for simple commands (pytest, unittest, jest, npm test, cargo, go, make, tsc and others). Commands with && or | are left alone. Off: TRIM_OUTPUT_CAP=off. |
| Connector result cleanup | Long base64 data, empty JSON fields, repeated lines and runs of progress or pass lines are removed from connector (MCP) results. One demo: 7,595 to 190 characters. Images are left alone. | Automatic for results over 2,000 characters that shrink at least 10%. Off: TRIM_TOOL_CLEANUP=off. |
| Smaller image reads | When Claude reads a big .png or .jpg file (long edge over 1,250 px), it gets a copy at 1,000 px instead. Your file is never changed. Saves about 2,000 tokens on a phone-sized screenshot (estimate). | Automatic. Small text can blur at 1,000 px. Skipped if your settings deny or ask for any Read. Needs sips (macOS) or ImageMagick. Off: TRIM_IMAGE_SHRINK=off. |
| Repeat reads | A second Read of an unchanged file returns a pointer to the earlier text instead of the text again. | Automatic. A third Read goes through, and so does any Read after a compact or clear. Off: TRIM_REPEAT_READS=off. |
| Fixed context check | Shows what fills your fixed context, in tokens per part, and lists the agent types, connectors and plugins this project has not used in 90 days, with where to turn each one off. Changes nothing. | Run /trim:context. |
| Savings report | What trim saved per feature (all time, 30 days, 7 days) and in your last 5 sessions. | Run /trim:report. Logging off: TRIM_SAVINGS=off. |
| Tips | Short session-start rules you choose, such as reading pages as text before taking screenshots. About 59 tokens per session. | Run /trim:setup. Applies from the next session. Untick to remove. |
Every feature, how it works and what it gives you: docs/FEATURES.md.
Better with rightsize
trim works alone. If you also use rightsize, /rightsize report adds a Trim savings section, read from trim's log, with the tokens trim saved per feature. whatsnext keeps your plan and a resume note between sessions. rightsize and whatsnext cut what a session costs and keep it resumable. trim cuts what goes into it.
Privacy and files
- Nothing leaves your machine. The hooks are local Python scripts that make no network calls.
- Everything is under
~/.claude/trim/(move it withTRIM_HOME). - Full copies of shortened results are saved with owner-only permissions and deleted after 7 days.
- The savings log cleans itself. Past 100 KB, lines older than 90 days are folded into daily totals, and it is capped at 1 MB.
What is not built yet
Pasted and attached images, and large pastes, cannot be shrunk by a plugin hook. Only image files that Claude opens with Read are shrunk. Web page stripping and Haiku notes for large results were considered and not built, because they saved too little. A cap on subagent report length is in testing and is off unless you set TRIM_SUBAGENT_CAP=on. In auto mode, Claude Code then adds a "safety classifier was unavailable" warning to each capped report.
Ask Claude to install it
Paste this into any Claude Code session.
Install the trim plugin from GitHub for me. Run these two commands in the terminal:
1. claude plugin marketplace add archid21/trim
2. claude plugin install trim@trim --scope user
Tell me if either one fails and why. When both succeed, tell me to start a new session and type /trim:context to check that it works.Claude asks your permission before it runs each command. When it is done, start a new session and type /trim:context.
Install in about a minute
You need Python 3.9 or later (standard library only) and Claude Code with a subscription (Pro, Max, Ultra) or an API key. Smaller image reads need sips (macOS) or ImageMagick.
In the terminal
claude plugin marketplace add archid21/trim
claude plugin install trim@trim --scope userInside Claude Code
/plugin marketplace add archid21/trim
/plugin install trim@trimThen start a new Claude Code session. Sessions that were already open don't load it. Type /trim:setup to choose tips, or /trim:report after a few sessions to see what it saved.
Commands
| Command | What it does |
|---|---|
/trim:setup | Turn trim tips on or off. |
/trim:context | Show fixed-context tokens per part and what this project has not used in 90 days. |
/trim:report | Show what trim saved. |
FAQ
Does trim change what Claude can do?
No. Claude can open any full copy, ask for a full-size screenshot or read a file again. trim only changes what comes back by default.
Does it send my data anywhere?
No. The hooks are local Python scripts that make no network calls. Its files stay on your machine.
How do I turn it off?
Set a feature's switch (listed in the table above) to off in your environment, or disable the plugin with claude plugin disable trim.
How accurate are the savings numbers?
They are estimates: characters divided by 2.7. The report marks a fixed per-use figure, such as a half-size screenshot, as "assumed". The demo figures above come from single runs, so yours will differ.
Does it work on Windows?
Not tested. It is tested on macOS.
Work in progress
trim is at version 0.2.1. It changes what Claude reads by default, and its token figures are estimates. Savings are not guaranteed. Report problems on GitHub, or email hello@aivalue.blog. This is an independent project, not made or endorsed by Anthropic.