cost-analysis — Claude Code Plugin
Analyze your Claude Code token usage and costs from local session data. See exactly what you spent, by project, model, and day — including which sessions didn't need Opus and how much MCP servers are costing you.
What it does
- Project breakdown — cost, tokens, session count per project
- Top sessions — most expensive sessions with the prompts that triggered them
- Model breakdown — spend per model (Opus vs Sonnet vs Haiku)
- Daily spend — ASCII bar chart of spend over time
- Token cost breakdown — shows how much cache write vs cache read vs output vs input tokens cost (cache write is usually the dominant driver)
- Model recommendations — classifies each project's work type and tells you which ones didn't need Opus, with estimated savings
- MCP analysis (
--mcp) — deep dive into MCP server overhead: tool result sizes, schema bloat, cost impact, and optimization recommendations
- Run history — compares current totals to your last run (cost, session count, date) in the report header
- Weekly reminder — surfaces a prompt at session start if it's been 7+ days since your last analysis
Installation
Run these two commands in your terminal:
claude plugin marketplace add https://github.com/ChintanTurakhia/cost-analysis.git
claude plugin install cost-analysis@cost-analysis
Then launch Claude.
OR
Run these two commands in inside Claude:
/plugin marketplace add https://github.com/ChintanTurakhia/cost-analysis.git
/plugin install cost-analysis@cost-analysis
Then restart Claude Code (quit and reopen — /reload-plugins is not sufficient).
To update later:
claude plugin update cost-analysis@cost-analysis
Verify installation
After restarting Claude Code, run:
/cost-analysis:analyze --days 1
If you see a cost report (even with zero sessions), the plugin is working.
Usage
Basic cost analysis:
/cost-analysis:analyze # all sessions, full breakdown
/cost-analysis:analyze --days 7 # last 7 days only
/cost-analysis:analyze --days 30 # last 30 days
/cost-analysis:analyze --since 2026-03-01 # from a specific date
/cost-analysis:analyze --since 2026-03-01 --until 2026-03-15 # explicit date range
/cost-analysis:analyze --project my-project # filter to one project
/cost-analysis:analyze --days 7 --top 5 # last week, top 5 sessions
/cost-analysis:analyze --model opus # only Opus sessions
/cost-analysis:analyze --budget 500 # show pace vs $500/month budget
/cost-analysis:analyze --save ~/reports/march.md # save report to file
MCP overhead analysis:
/cost-analysis:analyze --mcp # full MCP overhead report
/cost-analysis:analyze --mcp --days 30 # MCP analysis for last 30 days
/cost-analysis:analyze --mcp --mcp-server glean-hosted # filter to one MCP server
Flags
| Flag | Description | Default |
|---|
--days N | Only include sessions from the last N days | all time |
--since YYYY-MM-DD | Include only sessions on or after this date | — |
--until YYYY-MM-DD | Include only sessions on or before this date | — |
--project name | Filter to sessions matching this project name | all projects |
--model name | Filter to sessions that used this model | all models |
--top N | Show only the top N most expensive sessions | 10 |
--mcp | Show MCP server overhead analysis | off |
--mcp-server name | Filter MCP analysis to a specific server (implies --mcp) | all servers |
--max-sessions N | Hard cap on session count (keeps most recent) | unlimited |
--save [path] | Write the full report to a markdown file | not saved |
--budget N | Set a monthly spending threshold for pace tracking | — |
MCP analysis
MCP (Model Context Protocol) servers are a significant hidden cost driver. They load full tool schemas into context on session start (~15K+ tokens per server), and their tool results are often 100-300x larger than native tool results.
The --mcp flag reveals: