cd /news/developer-tools/i-built-a-claude-code-plugin-that-on… · home topics developer-tools article
[ARTICLE · art-42118] src=dev.to ↗ pub= topic=developer-tools verified=true sentiment=↑ positive

I built a Claude Code plugin that only keeps an "agent memory" rule if it can prove it saves tokens

A developer built token-warden, an open-source plugin for Claude Code that only retains agent memory rules if they can prove they save at least twice the tokens they cost. The tool benchmarks candidate rules on a frozen test suite and evicts those that fail, such as a rule that saved 38k tokens per run but caused the agent to fail tasks. In one test, a grep-before-read rule cut token usage from ~67k to ~56k per session, a 16% reduction.

read1 min views1 publishedJun 27, 2026

Most agent-memory setups add a rule because a model thought it sounded useful. I wanted one that has to earn its spot.

token-warden watches your Claude Code sessions, distills candidate efficiency rules from the expensive ones, then benchmarks each rule on a frozen test suite (with vs without it) and only keeps it if it saves at least 2x the tokens it costs to carry around, and breaks nothing. Everything else gets evicted. It once threw out a rule that saved 38k tokens per run because that "saving" came from the agent giving up and failing the task.

Honest result so far: on a deliberately wasteful agent, a "grep for the symbol before reading the whole file" rule cut a session from ~67k to ~56k tokens (about 16%, roughly 3 cents/session on Sonnet, ~500x what the rule itself costs). On my already-optimized agents the same rule saves basically nothing and gets auto-evicted, which is the entire point. It refuses to keep junk just to look busy.

It's measured, not vibes. Open source, MIT. I'd genuinely like people to try to break it or tell me the numbers are wrong.

── more in #developer-tools 4 stories · sorted by recency
── more on @token-warden 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/i-built-a-claude-cod…] indexed:0 read:1min 2026-06-27 ·