How it works

TokenWarden removes text your AI does not need.

Install it in opencode and work as usual. TokenWarden shortens large file reads, command output, and old session history before they are sent back to the AI model.

Focused file reads

It reads only what the task needs.

These tools help opencode avoid sending entire files when a smaller answer is enough.

ToolPlain explanation
smart_readReads only the useful parts of one source file.
smart_packCollects the useful parts of several files in one focused result.
token_reportShows how many tokens TokenWarden removed and the estimated savings.

Automatic behavior

It also cleans up each session.

Large tool output

Shortens long command output while keeping errors, failed tests, paths, and commands.

Session compaction

Shortens old session history but keeps the goal, changed files, decisions, test status, and next step.

Compact answers

Guides opencode to give short answers with the result, changed files, checks, risks, and blockers.

Important details stay

The AI still gets what it needs.

TokenWarden keeps details that affect the next coding step:

  • file paths
  • commands
  • error messages
  • failed tests
  • decisions
  • blockers
  • next actions
Install TokenWarden