Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

claude-usage-cost

A Claude Code plugin that looks at how you actually work and recommends the plugins and skills that would speed you up — plus honest spend tracking on the side.

  • /optimize — fingerprints your usage (tools, shell verbs, MCP servers, subagents, web use, context weight) and recommends matching plugins/skills from a forkable catalog.json. This is the part nothing else does.
  • /spend [days|--all] — daily token cost by model, across every session (the built-in /cost only shows the current session).
  • Live status line — a 💸 $X today segment for your status line.

Everything runs locally against ~/.claude/projects/**.jsonl. No npm deps, no network.


/optimize — the recommender

/optimize

It builds a usage fingerprint and matches it against rules in catalog.json:

Your fingerprint:
  tools:  Bash·60  Edit·33  Write·20  Read·19  WebFetch·13
  context: cache-read 232.8M  ·  subagents 0  ·  web 13

▸ Your sessions carry heavy context
   try:  headroom (context compression) + fresh sessions
   why:  Millions of cache-read tokens means you re-process a large context
         every turn — usually the biggest slice of spend and latency.
   how:  Compress big tool outputs, and /clear for unrelated tasks.

▸ Heavy shell use = lots of approval prompts
   try:  fewer-permission-prompts skill
   ...

The catalog is the product — fork it

catalog.json maps usage signals → recommendations. Each rule references dot-paths into the fingerprint (scripts/core.jsfingerprint()):

{
  "id": "ship-flow",
  "priority": 2,
  "all": [{ "path": "counts.gitOps", "op": ">=", "value": 8 }],
  "title": "You run a lot of git/gh by hand",
  "recommend": "compound-engineering:ce-commit-push-pr",
  "why": "...",
  "how": "..."
}
  • all = every condition must hold; any = at least one. op> >= < <= ==.
  • Lower priority shows first; ties break on how strongly the rule fired.

Fork the catalog to add your own or your team's signal→plugin rules — that's the "plug-and-play" hook. The engine is data-driven; no code changes needed to retune recommendations.

Available signal paths: tools.<Name> (Bash, Edit, Read, Write, WebFetch, Grep, Glob, MCP, Task…), bashVerbs.<verb>, mcpServers.<server>, counts.{subagents,webFetches,webSearches,editWrite,bashCalls,gitOps,testOps,pkgOps,dockerOps,mcpCalls,cacheReadTokens,cacheWriteTokens,outputTokens}, meta.totalToolCalls.


/spend — daily cost by model

/spend          # last 7 days
/spend 30       # last 30 days
/spend --all    # every day on record

Pricing is USD per 1,000,000 tokens. Cache tokens are billed off the model's input rate: cache write ×1.25 (5m) / ×2 (1h), cache read ×0.1. Web search is $10 per 1,000 requests on top of tokens (web fetch has no per-request fee).

Model Input $/1M Output $/1M
Fable 5 10 50
Opus 4.8 / 4.7 / 4.6 / 4.5 5 25
Sonnet 5 3 (2 intro → 2026-08-31) 15 (10 intro)
Sonnet 4.6 / 4.5 3 15
Haiku 4.5 1 5

Messages are deduped by message id; unknown/<synthetic> models are skipped. These are estimates from local token counts, not a billed invoice.


Live status line (today's spend)

Two variants print 💸 $X today, both cached 30s and (on cold recompute) only reading transcripts modified today:

  • scripts/statusline.js (Node) — recommended on Windows (~1s).
  • scripts/statusline.sh (bash + jq) — faster on Linux/macOS; on Windows it's slower (~10s) because Git Bash find + jq -s dominate.

Claude Code allows one statusLine command. If you have none:

{ "statusLine": { "type": "command",
  "command": "node \"/path/to/usage-cost-plugin/scripts/statusline.js\"" } }

If you already have one (e.g. a headroom indicator), chain them — feed stdin to both and join:

#!/usr/bin/env bash
input="$(cat)"
base="$(printf '%s' "$input" | bash "/path/to/your-existing-statusline.sh" 2>/dev/null)"
seg="$(printf '%s'  "$input" | node "/path/to/usage-cost-plugin/scripts/statusline.js" 2>/dev/null)"
[ -n "$seg" ] && printf '%s · %s' "$base" "$seg" || printf '%s' "$base"

Install

/plugin marketplace add Atishyy27/usage-cost-plugin
/plugin install claude-usage-cost@usage-cost-tools
/reload-plugins

Local development:

/plugin marketplace add /path/to/usage-cost-plugin
/plugin install claude-usage-cost@usage-cost-tools

Caveats

  • The fingerprint reflects how Claude works for you (plus assistant quirks like shell choice) — a proxy for your workflow, not a clean read of intent.
  • Recommendations sharpen as you accumulate real usage; a thin sample gives rough suggestions.
  • Spend figures are estimates, not billing.

Requirements

Node.js (ships with Claude Code). /spend's bash status line also needs jq.

License

MIT

About

Claude Code plugin: /cost command + live status line estimating your daily token spend by model, from local session transcripts.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages