In development · no stable release yet GPLv3, royalty-free or commercial — your choice

rtok.

Token-reduction CLI for AI coding agents — hooks, an MCP server and an API proxy in one Rust binary.

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/pyrlyn/rtok/releases/latest/download/rtok-installer.sh | sh

Token savings are estimates from a chars-per-token heuristic until matched against provider usage. No live A/B cost reduction has been established yet.

Abstract 4 by 4 grid of glass cubes: cyan cubes kept, dim cubes thinned, dashed coral outlines cut.

See it run

rtok, in the terminal.

rtok — zsh
$ rtok agents install claude --dry-run
+ PreToolUse Bash rtok hook PreToolUse
+ PreToolUse Read rtok hook PreToolUse
+ PostToolUse * rtok hook PostToolUse
…
8 additions
$ rtok run -- cargo test
[rtok 7f3a91 · 412 lines · expand: rtok expand 7f3a91]
$ rtok graph index .
indexed 5 files · 551 rows · 0 skipped · 5 read
$ rtok plugins
id       enabled  surfaces
measure  on       cli,proxy
cmd      on       hook,cli
archive  on       proxy,mcp
…
Commands and output from the rtok README (dry-run output abridged with …).

Code graph over MCP

agent symbol index symbol callers impact outline explore
rtok graph index . builds a symbol index that agents query as symbol, callers, impact, outline and explore instead of a grep-and-read chain.

Reversible by design

Less context in. Nothing lost.

Context, compressed Illustrative

Δtok −0 / 240 tokens

  • kept
  • thinned
  • cut → archive

Scroll to compress, scroll back to expand. An illustration of the idea, not a measurement: in rtok a saving only counts when a Measurement row in the ledger records it, and archived payloads come back whole with rtok expand <id>.

Overview

What rtok does.

rtok reduces the context that AI coding agents must carry. It is one Rust binary with three surfaces: Claude Code hooks, an MCP server, and an API proxy. Each reduction is measured, and shortened payloads stay retrievable by id.

Ten methods, one process, one ledger. A saving that is not a row in that ledger does not exist — including rtok's own.

Features

Built for real workflows.

Install

Up and running in a minute.

Install

macOS (Apple silicon) and Linux x86-64, installed into ~/.cargo/bin:

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/pyrlyn/rtok/releases/latest/download/rtok-installer.sh | sh

With ketch, straight from the GitHub Release archives:

ketch install pyrlyn/rtok

Homebrew, npm or PyPI (the packages carry the same native binary):

brew install pyrlyn/tap/rtok
npm i -g rtok-cli
uv tool install rtok-cli

From source:

git clone https://github.com/pyrlyn/rtok && cd rtok
mise install
mise exec -- cargo install --path .
rtok --version

Usage

Install the Claude Code integration, preview first, then check it:

rtok agents install claude --dry-run
rtok agents install claude
rtok doctor

More examples below.

Usage examples

Real commands, straight from the docs.

Run a command through rtok and read the archived output back later:

rtok run -- cargo test
rtok expand 7f3a91 --lines 120-180
rtok expand 7f3a91 --grep "panicked" --context 3

Index a tree for the code graph and list the plugins:

rtok graph index .
rtok plugins
rtok config set plugins.toon.enabled false

Run the proxy and measure:

rtok proxy --mode passthrough
rtok stats --since 7d
rtok stats --save-baseline before-rtok
rtok stats --compare before-rtok

See where every setting came from:

rtok config show --sources

Links

License

You can use rtok under any of the following licenses, at your choice:

  1. GNU GPLv3 — free for open-source applications on any platform, including embedded systems.
  2. Royalty-free license — free for proprietary desktop, mobile and web applications, as long as you disclose that your application uses the project. Embedded systems are not covered.
  3. Commercial license — for proprietary applications, including embedded systems, without the attribution requirement.

Pricing

Pro is a placeholder

Free forever. Pro when you need it.

Free · open source

GPLv3, royalty-free or commercial — your choice

$0forever

  • Hooks, MCP server and API proxy
  • Lossless archive with rtok expand
  • Local stats and doctor
Install free

Try rtok today.

Free and open source. Star it, file an issue, or send a pull request.