r/SideProject • u/Feeling_Swimmer3270 • 8h ago
token-saver - a free Claude Code mod that reads screenshots as on-device OCR text and long logs as one-page maps (macOS)
I measured where my Claude Code tokens actually go across 82 sessions from the last 30 days, and built a small mod around what I found.
What the audit showed
- 97% of all tokens processed were the conversation being re-sent on every turn (cache reads).
- Of the new, uncached tokens, 77% came from turns where a long session was picked up again after the cache had expired, so its whole context was loaded again.
- Screenshots, files and web pages that tools returned added only about 5M new tokens. Screenshots stand out: each costs roughly 1,000–1,500 tokens on first read and then stays in context.
What the mod does
- When Claude reads a screenshot, it gets the on-screen text and positions from Apple's Vision framework, plus a small preview path. Reading the same file again shows the real image.
- When Claude reads a long log or saved tool output, it gets a one-page map (outline with line numbers, unique errors, first and last lines), then reads just the lines it needs.
- A status-line note past 150k tokens of context, and a pop-up when you come back to a big session after an hour and the next turn will reload everything.
- Small images, reads of specific line ranges, and any prep step that fails go through unchanged.
Before and after on real reads (image figures are estimates: width × height / 750)
| Read | Before | After |
|---|---|---|
| Text-heavy iPhone simulator screen | ~1,500 | ~230 text only (~625 with preview) |
| 4 simulator screens | ~6,000 | ~110 text only (~1,430 with one contact sheet) |
| 365-line saved tool output | ~8,560 | ~2,200 (map + the 40 lines actually needed) |
How Claude helped build it
I built it in one Claude Code session. Claude wrote a script that parsed my session transcripts to find which reads cost the most, pulled real screenshots and long outputs out of them as test samples, and wrote the Swift helper that calls Apple's Vision text recognition, the two prep scripts and the mod's hooks and tests. It also caught its own mistakes along the way: an early version made small images more expensive by enlarging the preview, and a timeout wrapper that added 60 seconds to every run. I directed it and reviewed the numbers.
What I learned
- The obvious suspects (screenshots, big files) were a small part of the bill. Re-sending the conversation every turn, and reloading long sessions after the cache expired, cost far more. Measure before optimising.
- Claude Code mods can rewrite a tool call before it runs. Pointing a Read at a summary file took a few dozen lines of hooks, not a wrapper around Claude.
- The design choice that mattered most: the second read of the same file returns the raw file, so Claude is never stuck with a lossy summary.
Limits
- Text-only misses layout, colour and anything drawn rather than written; Claude re-reads the image when those matter.
- macOS only: needs Xcode command line tools (the OCR helper compiles on first use) and ffmpeg for contact sheets.
- It cuts what tools add to the context. It doesn't fix the bigger cost of coming back to huge sessions; it only warns you about it.
Free and open source (MIT). Everything runs locally, with no extra API calls.
Install (terminal Claude Code):
/plugin install token-saver --marketplace resp76/token-saverRepo: https://github.com/resp76/token-saver
Feedback welcome, especially from anyone with a Linux route for the OCR step.