Token Keeper
A Claude Code mod for token economics, for subscription and API users alike. It is a fork of Cache Keeper by Nate Herk, from nateherkai/claude-code-mods (MIT), cut down to four jobs: show what the cache costs, set it up, keep it warm, and hand a big chat off to a fresh one.
Credits
All of Cache Keeper's original work is Nate Herk's: the warm/cold cache band, /keepwarm, the cold-send guard, TTL detection, /handoff and the session-handoff skill, plus the shared pricing and fmt helpers. Go check out his repo and videos. This fork changes and adds the things listed below. It leaves out Cache Keeper's /board and recording mode for now.
What's different from Cache Keeper
- Cache-break detector. If a request rewrites most of the context even though the cache was still warm (less than 4.5 minutes idle), Token Keeper reports it as a cache break and names the cause it suspects: a model switch, or a changed prompt prefix (CLAUDE.md, MCP tools, settings, effort). Cache breaks show on the band and in
/cache.
- The threshold is in dollars. A context counts as big when rewriting it costs at least
/cache big ($1 by default). Token Keeper works out what that means in tokens for the current model and TTL, for example $1 ≈ 125k tokens on Opus 5.5 with the 1h TTL. Above it, the cold-send guard asks before a cold send, a line in the chat warns before the cache goes cold, and the band shows the keep-warm button.
- Keep warm knows its break-even.
/keepwarm runs for 30 minutes on the 5-minute TTL and for 4 hours on the 1-hour TTL by default. A rewrite costs as much as (cache-write price / cache-read price) pings, whatever the context size, so pinging pays off only up to a point, for example about 1h 28m on Opus 5.5 with the 5-minute TTL. Ask for longer and you get a warning that suggests /handoff or /clear instead.
/cache ttl sets the real TTL, and checks it. /cache ttl 5 or 60 sets CLAUDE_CODE_PROMPT_CACHE_TTL for the running Claude Code, so the next request already writes 5-minute or 1-hour cache entries; auto gives the variable back. Every cache write reports which TTL it used, so the cache window is measured rather than guessed, and a line warns once if Claude Code writes another TTL than the one you set (FORCE_PROMPT_CACHING_5M wins over it). Switching while the cache is warm makes the next message rewrite the part of the context cached under the other TTL, so /cache ttl asks first and names the price; once the cache is cold it switches without asking, because that rewrite happens anyway.
- Handoff or keep warm? A handoff reads the context once, writes the handoff, and starts a fresh chat; after that nothing needs pinging.
/keepwarm compares the two for the time you asked for and says when the handoff is cheaper, for example at 300k tokens on Opus 5.5 with the 5-minute TTL after about 14 minutes. It also says what each later turn saves, which is usually worth more: at 300k tokens each turn re-reads $0.06 of context, after a handoff about $0.005. The fresh chat's start is measured from /context, and the handoff's size is the average of your last five. Past /cache handoff tokens (140k by default, a common rule of thumb for where a model starts to lose track of a long context) a notice suggests a handoff or a /compact, which costs about the same, and asks whether to hand off now, be reminded after another 100k tokens, or get no more reminders. Not counted: files the fresh chat reads again because the handoff left them out, so a handoff pays off most when much of the old context is done with.
- A handoff while the cache is warm. On a cold cache, writing a handoff rewrites the whole context too. So the cooling warning offers
/handoff before the cache goes cold.
- Today's cost across sessions. A cache file per day keeps what each transcript cost, so only transcripts that changed are read again, and this session counts live. A transcript too big to read shows as
≥ instead of being left out without a word.
Where it shows
Token Keeper runs wherever Claude Code runs, but each app draws a different part of it. Claude Code decides which parts each app gets, not the mod.
Terminal (CLI): everything

The band above the prompt shows the cache state (warm, cooling, cold, kept warm), the context size, what a rewrite costs, rate limits, cold restarts and cache breaks. While a big cache is cooling, it shows a keep warm button you press with 1.
Claude Code Desktop: band and footer

The Desktop app draws the band too, with its buttons as native buttons. The footer also gets a short label, but only when there is something to act on.
VS Code: commands only, no band