Skip to content
affaan-m avatar

Cost Tracking

Reports Claude Code token usage and spend from the local cost-tracker log, with per-session and per-model breakdowns.

CCM score
73 of 100
skills.sh installs
8.6K
GitHub stars
312.6K
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers spend totals, token usage, and budget questions drawn from ~/.claude/metrics/costs.jsonl
  • Reduces cumulative per-session snapshots to the latest row per session before summing, avoiding double counting
  • Prefers the tracker's estimated_cost_usd field over hand-calculated pricing, and checks that the log exists first
  • Designed for users who ask about costs by model, session, or date after the stop:cost-tracker hook is enabled

Install

$ npx -y skills add affaan-m/ecc --skill cost-tracking -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Cost Tracking

Use this skill to analyze Claude Code cost and usage history from the metrics log that ECC's stop:cost-tracker hook writes.

Where the data lives

The tracker appends one JSON object per session-stop to ~/.claude/metrics/costs.jsonl. Each row is a cumulative snapshot for that session, so to total spend you take the latest row per session_id and sum across sessions — summing every row multiply-counts.

ECC also maintains internal per-session files under ~/.claude/metrics/cost-snapshots/ so runtime hooks can read the current session total without rescanning all history. Treat those files as a rebuildable cache; each snapshot stores a byte cursor so only newly appended rows are scanned. Stable reads are O(1), while updates are O(new bytes). Stale entries are pruned after 30 days or when the directory exceeds 512 sessions. Cold catch-up work is limited to 16 MiB per hook invocation, and malformed unterminated rows larger than 1 MiB are discarded with a resumable cursor. Reports and exports should continue to use costs.jsonl.

Row schema:

Details

Repository
github.com/affaan-m/ecc
Category
Agent Workflow & Planning
First seen
Jul 14, 2026

Questions

How do I check how much I have spent on Claude Code with cost-tracking?

The cost-tracking skill reads the local metrics log at ~/.claude/metrics/costs.jsonl, which the stop:cost-tracker hook writes after each session. It reduces the cumulative rows to the latest row per session and reports today's spend, yesterday's spend, the total, and a breakdown by model. If the log is missing, it tells you cost tracking populates after the first session ends with the hook enabled.

How do I install the cost-tracking skill?

Run npx -y skills add affaan-m/ecc --skill cost-tracking -y in your project to install it. After that, the agent can answer questions about Claude Code token usage, spending, budgets, and cost breakdowns by model, session, or date.

What does cost-tracking need before it can report anything?

It needs the ECC stop:cost-tracker hook enabled, because the hook writes the costs.jsonl log the skill reads. It uses node to check and read that file, so Node.js must be available on your machine.

Which other skills work with cost-tracking?

The skill points to cost-aware-llm-pipeline for model routing and budget design, token-budget-advisor for context and token-budget planning, and strategic-compact for reducing repeated token spend. It also refers to the /cost-report command, which runs a report over the same metrics log.

More from affaan-m/ecc

All 257

Similar to Cost Tracking

More Agent Workflow & Planning