Context compression

RTK alternative: try Caveman shrink and the proxy

Compare RTK and Caveman on one real command, check exit codes and byte-exact recovery, then swap the shell hook or add the proxy. Includes a one-step rollback.

By CavemanReviewed 4 min readRead Markdown ↗
The path to validate
  1. 01Save the RTK hook
  2. 02Shrink one command
  3. 03Check the bytes
  4. 04Swap, add or roll back

Start with one command, not your whole setup. Run a test suite you know through RTK and through Caveman, read both outputs, and decide from there. Many people end up keeping RTK for shell commands and adding the Caveman proxy for everything else, which this guide also covers. The comparison page explains the trade-offs.

This page means RTK, the Rust Token Killer. If rtk gain fails, you may have the unrelated crate with the same name.

Step 1: Find and save your RTK hook

Check what RTK installed and where:

terminal
rtk --version
rtk init --show

Note whether the hook is global (rtk init -g) or per project, and which agent it targets. Copy the agent's settings file somewhere safe so you can restore it exactly. For Claude Code the hook lives in its settings, and RTK also writes an RTK.md.

Pick a disposable workspace and one noisy command with a known result, ideally a test run with one failing test.

Step 2: Install Caveman

The CLI needs Node.js 22.13 or newer. setup --install downloads about 205 MB of signed Go binaries into ~/.caveman/bin/:

terminal
npm install -g @caveman-ai/cli
caveman setup --install

No account is needed for anything on this page.

Step 3: Run the same command through both

Save the raw output once, so both tools see the same bytes:

terminal
cargo test > baseline.txt 2>&1

Then run it through each tool:

terminal
rtk cargo test
caveman shrink -- cargo test

Swap cargo test for your own runner: pytest, npm test, go test. For an exact comparison on identical input, replay the saved file through Caveman:

terminal
caveman shrink --file baseline.txt

Read both views side by side. Each one must keep the failing test name, the assertion message and the file and line. A shorter output that buries the failure has failed the trial, whatever the token count says.

Caveman prints a footer with an inferred token estimate and a recovery handle, and sends a JSON report to stderr. RTK's counts are bytes / 4 estimates, so compare the direction of the numbers, not the exact values.

Step 4: Check the exit code and the bytes

Both tools must pass the exit code through, or an agent and a CI job will both be fooled:

terminal
caveman shrink -- cargo test; echo "exit: $?"

A failing suite has to print a non-zero exit.

Then check recovery. Use the ccr_ handle from the footer, with no query, since a query returns a filtered view:

terminal
caveman retrieve ccr_YOUR_HANDLE > recovered.txt
cmp baseline.txt recovered.txt

For a live run, capture the command's raw output yourself and compare against that. RTK keeps the full output of failed or truncated commands; rtk recall with the id it printed gets it back. Caveman keeps every shrunk output, including passing runs. Small outputs pass through unchanged and get no handle, which is correct.

Step 5: Choose your setup

Option A: replace RTK's hook with Caveman's. Remove RTK's hook first, then install Caveman's, so only one tool rewrites commands:

terminal
rtk init -g --uninstall
caveman hooks install

Restart the agent. Caveman's hook rewrites allow-listed, non-interactive commands with no pipes or redirects, on Claude Code, Codex, opencode, Gemini CLI, Hermes and OpenClaw. Check that your agent is on that list; RTK covers more tools.

Option B: keep RTK and add the proxy. Leave RTK's hook alone and run the agent through Caveman's local proxy, which compresses file reads, MCP results and other tool output in each request:

terminal
caveman wrap claude

That runs one session and writes nothing to your config. caveman claude makes it permanent. RTK filters first and Caveman sees RTK's output, so for those commands the original Caveman stores is RTK's filtered text.

Whichever you pick, run one real task before and after and compare finished results and provider-reported input tokens. The cost measurement guide has a format. Don't add the two tools' percentages together.

Roll back

For Option A, remove Caveman's hook and put RTK's back:

terminal
caveman hooks uninstall
rtk init -g

If you saved the agent's settings file in Step 1, you can also restore it directly. Restart the agent either way.

For Option B, stop launching through caveman wrap. If you ran caveman claude, caveman disable claude restores the agent's config. Leave Caveman installed while any open conversation still refers to Caveman handles.

Try it on work you know

Keep your agent. Add Caveman.

Install the local tools, run a task you can check, and compare the result.

Open the quickstart Explore comparisons ↗