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 measured44.8%

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

rtk gain, snapshot 2026-10-14, 333,841 commands

RTK measured457.9M

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

rtk gain, snapshot 2026-10-14, global scope

STK estimate~37M

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 October 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.6% 156.0M n=61,873 Biggest total saver in the log
rtk rg measured20.8% 112.8M n=5,541  
rtk grep measured20.7% 76.8M n=79,679 The most frequent command in the log
rtk lint eslint measured97.0% 34.4M n=249  
rtk diff measured60.2% 11.0M n=685  
rtk ls -la measured66.8% 7.9M n=41  
caveman replies (terse prompting) estimate~50% ~192M 2,073 sessions Estimate: assumed 2x prose baseline, no before-and-after log. See caveman mode
All commands measured44.8% 457.9M n=333,841 Everything routed through the filter
0 25 50 75 100 1 10 100 1000 TIMES THE COMMAND RAN, LOG SCALE SAVED PERCENT read, n=61,873 rg, n=5,541 grep, n=79,679 lint, n=249 diff, n=685 ls, n=41 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 →

measured6.8%
Tokens saved on one large diff
measured1.8M
Absolute tokens saved

rtk gain, snapshot 2026-10-14, n=67

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 6.8 percent smaller: 1.8 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 five-minute 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 333,841 real commands in the snapshot dated 2026-10-14: routing shell output through the RTK filter reduced output tokens by 44.8 percent overall, 457.9 million tokens saved. Per-command savings range from 13.6 percent for file reads to 97.0 percent for one large lint eslint. 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: lint eslint saved 97.0 percent (n=249), ls -la saved 66.8 percent (n=41), diff saved 60.2 percent (n=685). High-frequency commands save a lower percentage but large absolute totals: file reads saved 13.6 percent, 156.0 million tokens, across 61,873 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.