rtok documentation
Less context for your agent, every saving on record.
rtok reduces the context AI coding agents must carry. One Rust binary, three surfaces: Claude Code hooks, an MCP server, and an API proxy. Each reduction is measured; shortened payloads stay retrievable by id.
45 pages from pyrlyn/rtok/docs at cc732c3, in development
- Install
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/pyrlyn/rtok/releases/latest/download/rtok-installer.sh | sh - Configure
rtok config init - Inspect
rtok doctor - Wire in
rtok agents install claude --dry-run
How it works
From install to first result.
-
Install one binary
Prebuilt binaries for macOS (Apple silicon) and Linux x86-64. The installer puts
rtokandrtok-updatein~/.cargo/bin;ketch install pyrlyn/rtokworks too.ketch install pyrlyn/rtok -
Price what you already run
rtok doctoris worth running before you install anything: it prices the hooks and MCP servers you already have, including description tokens re-sent on every turn.rtok doctor -
Wire it into your agent
--dry-runprints the hook entries and touches nothing. Install backs up every file it writes, anduninstalltakes it out again.rtok agents install claude -
Expand anything that was cut
Lossless by default: anything shortened is retrievable by id, and a saving that is not a
Measurementrow does not exist.rtok expand <id>
Four invariants
The rules every surface keeps.
- Fail open. A hook exits 0 in ≤ 10 ms even on error, with unmodified input.
- Lossless by default. Anything shortened is retrievable via
rtok expand <id>. - A saving that is not a
Measurementrow does not exist. - Injected context stays under budget and byte-stable, so it never busts the prompt cache.
rtok config init # writes ~/.rtok/config.toml
rtok plugins # id, enabled, surfaces
rtok doctor # inspect hooks, MCP servers, proxy chain
Paths into the docs
Pick where to go next.
-
Start2 pages
- Getting started rtok reduces the context AI coding agents must carry. One Rust binary, three surfaces: Claude Code hooks, an MCP server, and an API proxy. Each reduction is measured; shortened payloads stay retrievable by id.
- Configuration One file, ~/.rtok/config.toml, holds every setting rtok has. Every CLI flag is a config key, so anything you can pass on the command line you can also make permanent, and rtok config show --sources always tells you…
-
Guides5 pages
- Agents Every host rtok agents install <host> configures, per app, with what rtok writes into it and which rtok plugins then reach that app.
- Command rules rtok run (and rtok filter --stdin, and the PreToolUse Bash rewrite that calls rtok run) shortens command output with per-family rules before the model sees it.
- Prompt cache No — measured, not promised. rtok stats on this machine (2026-09-18) reports hit=97.5% — 5 620 803 600 cache-read tokens against 145 402 240 cache-creation and 667 038 uncached input tokens over 910 sessions — and the…
- LSP backend
- OpenTelemetry
-
Extend2 pages
- Writing a plugin A plugin implements one trait: Plugin, from the published rtok-plugin-sdk crate. That is true whether the plugin ships inside this repository or lives in someone else's (D25) — there is one contract and no in-tree…
- Plugin versions How rtok versions the plugin trees under plugins/<host>/, records what it installed, and decides what rtok agents update does with an installed plugin.
-
Background1 page
-
More35 pages
- Agents and worktrees Every agent session that works through rtok gets one rtok agent id, and every worktree is bound to the agent that owns it, the same way on every host. Agents and the user can message each other by that id.
- Commands Every command below is a surface onto the same plugin registry and the same SQLite store, and every one of them works today.
- Overview 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.
- Plugins
- Агенты и рабочие деревья
- Агенты
- Правила фильтрации команд
- Команды
- rtok в сравнении с альтернативами
- Конфигурация
- Начало работы с rtok
- LSP-бэкенд для graph
- Экспорт в OpenTelemetry
- Обзор
- Написание плагина
- Версии и обновления плагинов
- Плагины
- Кеш промпта
- Задачи
- Tasks
- Агенти й worktree
- Агенти
- Правила фільтрування команд
- Команди
- rtok у порівнянні з альтернативами
- Конфігурація
- Початок роботи з rtok
- LSP-бекенд для graph
- Експорт OpenTelemetry
- Огляд
- Як написати плагін
- Версії плагінів і оновлення
- Плагіни
- Кеш промптів
- Завдання
Where things live
Everything rtok keeps, in one place.
| Path | What it holds |
|---|---|
~/.rtok/config.toml | Configuration (RTOK_HOME overrides the directory) |
~/.rtok/rtok.db | SQLite — measurements, archive index, memory |
~/.rtok/archive/ | Raw payloads, addressed by expand id |
<git root>/.rtok.toml | Optional per-project overrides |
Questions the docs answer
Good to know.
Does rtok break the prompt cache?
No — measured, not promised. The Prompt cache page reports hit=97.5% from rtok stats on the maintainer's machine (2026-09-18) and zero recorded prompt-cache busts in rtok report. Injection is byte-stable, rewrites stay outside the conversation's working edge, and hooks touch each result once.
What happens if a plugin was compiled out?
The subcommand prints not implemented and exits 0, so a stripped or half-installed rtok never blocks the host agent.
Which agents can it wire into?
rtok agents install <host> configures Claude Code and other hosts such as cursor, codex and opencode. The Agents page lists, per host, what an install writes and which rtok plugins then reach that app.
Where did a setting come from?
Every CLI flag is a config key in ~/.rtok/config.toml, and rtok config show --sources always tells you where a value came from.
Next steps
Read these first.
- Getting started rtok reduces the context AI coding agents must carry. One Rust binary, three surfaces: Claude Code hooks, an MCP server, and an API proxy. Each reduction is measured; shortened payloads stay retrievable by id.
- Configuration One file, ~/.rtok/config.toml, holds every setting rtok has. Every CLI flag is a config key, so anything you can pass on the command line you can also make permanent, and rtok config show --sources always tells you…
- Agents Every host rtok agents install <host> configures, per app, with what rtok writes into it and which rtok plugins then reach that app.