Optimize OpenCode tokens with DCP and RTK
RTK eliminates noise from terminal outputs, achieving 60-90% reductions in common operations.
DCP cleans old information from the context to prevent accumulation of unnecessary messages or results.
In practice, this means fewer tokens per iteration, lighter contexts, and more efficient model usage. This helps make better use of free models and reduce costs on paid ones.

Here are the steps I followed on Windows:
Updating OpenCode
First, update OpenCode with choco upgrade opencode in PowerShell as administrator.
Installing Dynamic Context Pruning (DCP)
To install DCP, follow the instructions from Dynamic Context Pruning (as of this tutorial):
Edit C:\Users\[MyUser]\.config\opencode\opencode.jsonc and set:
{
"plugin": ["@tarquinen/opencode-dcp@latest"],
}
Also create a dcp.jsonc file and paste the “Default Configuration” from the GitHub repo documentation.
Modify some of these values in dcp.jsonc since by default it has high values that might not have any effect on some low-context models:
{
"compress": {
"mode": "range",
"permission": "allow",
"summaryBuffer": true,
"maxContextLimit": 20000,
"maxTokenLimit": 10000,
"minContextLimit": 10000,
"nudgeFrequency": 1,
"nudgeForce": "strong",
"iterationNudgeThreshold": 5,
},
}
Installing Rust Token Killer (RTK)
To install RTK, follow the instructions from Rust Token Killer (as of this tutorial):
On Windows, download rtk-x86_64-pc-windows-msvc.zip from the releases section of the GitHub repo, extract it and place rtk.exe in a fixed path, for example C:\Programas\rtk\rtk.exe
In the system environment variables, add the previous path to the “Path” (C:\Programas\rtk\)
Open another command prompt and verify with rtk --version and rtk init --show
Also, with rtk gain you can see the saved tokens stats that initially are zero because it hasn’t been used yet.
Run rtk init -g --opencode
Finally add the RTK plugin to “opencode.jsonc”, so the file would look like:
{
"plugin": ["@tarquinen/opencode-dcp@latest", "@rtk/opencode-plugin@latest"],
}
Finally, open OpenCode and press Ctrl+P > View Status (in the System category) and verify that both plugins, dcp and rtk, are visible.
From now on, you can use them and as you have interactions with the agents, these plugins will be used to save tokens.
Checking token savings
To check token savings in OpenCode, you can run the /dcp stats command, and to see savings with rtk, run rtk gain in a command prompt.
YouTube video of the process (Spanish audio): YouTube video