Cut Claude Code Shell Tokens by 80% With One Install Command
A Rust CLI proxy that intercepts every shell command Claude Code runs and returns the same information in 75-90% fewer tokens — same output, massively smaller context window pressure.
Last updated: June 15, 2026
A Rust CLI proxy that intercepts every shell command Claude Code runs and returns the same information in 75-90% fewer tokens — same output, massively smaller context window pressure.
This guide is reviewed for clarity, service accuracy, and AI-search readability. The next quarterly content review is tracked internally before unsupported metrics or client proof are added.
Why Claude Code burns tokens on shell output
When Claude Code runs
git diffgreppytestNone of that noise helps Claude reason better. It fills the context window with tokens that cost money and push useful content out of scope.
Install and verify
bash# Install the proxy brew install rtk-ai/tap/rtk # Or with cargo cargo install rtk # Hook it into every Claude Code session globally rtk init -g
Restart Claude Code fully after
rtk init -gThen confirm it's intercepting:
bashrtk gain
You'll see something like:
promptSession: 12 commands intercepted Tokens raw: 8,420 Tokens delivered: 1,650 Saved: 6,770 (-80%)
What savings look like per command
Token counts from a 30-minute Claude Code session on a typical TypeScript/Rust project:
| Operation | Raw | rtk | Savings |
|---|---|---|---|
| ls / tree | 2,000 | 400 | -80% |
| cat / read | 40,000 | 12,000 | -70% |
| grep / rg | 16,000 | 3,200 | -80% |
| git status | 3,000 | 600 | -80% |
| git diff | 10,000 | 2,500 | -75% |
| git log | 2,500 | 500 | -80% |
| git add/commit/push | 1,600 | 120 | -92% |
| cargo test / npm test | 25,000 | 2,500 | -90% |
| pytest | 8,000 | 800 | -90% |
| Total | ~118,000 | ~23,900 | -80% |
How it works
The proxy sits between Claude Code and your shell as a hook. When Claude Code calls the Bash tool, the hook rewrites the invocation to route through the proxy:
git diffrtk git diffFrom Claude's perspective, nothing changes — it gets the same information. From the token counter, the output is 75-90% smaller.
What gets stripped
The proxy applies command-specific filters:
- — removes redundant headers and whitespace-only lines, keeps diff hunksprompt
git diff - — removes file path repetition and separator lines, keeps match content and line numbersprompt
grep - Test runners — removes passing test output, keeps failures, summaries, and error tracebacks
The
-gFrequently asked questions
Does the proxy ever drop information Claude actually needs? The filters are conservative — they strip formatting, repetition, and passing-test noise, not content. If something looks like signal (error messages, diff content, search matches), it stays.
Does this affect my own terminal sessions? No. The proxy only intercepts commands running through Claude Code's Bash tool. Your own terminal sessions are unaffected.
What's the difference between this and just reading less output? Reading less output requires knowing in advance what to skip. The proxy is automatic and command-aware — it knows passing tests are noise for pytest, and index lines are noise for git diff. Set-and-forget optimization that runs on every shell command without changing how you work.
