Skip to content
Documentation

Documentation

rtok is one Rust binary that reduces the tokens an AI coding agent burns. Every token-reduction method is a plugin behind a single trait, and three surfaces reach those plugins:

SurfaceEntry point
Claude Code hooksrtok hook <event> — stdin JSON in, stdout JSON out
MCP serverrtok mcpread, search, tree, expand, mem_*, graph tools
API proxyrtok proxyANTHROPIC_BASE_URL / OPENAI_BASE_URL hop
Status: P0 scaffold done. Config, store, plugin registry, estimator, hook types and CI are in place. No token has been saved yet — by design, measurement comes first. Nothing in the repo has produced a measured saving; the first number lands in P1.

Start here

Why it exists

A typical Claude Code setup stacks several tools that each compress Bash output, cache reads, and inject context at session start — each claiming 60–95 % savings that nobody measures end to end. Measured, that stack saves 3–40 % and costs roughly 3 K injected tokens per turn.

rtok replaces the stack with one binary that runs as one hook per event, serves five MCP tools instead of seventy-eight, sits as one proxy hop that records real usage, and keeps one measurement table so rtok stats can say what actually changed.

Every plugin is written from scratch in this repo. rtok never runs, links, or reads the tools it replaces.