kmail-save-tokens
v0.1.3 · stable · utilstranslate coding-agent prompts into token-efficient instructions
about
Rewrites the prompts you give to coding agents (OpenCode, Claude Code,
Codex, Cursor, Copilot) so they say the same thing in fewer tokens —
cutting cost and latency without losing intent. Strips filler, shrinks
verbose phrasing, and applies prompt-engineering techniques on demand.
what it does
- Filler strip and phrase shrink
- `translate` removes courtesy words ("please", "thanks", "can you", "just") and collapses verbose phrasing ("take a look at" → "inspect", "in order to" → "to"); the default path never adds tokens, so savings are always ≥ 0.
- Six agent presets
- `--agent` targets generic, opencode, claude, codex, cursor or copilot, and `presets` prints each one's system line — e.g. claude is "Act as a senior staff engineer. Be concise and precise."
- Interactive agent session
- `kmail-save-tokens --agent opencode` opens a prompt loop that translates every line before you send it, with /send to pipe the optimized prompt straight to the agent CLI.
- See what it changed
- `analyze` lists the techniques applied and why, `diff` shows the original against the optimized prompt side by side, and `--json` emits the whole analysis as JSON.
- Opt-in techniques that cost tokens
- --with-role, --with-output, --with-system and --with-verb add a persona (RICCE), an output constraint, an agent system prefix or a magic verb — each has to be asked for because each adds tokens.
- Token estimation offline
- `tokens <text>` estimates a count with no network call, and the same optimizer is importable as `optimize` and `estimateTokens` from the package.
install
npm — global install
npm install -g kmail-save-tokensInstalls the `kmail-save-tokens` command. Needs Node.js 20 or newer. The only runtime dependency is commander, so there is no native build step.
Translate one prompt
kmail-save-tokens translate "please can you take a look at the code and fix the bug in the login function, thanks"Prints the optimized prompt and the token delta (the README's example goes 21 → 14 tokens). Add --conservative to only strip filler and preserve wording, or --agent <name> to target a specific agent.
Work inside an agent session
kmail-save-tokens --agent opencodeEvery prompt you type is translated before it is sent; /send toggles auto-sending the result to the agent CLI and /verbose shows the full diff and edits.
As a library
npm install kmail-save-tokensoptimize() and estimateTokens() are importable, so a script can compress prompts without spawning the CLI.
synopsis
kmail-save-tokens --agent <name> | translate <prompt> [--agent=claude]changelog
- v0.1.3stream agent responses live to the terminal
- v0.1.2interactive session: --agent <name> auto-translates prompts
- v0.1.1agent presets for opencode/claude/codex/cursor/copilot
- v0.1.0initial release: filler strip + phrase shrink
