Install
Add the plugin
Install the package, then register it in your global or project opencode config.
npm install -g tokenwarden
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["tokenwarden"]
}README
TokenWarden is a local-first opencode plugin and CLI for reducing wasted context, keeping raw logs local, and reporting observed token savings per session.
Install
Install the package, then register it in your global or project opencode config.
npm install -g tokenwarden
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["tokenwarden"]
}Run
After changing opencode config, restart opencode so it loads TokenWarden.
opencode . # Then use local slash commands: /tokenwarden-status /tokenwarden-report
Slash commands
/tokenwarden-reportShows observed would-have-used tokens, actually used tokens, saved tokens, and percent saved from local usage data.
/tokenwarden-statusShows the current TokenWarden account and allowance status in the opencode TUI only. It does not open a browser.
/tokenwarden-accountOpens your hosted TokenWarden account page without spending an AI call.
/tokenwarden-connectStarts hosted account connection and device authorization in the browser without spending an AI call.
/tokenwarden-disconnectDisconnects the current account, removes the local paid license, and reverts this machine to the capped free seat.
Session behavior
TokenWarden can guide opencode sessions toward shorter, development-focused answers that skip filler, unnecessary recap, and details that do not affect coding, debugging, verification, or planning.
Important paths, commands, errors, failed tests, decisions, and blockers should still be preserved when they matter for the work. This stays part of your local opencode workflow.
CLI
tokenwarden report tokenwarden report --session SESSION_ID --no-color tokenwarden status tokenwarden account tokenwarden connect --email you@example.com tokenwarden disconnect
status prints local runtime and billing state. account opens the hosted account page.disconnect removes the local license and returns this machine to the free version.
Storage
Usage events, summaries, raw tool outputs, and failure diagnostics stay on your machine.
The native package includes signed sidecars for macOS arm64, macOS x64, Linux x64 musl, Linux ARM64 musl, and Windows x64, with signed sidecar verification before native optimization runs.
~/.cache/tokenwarden/encrypted/raw-tool-output/
Workflow
Paid Standard seats remove the free saved-token cap. Disconnecting only changes the local account and license state; it does not delete your usage history or raw logs.
When an account owner assigns a seat to another email address, that recipient gets an activation email. They sign in with the receiving address, open the account page, and follow the account/device authorization flow to activate the license.
opencode> /tokenwarden-connect Browser opened. Waiting for authorization... opencode> /tokenwarden-status Account: standard (active) opencode> /tokenwarden-account Account page opened. opencode> /tokenwarden-disconnect Reverted to free seat. Account: free seat | remaining local allowance shown in TUI