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.

Copy install promptView on GitHub
Version 0.2.1. Eight features are built and tested on macOS. Token figures are estimates. If something breaks, open an issue with what you ran and what you saw.

Why use it

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:

Trimming these by hand means remembering every time. trim does it before Claude reads them.

What you get

FeatureWhat it deliversHow to use it
Half-size browser screenshotsAbout 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 capsA 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 cleanupLong 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 readsWhen 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 readsA 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 checkShows 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 reportWhat trim saved per feature (all time, 30 days, 7 days) and in your last 5 sessions.Run /trim:report. Logging off: TRIM_SAVINGS=off.
TipsShort 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

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 user

Inside Claude Code

/plugin marketplace add archid21/trim
/plugin install trim@trim

Then 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

CommandWhat it does
/trim:setupTurn trim tips on or off.
/trim:contextShow fixed-context tokens per part and what this project has not used in 90 days.
/trim:reportShow 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.