opencode-rtk-optimizerOpenCode plugin for RTK, reduces LLM token consumption by 60-90% on dev commands
0
39
7 in 7 days
28.3
Multi-signal model
1 month ago
2026-07-16
Install and configure
opencode.jsonWrites to this project's opencode.json — applies to this repository only.
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-rtk-optimizer@0.1.0"]
}Writes to ~/.config/opencode/opencode.json — applies to every project.
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-rtk-optimizer@0.1.0"]
}If you want to modify the plugin locally, install it into the project and reference the local path.
shell
pnpm add -D opencode-rtk-optimizeropencode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.
[!NOTE] This fork exists because openrtk appears inactive, with no updates for roughly four months. The npm package will be removed if changes are accepted upstream.
OpenCode plugin for RTK (Rust Token Killer). Reduces LLM token consumption by 60-90% on common dev commands by transparently routing them through RTK's output compression.
A lightweight OpenCode plugin that intercepts shell commands and routes them through RTK for automatic output compression. The model retains the original command in its history while receiving RTK's optimized output.
Prerequisites
Install RTK:
cargo install rtk
Installation
Install via npm:
npm install opencode-rtk-optimizer
Then add to your OpenCode config (opencode.json or .opencode/config.json):
{
"plugin": ["opencode-rtk-optimizer"]
}
Or copy src/index.ts directly into .opencode/plugins/ for local use.
How it works
The plugin hooks into OpenCode's tool execution events and delegates shell command rewrites to rtk rewrite. The rewritten command executes while the original command remains visible to the model.
git status -> rtk git status (72% savings)
cargo test -> rtk cargo test (80% savings)
docker ps -> rtk docker ps (65% savings)
Supported commands are determined by the installed RTK version. Common rewrites include:
Supported commands
| Category | Commands |
|---|---|
| Git | status, diff, log, add, commit, push, pull, branch, fetch, stash, show |
| GitHub CLI | pr, issue, run, api, release |
| Rust | cargo test/build/clippy/check/install/fmt |
| File ops | cat, grep, rg, ls, tree, find, diff |
| JS/TS | vitest, npm test/run, tsc, eslint, prettier, playwright, prisma |
| Containers | docker (compose/ps/images/logs/run/build/exec), kubectl (get/logs/describe/apply) |
| Network | curl, wget |
| Python | pytest, ruff, pip, uv pip |
| Go | go test/build/vet, golangci-lint |
| Packages | pnpm list/ls/outdated |
Development
npm run build # build the plugin
npm test # run tests
License
MIT