Skip to content
Skills Library
AI & agents · Analysis

cachewise

/cachewise

Prompt-cache economics forensics — why your Claude Code tokens burn so fast, with the numbers to prove it. Parses local ~/.claude transcripts (0 tokens, a bundled Python script does the counting) and attributes every cache-miss rebuild to a cause — idle gaps past the 5-min TTL, mid-session model/effort switches, prefix churn (MCP tool-lists, edited CLAUDE.md, dynamic content), and cold re-boots of a session you could have resumed — each priced in real USD, then prescribes the fixes ranked by dollars saved. Tracks before/after in out/cachewise/tracker.md so the next run measures whether a fix w

Repository
skillhub ↗
Licence
MIT
Last repository change
08.09.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
3
Scripts
2
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 08.09.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • 2 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: scripts/analyze.py, scripts/test_analyze.py

What it does and when to use it

Prompt-cache economics forensics — why your Claude Code tokens burn so fast, with the numbers to prove it. Parses local ~/.claude transcripts (0 tokens, a bundled Python script does the counting) and attributes every cache-miss rebuild to a cause — idle gaps past the 5-min TTL, mid-session model/effort switches, prefix churn (MCP tool-lists, edited CLAUDE.md, dynamic content), and cold re-boots of a session you could have resumed — each priced in real USD, then prescribes the fixes ranked by dollars saved. Tracks before/after in out/cachewise/tracker.md so the next run measures whether a fix w

Original author description

Prompt-cache economics forensics — why your Claude Code tokens burn so fast, with the numbers to prove it. Parses local ~/.claude transcripts (0 tokens, a bundled Python script does the counting) and attributes every cache-miss rebuild to a cause — idle gaps past the 5-min TTL, mid-session model/effort switches, prefix churn (MCP tool-lists, edited CLAUDE.md, dynamic content), and cold re-boots of a session you could have resumed — each priced in real USD, then prescribes the fixes ranked by dollars saved. Tracks before/after in out/cachewise/tracker.md so the next run measures whether a fix w

How it works

  1. Step 0 — Run the analyzer
  2. Step 1 — Read the attribution
  3. Step 2 — Render the report
  4. Step 3 — Track before/after
  5. Guardrails
Original SKILL.md headings · 108 lines, 794 words
SKILL.md preview
---
name: cachewise
description: >-
  Prompt-cache economics forensics — why your Claude Code tokens burn so fast,
  with the numbers to prove it. Parses local ~/.claude transcripts (0 tokens,
  a bundled Python script does the counting) and attributes every cache-miss
  rebuild to a cause — idle gaps past the 5-min TTL, mid-session model/effort
  switches, prefix churn (MCP tool-lists, edited CLAUDE.md, dynamic content),
  and cold re-boots of a session you could have resumed — each priced in real
  USD, then prescribes the fixes ranked by dollars saved. Tracks before/after
  in out/cachewise/tracker.md so the next run measures whether a fix worked.
  Use when the user asks why they hit usage limits so fast, wants their cache
  hit rate or token spend analyzed, or where their tokens are going — e.g.
  "/cachewise", "analyze my prompt cache", "what's burning my tokens". For
  recurring behavior mistakes use tune; for today's schedule use daybrief.
---

# cachewise — where your cache dollars leak

`/cachewise` — analyze the last 30 days across every project
`/cachewise --days N` — widen or narrow the window

Answer one question: **which habits are rebuilding cache you already paid
for, and what would each fix save?** Prompt caching makes a cache read cost
0.1× and a rebuild cost 1.25× — so every avoidable miss is a ~12× markup on
that slice of context. ccusage and `/cost` count the tokens; cachewise says
*why* the expensive ones happened and *what to change*. The evidence is on
disk — the transcripts recorded every cache write; this skill attributes
them so the numbers, not folklore, drive the fix.

## Step 0 — Run the analyzer

The counting is deterministic and token-free — **never read the raw JSONL
yourself** (parsing thousands of transcript lines with the model is the
exact token burn this skill exists to stop). Run the bundled script:

```bash
python3 .claude/skills/cachewise/scripts/analyze.py --days 30
```

It scans `~/.claude/projects/**/*.jsonl` and prints one JSON document.
No `~/.claude` data (fresh machine, or none in the window) → the script
returns zero turns; say so plainly and stop, there's nothing to diagnose.

Before trusting the numbers, glance at `flags`:
- `pricing_fallback_models` — models priced at the Sonnet-4.x fallback
  because their id wasn't in the table (USD is approximate for those).
- `missing_timestamp_turns` / `malformed_lines` — data the parser skipped;
  large counts mean the picture is partial.

## Step 1 — Read the attribution

The report splits cost three ways — keep them distinct, they prescribe
differently:

- **`miss_attribution`** — cache *rebuilds*, the avoidable core. Each cause
  carries tokens + USD (the money a cache hit would have saved):
  `idle_gap`, `model_switch`, `write_churn`, and `unattributed` (cause
  undeterminable, usually missing timestamps). The USD is *avoidable* spend,
  not total spend.
- **`context_tax`** — not a miss: the standing read-cost of sessions that
  carry far more prefix per turn than your same-model norm. Sprawl, priced
  as excess reads.
- **`dead_session`** — **low-confidence** heuristic: cold re-boots of a
  same-project session soon after another ended. Report it as a lead, not a
  fact — say "possibly" and cite the count.

`totals.usd.total` is the whole API-equivalent spend in the window;
`miss_attribution.total_usd` is the slice that better habits recover.

## Step 2 — Render the report

Present, in chat, most-expensive-first:

1. **Headline** — window, total API-equivalent spend, cache hit rate, and
   the avoidable miss total in USD (e.g. "94% hit rate; **$1,534 of $5,944
   was avoidable cache rebuilds**").
2. **Prescriptions** — walk `prescriptions` in order (already ranked by
   USD). For each: the cause, its dollar cost, the one-line fix from the
   script, and the top offending sessions/projects from `top_offenders` so
   the user sees *where* it happened. Mark `dead_session` and `context_tax`
   as the softer, lower-confidence lines they are.
3. **Caveats** — surface any `flags` that make the numbers approximate, and
   the standing note: for subscription (Pro/Max) users these are
   API-equivalent *values*, not a bill — the ratios still hold, the absolute
   dollars are a yardstick.

Keep it honest: if the hit rate is already high and avoidable spend is a
rounding error, say the setup is healthy rather than manufacturing a
problem.

## Step 3 — Track before/after

Memory is what turns a one-off report into a measurable fix. Append a run
to `out/cachewise/tracker.md` (create it if absent; date via `date +%F`):

```markdown
## <date> · window <N>d
- Spend: $<total> · hit rate <pct>% · avoidable $<miss_total>
- By cause: idle_gap $X · write_churn $Y · model_switch $Z · dead_session $W (low-conf) · context_tax $V
- Prescribed: <the top 1–3 fixes handed to the user this run>
- Since last run: <hit-rate and avoidable-$ delta vs the previous entry, or "baseline">
```

On every run after the first, read the previous entry and lead the report
with the delta — did avoidable spend fall after last run's fix, or not?
A prescription whose number didn't move next run is one to retire or
rethink, not repeat.

## Guardrails

- **The script counts; the model interprets.** Reading raw transcripts into
  context to tally tokens is the waste this skill diagnoses — don't commit
  it. If the script can't answer something, extend the script, not the habit.
- **Avoidable, not total.** Miss USD is what better habits recover, never
  the whole bill — conflating them scares the user off legitimate spend.
- **Confidence is labeled, not implied.** `dead_session` and `context_tax`
  are heuristics; present them as leads. Never state a cause the transcript
  can't support — `unattributed` exists so misses aren't force-fit.
- **Prices carry a date.** The USD table is stamped `pricing_asof`; when it
  ages, reverify against the official pricing page rather than trusting it.
- **Privacy is structural.** Transcripts stay local; only aggregate numbers
  reach the report. `out/cachewise/` holds no prompt content.
Files in this package (3)
  • SKILL.md 6 KB
  • scripts/analyze.py 18 KB
  • scripts/test_analyze.py 18 KB

Versions

The database has no other skills named cachewise.

Database snapshot: 13.11.2026 · package version 7d27ef883d42 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100cache-refund
    Analyze this machine's Claude Code prompt-cache economy and report what the cache saved, what it leaked (attributed to causes), and — for API-billed users on the 5-minute default — whether enabling the 1-hour cache TTL would save money. Use when the user asks about their Claude…
  • 100k-tokens
    Cut Claude Code token use. Audit reads your local transcripts and shows where tokens go (idle cache rewrites, context size, polling, Opus agents). Apply is a one-screen settings choice that merges a few documented keys into ~/.claude/settings.json and adds agent working rules to…
  • 100claude-token-audit
    Show where Claude Code tokens and usage limits go, from the local session logs in ~/.claude/projects. Breaks usage down by project, session, day, model and tool, finds the biggest tool outputs flooding the context, measures cache hit rate and peak context per session, sizes what…
  • 100cache
    Use this skill when the user asks to "enable cache protection", "block on cache miss", "avoid cache expiration cost", "/ar:cache", "protect against compaction", "cache pressure guard", "cache hit ratio threshold", or "set cache-miss threshold". Covers the /ar:cache slash command…
  • 100cache-money
    This skill should be used when the user asks to "keep cache warm", "warm the cache", "save tokens", "reduce token usage", "cache-money", "start cache ping", "optimize peak hours", "prevent cache expiry", or mentions Anthropic prompt caching, cache TTL, peak hour throttling,…
  • 100token-meter
    Live token meter for Claude Code. Shows what every running session is spending right now - context size, window fill, turns left before compaction, cache share, a cold-cache mark, subagent tokens, and calls per tool, MCP server and skill - plus the MCP servers and skills you…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.