Token usage and cost analysis for Claude Code sessions with personalized savings recommendations
npx claudepluginhub chintanturakhia/cost-analysisAnalyze Claude Code token usage and costs from local session data. Breaks down spend by project, model, and day. Includes model recommendations showing which sessions didn't need Opus. Analyzes MCP server overhead, tool result sizes, and context bloat.
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.
--mcp) — deep dive into MCP server overhead: tool result sizes, schema bloat, cost impact, and optimization recommendationsRun 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
After restarting Claude Code, run:
/cost-analysis:analyze --days 1
If you see a cost report (even with zero sessions), the plugin is working.
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
| 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 (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: