savetokens.tips
STK Session Token Killer is open source: a Claude Code hook that clamps 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 measured66.9%

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

rtk gain, snapshot 2026-09-01, 153,029 commands

RTK measured189.7M

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

rtk gain, snapshot 2026-09-01, global scope

STK measuredLIVE

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

as of September 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: raw output tokens versus filtered output tokens, logged per command, snapshot 2026-09-01.

CommandOutput tokens savedTotal savedSampleNotes
rtk read measured17.3% 77.8M n=7,276 Biggest total saver in the log
rtk rg measured26.9% 37.3M n=1,969  
rtk lint eslint measured96.9% 34.1M n=214  
rtk grep measured24.1% 22.8M n=13,611 The most frequent command in the log
rtk git diff measured99.2% 5.6M n=3 Small sample dominated by one run; read as a single sample, not an average
rtk git log --all -p measured100.0% 2.0M n=1 Single observation
caveman replies (terse prompting) estimate~50% ~134M 1,710 sessions Estimate: assumed 2x prose baseline, no before-and-after log. See caveman mode
All commands measured66.9% 189.7M n=153,029 Everything routed through the filter
0 25 50 75 100 1 10 100 1000 TIMES THE COMMAND RAN, LOG SCALE SAVED PERCENT read, n=7,276 rg, n=1,969 lint, n=214 grep, n=13,611 diff, n=3 log, n=1 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
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 →

measured99.2%
Tokens saved on one large diff
measured5.6M
Absolute tokens saved

rtk gain, snapshot 2026-09-01, n=3

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 99.2 percent smaller: 5.6 million tokens the agent never had to read.

That figure pools three runs dominated by one huge diff, so read it as a strong signal, not a guaranteed rate. The habit it argues for: route any diff you would scroll past through the filter.

→ 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 153,029 real commands in the snapshot dated 2026-09-01: routing shell output through the RTK filter reduced output tokens by 66.9 percent overall, 189.7 million tokens saved. Per-command savings range from 17.3 percent for file reads to 99.2 percent for one large git diff. 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 diff saved 99.2 percent (n=3), lint eslint saved 96.9 percent (n=214), rg saved 26.9 percent (n=1969). 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 17.3 percent, 77.8 million tokens, across 7,276 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.

What sources support these numbers?

The percentages and command counts on this page come only from the dated rtk gain snapshot described above. The sources below establish how RTK works and the agents it serves; they do not replace or inflate the local measurements.

“rtk filters and compresses command outputs before they reach your LLM context.”

“Claude Code is an agentic coding tool that reads your codebase, edits files, runs commands, and integrates with your development tools.”

“Use Codex across ChatGPT, your editor, and the terminal, all connected by your ChatGPT account.”

Compressing text before it reaches the model saves tokens without losing meaning, a result established in the research: 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.