fix(claude-usage-report): price cache-writes at their actual TTL#8
Open
goneflyin wants to merge 3 commits into
Open
fix(claude-usage-report): price cache-writes at their actual TTL#8goneflyin wants to merge 3 commits into
goneflyin wants to merge 3 commits into
Conversation
A plugin entry that combined a bare relative-string source
("./skills/claude-usage-report") with a skills array ([".") tripped
Claude Code's plugin resolver into its default: throw, surfaced as a
misleading "update Claude Code" error. Switch to the git-subdir object
form used by other skill-bearing marketplaces.
After merge, re-pull with `/plugin marketplace update 7factor` (the
local marketplaces copy is a cache).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…yout
The git-subdir source from the prior attempt made the plugin resolver
throw its generic "source type your Claude Code version does not support"
error, even on the latest Claude Code (2.1.212). That message is a
misleading catch-all the resolver emits when it can't process an entry.
Two coupled problems were feeding the throw:
1. the `git-subdir` object source, and
2. `skills: ["."]`, which trips the "Path escapes plugin directory"
loader bug (same issue nicobailon/visual-explainer hit).
`skills: ["."]` existed because SKILL.md sat at the plugin root, so the
default `skills/` scan found nothing. Fix both by matching the
conventional layout:
- move the skill (SKILL.md + usage_report.py + update_pricing.py +
prices.json) into skills/claude-usage-report/skills/claude-usage-report/
so the default scan finds it; drop the `skills` field entirely.
- set the plugin source to the plain relative path
"./skills/claude-usage-report" (the original, universally-supported
form; resolves against the cloned marketplace repo).
record_account.sh/.py, hooks/hooks.json, and .claude-plugin/plugin.json
stay at the plugin root, so ${CLAUDE_PLUGIN_ROOT}/record_account.sh and
the existing settings.json hook path keep working.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The parser costed every cache-write token at the 5-minute TTL rate (1.25x input), ignoring the 5m/1h split that each transcript records in its `cache_creation` object. In practice most Claude Code cache-writes use the 1-hour TTL (2x input), so reports under-counted materially — a 16-day sample came out ~$509 when the TTL-correct figure was ~$599. - usage_report.py: read `ephemeral_5m_input_tokens` / `ephemeral_1h_input_tokens` per message and cost each at `cw` / `cw_1h`; fall back to the combined field (as 5m) for legacy transcripts, and to 2x input when a price record omits `cw_1h`. Fix a token double-count in the per-session total introduced by the new fields. RATES output now shows both cache-write columns. - prices.json: add explicit `cw_1h` (= 2x input) to the models that lacked it; document the field in the header comment. - SKILL.md: add the 1h column to the reference table and replace the stale "assumes 5-minute TTL" caveat. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
goneflyin
force-pushed
the
fix/usage-report-cache-ttl
branch
from
July 17, 2026 02:12
127f4bb to
955f4f6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
claude-usage-reportparser costed every cache-write token at the 5-minute TTL rate (1.25× input), ignoring the 5m/1h split that each transcript records in itscache_creationobject. Most Claude Code cache-writes actually use the 1-hour TTL (2× input), so reports materially under-counted cache-write spend.Impact on a real 16-day sample: the report read ~$509 when the TTL-correct figure was ~$599 — an $89 undercount, entirely Opus 1-hour cache writes.
Changes
usage_report.py— readephemeral_5m_input_tokens/ephemeral_1h_input_tokensper message and cost each atcw/cw_1h. Falls back to the combinedcache_creation_input_tokens(as 5m) for legacy transcripts, and to 2× input when a price record omitscw_1h. Also fixes a token double-count in the per-session total that the new fields introduced. RATES output now prints both cache-write columns.prices.json— add explicitcw_1h(= 2× input) to the models that lacked it; document the field in the header comment.SKILL.md— add the 1h column to the reference table and replace the stale "assumes 5-minute TTL" caveat.Notes
Branched off
fix/marketplace-source-format(PR #7), so until that merges this PR's diff also contains the marketplace-source fix.🤖 Generated with Claude Code