Artikel ini belum diterjemahkan. Isi berikut berbahasa Inggris. Buka versi asli bahasa Inggris.
rtk-ai/rtk is a Rust CLI proxy that compresses common command outputs before they are sent to your coding agent context.
In practical OpenCode sessions, this can reduce prompt/context token usage significantly on repetitive commands like git status, git diff, ls, grep, test runners, and build logs.
What RTK does in OpenCode
RTK can integrate with OpenCode through an OpenCode plugin hook and rewrite Bash commands to rtk ... equivalents automatically.
Examples:
git status→rtk git statusgit diff→rtk git diffls→rtk lsrg pattern .→rtk grep pattern .
That means you keep the same command habits while sending denser, less noisy output to the model.
Install RTK
Choose one method.
Homebrew (recommended on macOS)
brew install rtkScript install (Linux/macOS)
curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | shVerify installation
rtk --version
rtk gainSet up RTK in OpenCode
Install the global OpenCode plugin:
rtk init -g --opencodeThis creates:
~/.config/opencode/plugins/rtk.ts
Then restart OpenCode.
Validate that OpenCode hook is active
After restart, run a few normal commands in OpenCode:
git status
git diff
lsIf RTK is hooked correctly, these commands are rewritten internally and produce compact summaries.
Use these checks as well:
rtk init --show
rtk gain --historyImportant limitation
The OpenCode plugin hook applies to Bash tool execution only. Built-in non-Bash tools (for example native file readers/searchers) are not rewritten by this hook.
If you want RTK compaction for those workflows, use shell commands or explicit RTK commands such as:
rtk read <file>rtk grep <pattern> <path>rtk find "*.ts" .
Optional tuning
RTK supports config tuning in ~/.config/rtk/config.toml (or macOS app support path), including:
- rewrite exclusions (
hooks.exclude_commands) - tee/full-output capture behavior for failures
- tracking database location
This is useful if you want RTK in most places but need raw output for specific commands.
When to use RTK in this docs stack
RTK is most useful when you frequently run command-heavy coding sessions and want to reduce token burn without changing your normal terminal habits.
If your sessions are mostly short or rely heavily on OpenCode built-in non-Bash tools, the impact will be smaller.
References
- RTK repository: https://github.com/rtk-ai/rtk
- RTK install docs: https://github.com/rtk-ai/rtk/blob/master/INSTALL.md
- OpenCode plugin docs: https://open-code.ai/en/docs/plugins