{"slug": "show-hn-which-prompts-ate-your-claude-code-limit-a-local-read-only-doctor", "title": "Show HN: Which prompts ate your Claude Code limit? A local, read-only doctor", "summary": "A tool called TokenOps, published as a Claude Code plugin and a PyPI CLI, analyzes local Claude Code session logs to show which prompts consumed the most usage; in a sample 7-day report covering 12 sessions and 304 prompts, it attributed 37% of usage to the first message after a break and 41% to re-reading context on every call. The doctor estimates that running /compact before stepping away would have saved about 31%, and its optional saver mode, off by default, holds a post-break message once when context exceeds 50k tokens to warn that resending re-reads the conversation at the cache-write price. TokenOps requires Python 3.9+ or uv, installs via /plugin marketplace add theagentplane/tokenops, and offers a --redact flag that hides prompts and project names for screenshots.", "body_md": "**Why am I hitting my limit?** One command names the prompts that cost you the most, says why,\nand what to change. Read from your own session logs, on your machine.\n\n```\n/tokenops:doctor\n\n  Why am I hitting my limit?   (last 7 days, 12 sessions, 304 prompts, $235 at API list prices)\n\n  37% of your Claude usage went to the first message after a break.\n  39 times the cache had expired, so Claude reloaded the whole conversation.\n  /compact before you step away would have saved ~31%.\n\n  Your 3 most expensive prompts  (9% of usage)\n\n  #2  Wed 21:56  project B  (prompt hidden)\n      █████████░░░░░░░░░░░ 44% of that 5-hour window  |  24x your typical prompt\n      CACHE EXPIRED  away 4h 45m, past the 1h cache: one call re-wrote your\n                     whole 965k-token conversation to the cache at 2x the input price\n      1 model call, paid $7.41  ->  /compact before leaving ~$0.52 (14x less) | /clear + note ~$0.27\n  ...\n  Where your usage goes\n     41%  Re-reading context every call\n     37%  First message after a break (cache reloaded)\n     12%  Claude's output\n     11%  Caching new context\n\n  What to change\n    1. Re-reading is 41%: every call reads the whole conversation again ... Use /clear when you\n       switch to an unrelated task.\n    2. Output is 12% of your usage, so a terse-output tool like caveman can save at most that ...\n```\n\nIn Claude Code:\n\n```\n/plugin marketplace add theagentplane/tokenops\n/plugin install tokenops@tokenops\n```\n\nThen run `/tokenops:doctor` (last 7 days; `/tokenops:doctor 30` for 30). Needs Python 3.9+ on\nyour PATH; nothing to `pip install`.\n\nOr, without installing anything, from any terminal with [uv](https://docs.astral.sh/uv/):\n\n```\nuvx tokenops doctor\n```\n\n(The `tokenops` package on PyPI is this CLI; the agent governance library is `agent-tokenops`.)\n\n- **Prompts.** One prompt you type can make many model calls (tool use, subagents). They are all\ncounted under the prompt that started them. The doctor shows the 3 most expensive prompts,\nwith the project they were typed in.\n- **Tokens** are the size of the whole conversation that one call sent, not a sum over calls.\nModels with a 1M-token context can carry a conversation that long.\n- **CACHE EXPIRED** means the call came more than the cache lifetime (1 hour on a Claude plan,\n5 minutes with an API key) after the previous one, and wrote most of the conversation to the\ncache again at the cache-write price. The headline and the \"First message after a break\" row are\nthe same number: the cache writes of those calls.\n- **5-hour windows** are estimated from your first prompt in each, not read from Anthropic's\nmeter. The cheaper costs are estimates: only the calls a break made expensive are re-priced.\n- **Share yours.** The report ends with one line you can paste as is: your headline share and the\ncommand, with no prompts, project names or dollars.\n- **Sharing a screenshot?** From a terminal,`uvx tokenops doctor --redact` hides your prompts and\nproject names (\"project A\", \"project B\").\n\n`/tokenops:saver on` lets TokenOps act on what the doctor finds. Off by default; every hook\nfails open.\n\n- \n**Resume guard.** After a break longer than the cache lifetime, your next message re-reads the\nwhole conversation at the cache-write price. The guard holds that message once:\n\n```\nTokenOps: this session's cache expired (1.5 h since the last reply). Sending now re-reads\n433k tokens at the cache-write price: about $3.47 API-equivalent, against $0.09 while the\ncache was warm.\n  - Send the same message again to continue anyway.\n  - Or run /compact first: it keeps the gist in far fewer tokens.\n  - Or /clear and paste a 3-line summary of where you were (cheapest).\n```\n\n It only acts when the context is at least 50k tokens ( `TOKENOPS_GUARD_MIN_TOKENS` ).\n- \n**Smart RTK.** With[RTK](https://github.com/rtk-ai/rtk) installed, shell commands Claude runs\nare rewritten to their compact RTK form (`git status` ->`rtk git status` ), using RTK's own`rtk rewrite` . File reads (`cat` ,`head` ,`sed -n` ),`git diff` /`git show` , and the next test run\nafter a failing one stay verbatim, because Claude needs that output exactly. If RTK's own hook\nis installed, smart RTK stays off so nothing is rewritten twice: remove RTK's hook from your\nClaude Code settings to let TokenOps decide.\n- \n**Measured, not guessed.** Smart RTK and[caveman](https://github.com/JuliusBrussee/caveman) are\neach switched on in a random half of your sessions. After 10 sessions on and 10 off, the doctor\nshows what each one did to your usage per prompt, and the saver mode keeps it only if it saves:\n\n```\nMeasured on your sessions (saver mode A/B, usage per prompt)\n  Smart RTK  -6% usage per prompt (95% range -9% to -2%) -> kept on\n  caveman    +1% usage per prompt (95% range -3% to +5%) -> turned off\n  Usage only: hooks cannot see whether the work went as well.\n```\n\n For caveman, set its own default to off ( `\"defaultMode\": \"off\"` in caveman's config file, or`CAVEMAN_DEFAULT_MODE=off` ) so TokenOps decides per session.\n\n`/tokenops:saver status` shows what is on; `/tokenops:saver off` turns it all off.\n\nClaude Code writes every model response to `~/.claude/projects/*/*.jsonl`, often on several\nlines with the same message id. The doctor keeps the last line per response, includes subagent\ntranscripts, counts a response once even when a forked session copies it, and prices each response at Anthropic's list rates: input, output, cache reads,\nand cache writes (1.25x input for the 5-minute cache, 2x for the 1-hour cache). Prices come from\nTokenOps' price book (`src/tokenops/framework/pricing.py`).\n\n- **First message after a break:** a cache write of 20,000+ tokens, at least half the conversation,\nmore than the cache lifetime after the previous call. The cache had expired, so the whole\nconversation was written again.\n- **Re-reading context:** cache reads. Every call reads the conversation again.\n- **Caveman and RTK advice** is a ceiling from your own usage mix (what share is output, what\nshare of tool output came from shell commands RTK compacts), not a measured A/B.\n\nOn a Claude plan the dollar figures are API-equivalent: they show your share of usage, not a bill. Nothing leaves your machine.\n\n- **Runs:**`python3` (or`python` ) with the scripts in this folder, standard library only. With\nSaver mode on and[RTK](https://github.com/rtk-ai/rtk) installed, it also runs`rtk rewrite <command>` to ask RTK how it would compact a shell command. Nothing else.\n- **Reads:** your Claude Code session logs (`~/.claude/projects/*/*.jsonl` ), your Claude Code\nsettings files (to see which token savers are installed), caveman's installed skill file and\nconfig (only when caveman is installed), and this plugin's own`prices.json` .\n- **Stores:** a small settings file and one small JSON file per session in Claude Code's plugin\ndata folder (`$CLAUDE_PLUGIN_DATA` ): whether Saver mode is on, the A/B choices and results.\n- **Sends:** nothing. It makes no network requests and keeps no copy of your prompts or code.\n- **Changes:** with Saver mode on, it can hold one message after a break (you send it again to\ngo on) and rewrite a shell command to its RTK form. With Saver mode off, it only reads.\n\n```\npython scripts/sync-claude-prices.py   # after changing DEFAULT_RATES\npython -m pytest tests/claude_code\n```\n\n", "url": "https://wpnews.pro/news/show-hn-which-prompts-ate-your-claude-code-limit-a-local-read-only-doctor", "canonical_source": "https://github.com/theagentplane/tokenops/tree/main/integrations/claude-code", "published_at": "2026-12-02 07:17:30+00:00", "updated_at": "2026-12-02 07:46:40.479544+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents"], "entities": ["TokenOps", "Claude Code", "Anthropic", "PyPI", "uv", "RTK", "theagentplane"], "also_reported_by": [], "takeaway": "TokenOps' doctor attributes 37% of a sample Claude Code bill to cache-expired first messages after breaks and 41% to re-reading context each call, and estimates /compact before stepping away would have cut about 31%.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-which-prompts-ate-your-claude-code-limit-a-local-read-only-doctor", "markdown": "https://wpnews.pro/news/show-hn-which-prompts-ate-your-claude-code-limit-a-local-read-only-doctor.md", "text": "https://wpnews.pro/news/show-hn-which-prompts-ate-your-claude-code-limit-a-local-read-only-doctor.txt", "jsonld": "https://wpnews.pro/news/show-hn-which-prompts-ate-your-claude-code-limit-a-local-read-only-doctor.jsonld"}}