Hypd AI automation agency logo

Hypd

AI Tools / Published June 15, 2026

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

claude codetokensoptimizationcliworkflowai toolsproductivity
Bottom line

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

prompt
git diff
, the raw output includes file headers, timestamps, line numbers, and formatting that Claude doesn't need to understand the change. Same for
prompt
grep
— surrounding context, file paths repeated on every line, separator characters. Same for
prompt
pytest
— full tracebacks, decorators, test IDs for passes.

None 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

prompt
rtk init -g
— full quit and reopen, not just a new chat. The hook registers at process start.

Then confirm it's intercepting:

bash
rtk gain

You'll see something like:

prompt
Session: 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:

OperationRawrtkSavings
ls / tree2,000400-80%
cat / read40,00012,000-70%
grep / rg16,0003,200-80%
git status3,000600-80%
git diff10,0002,500-75%
git log2,500500-80%
git add/commit/push1,600120-92%
cargo test / npm test25,0002,500-90%
pytest8,000800-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:

prompt
git diff
becomes
prompt
rtk git diff
. The proxy runs the command, strips the noise, and returns the compressed result to Claude's context.

From 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:

  • prompt
    git diff
    — removes redundant headers and whitespace-only lines, keeps diff hunks
  • prompt
    grep
    — removes file path repetition and separator lines, keeps match content and line numbers
  • Test runners — removes passing test output, keeps failures, summaries, and error tracebacks

The

prompt
-g
flag installs the hook globally — every Claude Code session from any folder uses it automatically.

Frequently 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.