Context compression

Caveman vs RTK (Rust Token Killer): which to use

RTK filters shell command output before your coding agent reads it. Caveman compresses every tool result and keeps originals recoverable. Where each one wins.

By CavemanReviewed 6 min readRead Markdown ↗
Where Caveman fits
  1. 01Agent runs a command
  2. 02Output gets filtered
  3. 03Original kept or not
  4. 04Model reads less

RTK and Caveman both shrink what a coding agent reads, from different places. RTK sits on the shell: a hook rewrites git status into rtk git status, and a filter that understands git, cargo or pytest cuts the output before the agent sees it. Caveman sits on the model request, so it also sees file reads, MCP results and API responses that never touched a terminal, and it stores every original it shortens. If your token waste is terminal output from a coding agent, RTK is excellent and may be all you need. If it comes from everywhere, or you need the exact bytes back later, Caveman covers more.

What is RTK?

RTK (Rust Token Killer) is an open source CLI proxy that filters command output before it reaches an AI agent's context. It is a single Rust binary, licensed Apache 2.0, from RTK AI Labs. On 30 September 2026 the repo had about 82,000 stars and the latest release was v0.50.0.

RTK knows over 100 commands and restructures their output per command:

  • git push becomes ok main, and git status is grouped by state.
  • cargo test, pytest, jest and go test show failures only, with passing tests collapsed to a count.
  • ls becomes a tree with file counts, and grep results are grouped by file.
  • docker logs and kubectl logs collapse repeated lines into counts.

rtk init -g installs a hook so the agent's shell commands are rewritten automatically. RTK supports 18 AI coding tools, including Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Cline and OpenCode. The project reports up to 90% less bash output on its noisiest commands and says overhead stays under 10 ms. rtk gain shows your own history and rtk discover finds commands you are not filtering yet.

RTK is also honest about its numbers. Its savings doc says RTK only changes the bytes a shell command returns, that this is one part of input tokens, and that token counts are a bytes / 4 estimate. The OSS tool is free with no account. A paid team product, RTK Pro, adds observability, security and governance.

How does Caveman compare?

Caveman has two pieces that overlap with RTK.

caveman shrink is the command-level piece. It runs a command, compresses what it printed and returns the command's own exit code. caveman hooks install routes the agent's shell commands through it automatically on Claude Code, Codex, opencode, Gemini CLI, Hermes and OpenClaw. The allow list covers version control, package managers, builds, tests, type checkers, linters, search, file listings and cloud CLIs. Every shrunk output is stored first, and the footer carries a handle for caveman retrieve.

Caveman Proxy is the request-level piece. caveman claude points Claude Code at a local proxy that compresses tool results in each model request, by format: JSON, logs, diffs, code, tables, search results and more. The agent gets a caveman_retrieve tool to pull originals back.

For your own agents and apps, Caveman Middleware does the same compression inside LangChain, the Vercel AI SDK, the OpenAI and Anthropic clients and other frameworks. RTK has no equivalent, since it works on shell commands.

Is RTK's filtering lossy?

Yes, by design, with a safety net for failures. When a command fails or its output is truncated, RTK saves the full unfiltered output in a local SQLite store and prints a handle like [full output: rtk recall 3f9c2a81d4e7]. A successful command's full output is not kept unless you turn on tee_on_success.

Caveman stores the original of every payload it shortens, successful or not. That matters when the detail you need later sat in a passing run: a deprecation warning, a timing line, the version a package manager resolved.

RTK vs Caveman: feature comparison

RTKCaveman
ApproachCommand-aware output filtersFormat-aware compression of tool results
What it seesShell commands the hook rewritesShell output via shrink, plus every tool result via the proxy
Built-in Read, Grep, Glob toolsNot covered by the hookCovered by the proxy
MCP and API resultsNoYes
Original keptOn failure or truncationAlways, before any lossy change
Command semanticsDeep: knows git, cargo, pytestGeneric terminal and log compressors
InstallOne binary, rtk init -gNode CLI plus about 205 MB of Go binaries
Sits in the model pathNoProxy does; shrink alone does not
Agents18Hooks on 6, proxy profiles for 10
Token countingbytes / 4 estimateo200k_base estimate, labelled inferred
LicenseApache 2.0MIT CLI, BSL engine (free for your own traffic)

Where does RTK win?

RTK wins on command knowledge. It knows git push succeeded, so it prints one line. A general terminal compressor sees text and has to guess what matters. For git, test runners, linters and cloud CLIs, RTK's per-command filters are hard to beat.

It wins on footprint. One Rust binary with no dependencies, nothing new in your model path. Plenty of teams have a rule against proxies between the agent and the provider, and RTK never needs one.

It wins on reach. Eighteen supported tools, including Cursor, Windsurf and Copilot, is wider coverage than Caveman's hook list. It runs natively on Windows. The Apache 2.0 license is simpler than Caveman's BSL engine terms.

Where does Caveman win?

Caveman wins when the tokens do not come from the shell. RTK's README notes that Claude Code's built-in Read, Grep and Glob tools bypass the Bash hook. In a typical coding session those tools, plus MCP servers, return a lot of the context. Caveman's proxy sees all of it because it works on the request.

It wins when you need originals back. Every shortened payload is recoverable, and the proxy's recovery store never evicts.

It also covers apps you build yourself, through middleware adapters for TypeScript and Python frameworks.

Can you use RTK and Caveman together?

Yes, with one rule: pick one command hook per agent. RTK's hook and caveman hooks install both rewrite shell commands, and two rewriters on the same command is a mess.

A clean split is RTK for shell commands and the Caveman proxy for everything else. The order is fixed by where each sits: RTK filters at the command, and Caveman sees what RTK emitted. Caveman can only store what it received, so for commands RTK already filtered, Caveman's recovered original is RTK's output. RTK's own recall covers failures there.

Do not add the savings up. If RTK already collapsed a test log, there is little left for Caveman to take out of the request.

How to decide

Run one real task three ways: direct, RTK, Caveman. Grade whether the task finished correctly, then compare provider-reported input tokens. Both tools' local numbers are estimates. There is no matched public benchmark between them, so this page gives no number. The measurement guide has a format, and the RTK switching guide walks through a one-command trial.

FAQ

Is RTK free? Yes. RTK is Apache 2.0 with no account or API key. RTK Pro is a separate paid product for teams.

Does RTK compress file reads? Only through shell commands or rtk read. Claude Code's built-in Read tool bypasses the hook.

Can I get RTK's full output back? For failed or truncated commands, yes, with rtk recall. Successful runs are only archived if you enable tee_on_success.

Does Caveman need an account? No. Local compression, shrink and the proxy work without one.

Sources

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 ↗