# cost-tracking

> Claude/Codex skill by [@affaan-m](https://github.com/affaan-m) · 283k stars · Updated 2026-10-15

Track and report Claude Code token usage, spending, and budgets from the local ECC cost-tracker metrics log. Use when the user asks about costs, spending, usage, tokens, budgets, or cost breakdowns by model, session, or date.

Tags: ai-agents, anthropic, claude, claude-code, developer-tools, llm, mcp, productivity

## Install

```sh
git clone https://github.com/affaan-m/ECC /tmp/ECC && ln -s /tmp/ECC/skills/cost-tracking ~/.claude/skills/cost-tracking
```

## From README

Cost Tracking Use this skill to analyze Claude Code cost and 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 sessionid 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.

## Links

- HTML page: https://omgskills.com/library/affaan-m/ecc/cost-tracking/
- GitHub: https://github.com/affaan-m/ECC
- Author: [@affaan-m](https://github.com/affaan-m)

## More from this repo

- [api-design](https://omgskills.com/library/affaan-m/ecc/api-design/index.md) — REST API design patterns including resource naming, status codes, pagination, filtering, error responses, versioning,...
   - [@affaan-m](https://github.com/affaan-m) · 283k stars
- [article-writing](https://omgskills.com/library/affaan-m/ecc/article-writing/index.md) — Used to write articles, guides, blog posts, tutorials, newsletter issues, and other long-form content in a distinctive...
   - [@affaan-m](https://github.com/affaan-m) · 283k stars
- [brand-voice](https://omgskills.com/library/affaan-m/ecc/brand-voice/index.md) — Used to build a source-derived writing style profile from real posts, essays, launch notes, docs, or site copy, then...
   - [@affaan-m](https://github.com/affaan-m) · 283k stars
