AI column

Coding@donghyeok99Staff

RTK: a CLI that shrinks the command output your agent reads

A 71-line cargo test run reaches the agent as 11 lines: a Rust binary that filters command output first

The 71 lines cargo test prints pass through rtk and come out as 11: the failing test and the summary.
The 71 lines cargo test prints pass through rtk and come out as 11: the failing test and the summary.
Who
Patrick Szymkowiak and a core team (rtk-ai), for developers who want their coding agent to spend fewer tokens.
When
The repository opened in January 2026; development builds were still landing on 12 November 2026 (dev-1.2.1-rc.637).
Where
Claude Code, Codex, Cursor, Gemini CLI and 14 more tools, on your own macOS, Linux, Windows or WSL machine.

What was hard

Ask an agent to run the tests and hundreds of passing lines and progress bars go into the conversation with them. The same happens with git status and build logs, so the agent reads a whole wall of output each time to find the one failure that matters.

What it does about it

RTK sits between the agent and the shell and reduces command output before it is read. A hook runs rtk git status in place of git status, and a filter written for each command keeps what is needed, such as failing tests or changed files. If a filter fails you get the raw output and the exit code is passed through, and output that was cut says where the full version is.

A terminal: register the hook, ask for the tests, check rtk gain
A terminal: register the hook, ask for the tests, check rtk gain
cargo test on a 48-test crate: 71 raw lines, 11 lines through rtk
cargo test on a 48-test crate: 71 raw lines, 11 lines through rtk

What people made with it

dev.toJangwook Kim2026-05-22

Installed RTK on their own blog repository and measured six commands; the average reduction they report is 60.6%.

60.6% average across 6 commands.
quesma.comQuesma2026-09-11

Ran Terminal-Bench 2.1 with and without RTK and compared the real bill: cost did not fall as much as output did, moving 5% down or up depending on the model.

With RTK, costs fell by 5% for Fable and rose by 5% for DeepSeek.

How it runs inside

  1. 1

    You → rtk

    rtk init -gRegisters the hook in Claude Code's settings, once.src/hooks/init/claude.rs
  2. 2

    Claude Code → rtk-rewrite.sh hook

    The shell command it is about to runJust before the agent runs a command, the hook receives the command string.hooks/claude/rtk-rewrite.sh
  3. 3

    rtk-rewrite.sh hook → rtk

    rtk rewrite "cargo test"One rule table on the Rust side decides whether there is a swap. If not, the command passes through.src/discover/registry.rs
  4. 4

    rtk → Claude Code

    The reduced output of rtk cargo testIt runs the real command, then returns only the failing tests and the summary.src/cmds/rust/cargo_cmd.rs
  5. 5

    rtk → Local record (SQLite)

    Raw size and filtered sizeHow much each command shrank is written down on your machine.src/core/tracking.rs
  6. 6

    Local record (SQLite) → rtk gain dashboard

    rtk gainReads that record back as savings and percentages per command.src/analytics/gain.rs

What goes in, what comes out

cargo test (48 tests, 71 raw lines)11 lines: the failing test's panic, assertion and location, and the summary
git status, 40 linesA 3-line summary
git logOne line per commit

Is it for you

Good for

  • Projects where the agent runs tests and builds often and the conversation fills up fast
  • Using several coding agents and wanting one way to trim all of them
  • Wanting a number for how much each command shrank

Not for

  • Per the README, a 90% cut in command output is not a 90% cut in cost: command output is one part of the input tokens.
  • Token counts are estimated as bytes / 4, so percentages are reliable and absolute numbers approximate.
  • The hook rewrites shell commands only. Built-in tools such as Read, Grep and Glob pass through untouched by default.
  • The CLI is Apache-2.0; the pipeline engine and proxy are BUSL-1.1. Using it at work is free; reselling RTK as a product is not covered.

Reviewed by Devalley’s editor before publishing. How the column is made

Sign in to post, comment and like.Sign in

Report

Reason

Read the community rules