STANDBY

0TOKENS KEPT OUT

This counter is real and it is currently zero. It starts moving the first time the hook clamps a read.

CLAMPS0

DUP HITS0

BYTES AVOIDED0

EST. TOKENS0

SNAPSHOT

Get STK on GitHub ▸

github.com/ryanportfolio/STK · MIT · one Rust binary, no runtime deps · install ↓

UPPER BOUND, NOT A NET. Full methodology ↓

A Claude Code hook that stops oversized file reads from flooding your context.

One Rust binary, wired in as a PreToolUse hook on the native Read tool. Big file → the agent gets a ~2 KB line-numbered outline instead of the full dump, plus exact instructions to fetch any range with Read(offset, limit). Small files, scoped reads, binaries, anything STK can't analyze: all pass through untouched.

We looked before we built

Mined 250+ Claude Code sessions (27.8 MB of tool output across 24,597 tool results) to find where the tokens actually go:

38.6%

of ALL tool-result bytes sat in oversized (>8 KB) results: 10.7 MB carried by just 590 results. 2.4% of results held 38.6% of the bytes.

85%

of that oversized mass came from ONE source: the native Read tool. 9.1 MB, vs 1.0 MB from Bash. RTK's shell hook can never see it. This number is the whole reason STK exists.

The narrowest tool that closes the gap

Decision in under 10 ms, in order. The first rule that matches wins. Everything STK doesn't understand passes through. It never blocks a read it can't analyze.

  1. Read already has offset/limitALLOWnever fight a targeted read
  2. File missing / unreadableALLOWlet Read produce its own error
  3. Binary, image, PDF, notebookALLOWnothing to outline
  4. ≤ 16 KBALLOWsmall files were never the problem
  5. Same file, same hash, this sessionDENYone-line “unchanged” note, not a 50 KB re-dump
  6. Big file, first sightDENYoutline instead (the payload below)

What the model sees instead of 84 KB of source:

stk clamp: src/pipeline.ts — 84.3 KB, 2140 lines (threshold 16 KB).
Outline below; fetch only what you need with Read(file_path, offset, limit).

   1  import { … } (12 import lines)
  40  export interface Config
  92  export class Pipeline
 118    constructor(opts: PipelineOpts)
 143    async run(input: Stream): Promise<Result>
 402    private flush()
 ...
2101  export function main()

Re-read a symbol's body: Read with offset=<line>, limit=<span>.

The shape of an 84 KB file for ~2 KB. Nothing is lost: the agent re-reads any range on demand.

Two meters, two streams

STK is the sibling of RTK (Rust Token Killer). Together they cover the two fattest input streams an agent pays for.

RTK versus STK
RTKSTK
ScopeShell command outputRead tool output
UnitPer commandPer session
MechanismFilter & compressOutline & clamp
LossLossless (strips decor)Lossy but recoverable (re-read on demand)

COMMANDS97,474

TOKENS SAVED19.9M

REDUCTION77.9%

RTK's own accounting, from rtk gain on the author's machine, reported here as-is. Not measured by us.

How the meter is wired

  1. Source of truth: an append-only JSONL at %LOCALAPPDATA%\stk\stats.jsonl. One record per clamp or dedup hit, with file_bytes and sent_bytes.
  2. Aggregation: stk gain --json emits totals plus a per-day series. bytes_avoided = file_bytes − outline_bytes per clamp. est_tokens = bytes ÷ 4. The divisor is an estimate and we say so.
  3. Publication: a scheduled job on the author's machine runs stk gain --json and commits the snapshot into this repo. This page renders that file. No server, no credentials. “Live” means daily granularity, the granularity the data has.
  4. The caveat, again: after a clamp, follow-up range reads cost tokens the hook can't see. The counter is an upper bound. Under-claiming is the brand.
  5. Everything is auditable: the decision matrix, outline formats, store layout, and fail-open contract live in SPEC.md, in the same repo as this page.

Single binary, no runtime deps

cargo install --path .   # build the binary
stk init                 # prints the PreToolUse snippet

stk init prints the exact hook block to paste into ~/.claude/settings.json. STK never edits your settings for you. You paste it, so you stay in control of what runs in your agent. Verify with echo {} | stk hook claude: prints nothing, exits 0.

Tunables (all optional): clamp_threshold · outline_max_lines · dedup · exclude globs. Details in the README.