@r3b1s/pi-token-killer
RTK (Rust Token Killer) extension for pi-coding-agent — routes eligible bash commands through rtk
Package details
Install @r3b1s/pi-token-killer from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@r3b1s/pi-token-killer- Package
@r3b1s/pi-token-killer- Version
0.3.1- Published
- Jun 11, 2026
- Downloads
- not available
- Author
- r3b1s
- License
- MIT
- Types
- extension
- Size
- 8.8 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-token-killer
RTK (Rust Token Killer) extension for pi-coding-agent. It transparently routes eligible bash commands through rtk to reduce LLM token consumption by 60-90%.
This extension requires rtk: https://github.com/rtk-ai/rtk
The goal is minimalism. This package simply hooks an existing RTK installation into pi. Other RTK-related npm packages I found appear to reimplement RTK output filtering or add extra behavior.
This extension does not replace the functionality of the original rtk tool. It only uses pi hooks to route eligible shell commands through RTK, while keeping RTK responsible for command execution and output optimization.
Install
Install via git:
pi install git:https://github.com/r3b1s/pi-token-killer
Or add it to your pi agent extensions config (for example, .pi/extensions/ or settings.json) if you are using a local checkout:
/path/to/pi-token-killer
rtk must be installed and available on your PATH.
How it works
- On startup, it parses
rtk helpand stores the available RTK subcommands. - It removes systemic/meta RTK commands from that set, keeping only optimizer commands.
- It intercepts
bashtool calls and prefixes matching optimizer commands withrtk. - It maps common aliases where RTK uses a different subcommand, such as
cat→rtk readandrg→rtk grep. - It skips commands that are already prefixed with
rtk, interactive commands, heredocs, and commands RTK does not expose as optimizers. - It fails open: if
rtkis missing or parsing fails, the original command runs unchanged. If RTK appears later, the extension retries parsing on the next rewrite attempt. - It injects RTK meta-command documentation into the system prompt.
Meta commands
rtk gain # Show token savings analytics
rtk gain --history # Show command usage history
rtk discover # Find missed optimization opportunities
rtk session # Show RTK adoption across recent sessions
rtk proxy <cmd> # Run command without rtk filtering
rtk rewrite <cmd> # Show how RTK would rewrite a raw command