RTK: compress terminal output before it reaches Claude Code to save tokens
TL;DR
RTK (Rust Token Killer) is a CLI that compresses terminal command output before it enters an AI agent’s context. For Claude Code it installs a PreToolUse hook that automatically rewrites <code>git status</code> to <code>rtk git status</code>, and so on.
How it works
- Install RTK, then run
rtk init -gto add the Claude Code hook. - When the agent calls Bash, the hook rewrites the command to its RTK equivalent.
- The agent receives compressed output — still informative, minus the noise.
| Point | Details |
|---|---|
| Coverage | 100+ commands: git, gh, npm/pnpm, jest/vitest, tsc, pytest, ruff, go test, cargo, docker, kubectl, terraform… |
| Savings | Up to ~90% of bash output (per the project); that’s only part of input tokens, so total cost drops less |
| Limitation | Only intercepts Bash; built-in Read/Grep/Glob tools don’t pass through the hook |
| Licence | CLI is Apache-2.0; some engine/proxy components are BUSL-1.1 (an Apache-only rtk-oss edition exists) |
How to put it to work
- Best for repos with large test suites and long build logs, where command output dominates context.
- After installing, run
rtk --versionandrtk gainto confirm the right package (another “rtk” exists on crates.io). - Measure before/after with real usage rather than trusting headline numbers.
- Spot-check important commands: over-aggressive compression can hide error details the agent needs.
Links: rtk-ai/rtk README