savetokens.tips
STK Session Token Killer is open source: one binary that hooks Claude Code and Codex, clamping oversized file reads to a short outline. github.com/ryanportfolio/STK →

Token-saving techniques for AI coding agents

Token-saving techniques for AI coding agents are the habits and tools that shrink how much the model reads and writes, without losing anything it needs.

My sessions have saved:

RTK measured49.6%

of output tokens removed across every command routed through the filter.

rtk gain, snapshot 2026-11-29, 689,893 commands

RTK measured993.4M

tokens saved in total by filtering command output before the agent reads it.

rtk gain, snapshot 2026-11-29, global scope

STK estimate~65M

tokens kept out of context by STK, a hook that clamps oversized file reads.

stk gain upper bound (bytes avoided / 4, net unmeasured), as of November 2026

STK · Session Token Killer →

Practical guide: daily habits, caveman mode for shorter replies, RTK, and copy-paste rules for your agent.

The measurements

Every percentage below is measured in production.

CommandOutput tokens savedTotal savedSampleNotes
rtk read measured13.1% 480.3M n=120,889 Biggest total saver in the log
rtk grep measured20.8% 238.2M n=179,452 The most frequent command in the log
rtk rg measured17.4% 81.1M n=6,204  
rtk ls -la measured67.8% 36.8M n=152  
rtk diff measured63.4% 17.2M n=1,435  
rtk git show measured99.2% 3.7M n=2 Small sample dominated by one run; read as a single sample, not an average
caveman replies (terse prompting) estimate~50% ~104M 875 sessions Estimate: assumed 2x prose baseline, no before-and-after log. See caveman mode
All commands measured49.6% 993.4M n=689,893 Everything routed through the filter
0 25 50 75 100 1 10 100 1000 TIMES THE COMMAND RAN, LOG SCALE SAVED PERCENT read, n=120,889 grep, n=179,452 rg, n=6,204 ls, n=152 diff, n=1,435 show, n=2 estimate ~50, no measured frequency estimate ~50

Two clusters, and the gap between them is the finding: structural commands (diff, log, pull, test runs) filter down 90 to 100 percent, while content commands (file reads, grep) sit near 23 to 25 percent. Bigger dots mean more runs behind the number; the dashed line is the estimate and holds no position on the run-count axis.

How output filtering works

A proxy called RTK sits between the agent and the shell. The command runs normally; RTK condenses the raw output before the agent reads it, and logs both token counts. That pair of counts is where every green number on this page comes from.

git diff
raw output
→ rtk
filter
→ compact summary
to the agent

The summary keeps what a reviewer actually uses:

  • which files changed and by how much
  • the shape of the change, with the parts that need review
  • failing tests and error lines, quoted exactly

Compressing text before it reaches the model saves tokens without losing meaning: Jiang et al., LLMLingua compress prompts by up to 20x with little loss in performance. RTK applies the same principle to command output instead of prompts.

RTK repository on GitHub: CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies.

rtk-ai/rtk on GitHub: the open-source filter behind every measured number on this page →

measured95.7%
Tokens saved on one large diff
measured1.9M
Absolute tokens saved

rtk gain, snapshot 2026-11-29, n=2

A full git diff of a large change can send millions of characters to the model, most of which the agent never reads line by line. Filtered, the same diff came back 95.7 percent smaller: 1.9 million tokens the agent never had to read.

→ the practical guide: daily habits, caveman mode, RTK setup, copy-paste rules for your agent # everything measured on this page, turned into steps you can run today

Techniques at a glance

TechniqueStatusWhere it is covered
Filter command output through a proxy (RTK) In use, measured This page, table above
Caveman mode: compressed agent replies In use, estimate only Guide, caveman mode
Session hygiene: clear, compact, fresh sessions In use Guide, the basics
Model routing and subagent discipline In use Guide, advanced
Working inside the cache window In use Guide, cache window
Pasting whole files into the prompt Not recommended Superseded by scoped reads; a pasted file gets reread every turn

Frequently asked questions

Q1

How much does filtering command output reduce token usage?

Measured across 689,893 real commands in the snapshot dated 2026-11-29: routing shell output through the RTK filter reduced output tokens by 49.6 percent overall, 993.4 million tokens saved. Per-command savings range from 13.1 percent for file reads to 99.2 percent for one large git show. Every number's sample count and source is in the table above.

Q2

What is the difference between a measured number and an estimate?

A measured number has a real before-and-after: raw output tokens versus filtered output tokens, logged per command.

An estimate has no such log, so it prints gray, deliberately coarse, with a leading tilde, and never in the green reserved for measured numbers.

Q3

Which commands save the most tokens?

Commands with large raw output filter best: git show saved 99.2 percent (n=2), ls -la saved 67.8 percent (n=152), diff saved 63.4 percent (n=1435). Figures with n at or below 3 are single observations, not distributions. High-frequency commands save a lower percentage but large absolute totals: file reads saved 13.1 percent, 480.3 million tokens, across 120,889 runs.

Q4

Does savetokens.tips apply to both Claude Code and Codex?

Yes. Every technique on this site applies to both Claude Code and Codex. The filter sits between the agent and the shell, so it works the same regardless of which agent runs the command.