inferops-scan
v0.1.0
Published
Diagnoses waste in your Claude Code usage: cache lapses, context drag, re-read loops, model-tier mismatch, and cost concentration. Local-only, zero dependencies.
Readme
inferops-scan
Diagnoses waste in your local Claude Code usage — five named patterns, a ranked report, and a one-line fix for each. Runs entirely on your machine.
ccusage tells you what you spent. inferops-scan tells you what you wasted, and how to fix it.
$ npx inferops-scan --compact
Billing mode: Subscription
Sessions: 214 across 9 projects · 2026-04-06 -> 2026-07-03
~= 18% of your recent usage windows went to detectable waste. Fixing the top
finding buys back roughly 0.6 hours of window per day (approximate).
# Pattern Window share ~£/mo at API prices
---------------------------------------------------------
1 Cache waste 11.4% £86.20
2 Context drag 6.1% £41.90
3 Cost concentration 71% conc. -
Fixes:
[1] Cache waste: Work in continuous focused bursts; a pause longer than your
cache TTL (Claude Code picks a 5-minute or 1-hour tier
automatically, based on how you authenticate) forces a
rebuild of the cached prefix at 12.5x-20.0x the read price
(at current prices.json rates). Split unrelated tasks into
separate sessions instead of idling.
[2] Context drag: Use /clear between unrelated tasks and /compact after long
exploration; stale context re-bills on every subsequent
message.
[3] Cost concentration: Your spend is concentrated: review how these few
sessions ran. They are where the other findings above
are cheapest to fix.
Estimates only · prices 2026-07-03 · nothing left this machine(Illustrative output — figures above are not from a real scan. Table layout, wrapping, and column widths above are exactly what the tool produces; verified against this build's own test suite. Note: "Cost concentration" never adds to the headline percentage above it — it reports which top-spending sessions hold the other findings' waste, not a separate pool of waste of its own; see "What it detects" below.)
Install & run
No install step. No sign-up, no API key, no account.
npx inferops-scanCommon flags:
npx inferops-scan --compact # screenshot-sized output
npx inferops-scan --markdown # write a shareable report
npx inferops-scan --json # machine-readable findings
npx inferops-scan --since 2026-06-01 # scan from a specific date
npx inferops-scan --all # scan your entire history
npx inferops-scan --mode subscription # force a billing mode
npx inferops-scan --plan max # if you're on Claude MaxRun npx inferops-scan --help for the full flag reference.
What it detects
Cache waste — Claude Code's prompt cache expires after a period of inactivity. It writes cache entries on one of two time-to-live tiers, 5-minute or 1-hour, chosen automatically from how you authenticate. Idle past whichever tier applies and your next message rebuilds the entire cached prefix at write price instead of reading it back cheaply. This detector reads the real per-event tier from your transcripts rather than guessing, and separately flags sessions where the cache is persistently under-utilised.
Context drag — Long sessions that never get /clear'd carry their
entire history into every subsequent message. Even fully cached, an
oversized context costs real money on every turn. This detector flags
sessions where context size roughly doubles (or worse) between the start
and the end of the session, past a materiality floor, and estimates the
avoidable share.
Re-read loops — The same file read three or more times in one session usually means the model lost track of what it already knows, or a plan went sideways. This detector counts repeated file reads (and repeated identical tool calls more broadly) and estimates the re-transmitted token cost.
Model-tier mismatch — Small, well-scoped edits don't need Opus. This detector flags Opus-family sessions shaped like light work (tiny output, one or two files touched, no extended thinking, few messages) and computes — live, from the current price list, never a hardcoded number — what the same work would have cost on Sonnet.
Cost concentration — In most usage, a small number of sessions account for a disproportionate share of spend. This detector finds them, and reports which of the other four findings is most responsible for the waste inside them — so you know exactly where fixing behaviour pays the most.
Billing modes
inferops-scan detects, per session, whether you're billed by the API
(pay-per-token) or by a Claude subscription (Pro/Max), and values findings
accordingly:
- API-billed sessions show an estimated £/month of avoidable spend, extrapolated from the scanned date range.
- Subscription sessions show an approximate share of your recent 5-hour usage windows spent on detectable waste, plus a shadow cost — what that waste would have cost at API list prices, so you have a concrete number even though your actual bill doesn't change per-token.
If your history mixes both (e.g. a personal Max subscription and a work API key), the report segments automatically. Every £ figure carries the price-list version it was computed against, and is always labelled an estimate.
Cache-write pricing always comes from the real per-event TTL tier recorded
in your transcripts — never from your plan. --plan max|pro only refines
how idle-gap cache lapses are labelled in a finding's evidence text (this
build cannot read your plan tier from local config, see Privacy &
security below); passing it changes no cost figure in any report.
Privacy & security
- Zero dependencies. The published package depends on the Node
standard library only — no npm supply-chain surface at all.
npm lsafter install shows nothing. - Small enough to read. The whole tool is a few thousand lines of TypeScript, organised into single-purpose files. You can audit it in an afternoon; nothing is obfuscated or minified beyond standard bundling.
- Local-only by default. Zero network calls unless you explicitly pass
--telemetry. No update checks, no pricing fetches at runtime, no phone-home of any kind. - Read-only on your transcripts. Nothing under
~/.claude/projects/is ever modified, moved, or copied. Message and tool-result content is read into memory only to compute lengths, hashes, and counts for a handful of detectors — that content is discarded immediately after and never appears in any output, log, report, or file this tool writes. - No shell-outs.
child_process(or any equivalent) appears nowhere in the codebase — verified by an automated test that greps the source tree on every change. - Sanitised output. Every string that could originate from a transcript, file path, or local config is stripped of ANSI escape sequences and control characters before it reaches your terminal, a markdown file, or JSON — a defence against terminal/escape-sequence injection from untrusted transcript content.
- Config values are never read. Billing-mode detection checks whether an OAuth account marker is present in your local Claude config — it never reads, logs, or stores the actual value of anything in that file.
Telemetry (--telemetry, opt-in, off by default)
Passing --telemetry sends exactly one anonymous HTTP POST to
https://api.inferops.org/v1/cli-ping containing this payload and nothing
else:
{
"version": "0.1.0",
"mode": "subscription",
"sessionCountBucket": "51-200",
"findingCount": 3,
"wastePctBucket": "16-30%"
}Five fields. sessionCountBucket and wastePctBucket are coarse ranges,
never raw values. No project names, no file paths, no token counts, no
content of any kind. The request has a 2-second timeout and fails
silently if it can't be sent — nothing about this ping ever blocks or
breaks a scan.
Relationship to ccusage
Complementary, not competing. ccusage
reports what you spent. inferops-scan diagnoses why — which specific
patterns are driving that spend, and what to do about each one. Run both.
Point-in-time, not continuous
This is a scanner: it tells you what already happened. Waste regenerates — a session you fix today can drift back into the same pattern next week. inferops.org watches production AI usage continuously and confirms the saving when you fix it, instead of scanning after the fact.
Licence
Apache 2.0. Copyright JC Digital & App Development Ltd.
