Skip to main content
skill CX Codex

cost-breakdown — Claude Code skill for cost analysis

This skill reports model and session costs, daily spending trends, and token efficiency. Use it to compare model pricing or plan a budget.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-breakdown -a claude-code
Open on GitHub

What cost-breakdown does

The skill reads pricing, total costs, session costs, and daily statistics from Agent Monitor. Its Markdown report breaks spending down by model and session, lists the most expensive sessions, and reviews token efficiency. Currency is shown in USD to four decimal places.

Costs include input and output tokens, plus cache reads and writes. The report also examines baseline tokens preserved across compaction; without those baselines, earlier tokens could be lost when a transcript is rewritten. The report relies on Agent Monitor API data, so its figures depend on that data.

What it helps with

  • compare model costs by token type
  • identify the most expensive sessions
  • track daily spending trends
  • review cache reads and tokens recovered from baselines
  • spot sessions with costly models or frequent compaction

Example prompts for the agent

  • Break down this week's costs and compare models.
  • Show the most expensive sessions from the last 30 days.
  • Check cache reads and tokens preserved through compaction.

How to install cost-breakdown

1Skills CLI (Vercel)

npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-breakdown -a claude-code

2Manually: put the files in place

~/.claude/skills/cost-breakdown/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/cost-breakdown/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about cost-breakdown

How do I install cost-breakdown in Claude Code?

Run npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill cost-breakdown -a claude-code. The skill file is at ~/.claude/skills/cost-breakdown/SKILL.md.

What does cost-breakdown do?

It creates a report of spending by model and session, daily trends, and token usage. It also covers baseline token recovery after compaction.

How does cost-breakdown calculate token costs?

It applies separate rates for input, output, cache-read, and cache-write tokens. Effective totals add current counts to baseline counts preserved across compaction.

Source text

SKILL.md · MIT
---
name: cost-breakdown
description: >
  Break down Claude Code costs using the Agent Monitor pricing engine.
  Shows per-model costs (input, output, cache_read, cache_write at $/Mtok rates),
  per-session costs, daily trends, and compaction baseline token recovery.
  Use when analyzing spending, comparing model costs, or planning budgets.
---

# Cost Breakdown

Detailed cost analysis from the Agent Monitor's pricing engine.

## Input

The user provides: **$ARGUMENTS**

This may be: "today", "this week", "last 30 days", a session ID, or "budget $50/week".

## Data Sources

| Endpoint | Returns |
|----------|---------|
| `GET /api/pricing` | `{ pricing: [{ model_pattern, display_name, input_per_mtok, output_per_mtok, cache_read_per_mtok, cache_write_per_mtok }] }` |
| `GET /api/pricing/cost` | Total cost: `{ total_cost, breakdown: [{ model, input_tokens, output_tokens, cache_read_tokens, cache_write_tokens, cost, matched_rule }] }` |
| `GET /api/pricing/cost/{sessionId}` | Per-session cost with same breakdown shape |
| `GET /api/sessions?limit=200` | Sessions list — each includes inline `cost` field (bulk pricing) |
| `GET /api/analytics` | Token totals (total_input, total_output, total_cache_read, total_cache_write — baselines pre-summed), daily trends |

### How costs are calculated

The pricing engine matches model names against `model_pattern` using SQL LIKE (e.g. `claude-sonnet-4-5%` matches `claude-sonnet-4-5-20250514`). **Longest pattern wins** for specificity. Cost per model:

```
cost = (input_tokens / 1M) × input_per_mtok
     + (output_tokens / 1M) × output_per_mtok
     + (cache_read_tokens / 1M) × cache_read_per_mtok
     + (cache_write_tokens / 1M) × cache_write_per_mtok
```

Token counts are **effective totals** = `current + baseline` (baselines preserve pre-compaction tokens that would otherwise be lost when the transcript JSONL is rewritten).

### Default pricing tiers (seeded on first run)

| Family | Input $/Mtok | Output $/Mtok | Cache Read $/Mtok | Cache Write $/Mtok |
|--------|-------------|--------------|-------------------|-------------------|
| Opus 4.5/4.6 | $5 | $25 | $0.50 | $6.25 |
| Sonnet 4/4.5/4.6 | $3 | $15 | $0.30 | $3.75 |
| Haiku 4.5 | $1 | $5 | $0.10 | $1.25 |

## Report Sections

### 1. Cost by Model
Table from `/api/pricing/cost` breakdown — each model with 4 token counts + cost. Highlight which pricing rule matched.

### 2. Cost by Session (Top 10 Most Expensive)
From sessions list with inline `cost` — sort descending. Show session name, model, duration, cost.

### 3. Daily Cost Trend
Cross-reference `daily_sessions` with per-session costs to compute daily spend. Show 7/30-day trend with direction arrows.

### 4. Token Efficiency Analysis
- **Cache hit rate**: `total_cache_read / (total_cache_read + total_input) × 100` — higher = more efficient
- **Compaction baseline recovery**: Tokens preserved via baseline columns (tokens not lost to compaction)
- **Output/input ratio**: Balanced ratio indicates good prompt efficiency

### 5. Cost Optimization Opportunities
- Sessions where cache_write >> cache_read (poor cache reuse)
- Expensive models used for simple tasks (check subagent_type vs model)
- Sessions with many compactions (context overflow = wasted tokens)

## Output

Structured Markdown with tables. Currency as USD to 4 decimal places. Include total and per-model subtotals.

© hoangsonww · MIT · hoangsonww/Claude-Code-Agent-Monitor

Similar skills

All skills for Finance and business →

From the same set60

mcp-audit Audits user- and project-scoped MCP servers via the Agent Monitor API. Identifies transport issues, duplicate configurations, and external HTTP endpoints. CX Codex +1 ★ 1,121repo stars hook-inventory Inventories configured hooks and scripts in ~/.claude/hooks, then flags network activity and risky commands. Use it to review hook safety. CX Codex +1 ★ 1,121repo stars config-audit Walks your ~/.claude setup and reports what has piled up: skills, subagents, hooks, duplicates and risky shell commands. CX Codex +1 ★ 1,121repo stars usage-trends Tracks Claude Code session history, token consumption, and tool frequency through Agent Monitor API endpoints. Useful for diagnosing agent errors and checking cache efficiency over 365 days. CX Codex +1 ★ 1,121repo stars session-report Builds a Markdown report for a session or date range, covering model usage, costs, agents, and events. Useful when you need to inspect what happened during a run. CX Codex +1 ★ 1,121repo stars productivity-score Turns Agent Monitor metrics into a 0–100 productivity scorecard: session completion, cache efficiency, turn speed, tool success and cost. CX Codex +1 ★ 1,121repo stars model-mix Breaks down Claude Code token usage and spend across Opus, Sonnet, and Haiku via Agent Monitor to spot expensive models doing low-complexity tasks. CX Codex +1 ★ 1,121repo stars cache-efficiency The skill works out whether prompt caching pays off: hit rate, write-versus-read reuse, and what each side costs in dollars. CX Codex +1 ★ 1,121repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor