
Cost Tracking
Inspect Claude Code token spend and usage trends from a local SQLite log when you need budgets, session costs, or exports without guessing from chat.
Overview
Cost Tracking is an agent skill for the Operate phase that reports Claude Code token usage and spend from your local ~/.claude-cost-tracker/usage.db SQLite database.
Install
npx skills add https://github.com/affaan-m/everything-claude-code --skill cost-trackingWhat is this skill?
- Verifies sqlite3 and ~/.claude-cost-tracker/usage.db before any query—never fabricates usage if tracking is not configur
- Breaks down spend and tokens by project, tool, session, model, and date
- Compares today vs yesterday and surfaces recent usage trends
- Exports recent usage records to CSV on request
- Explicitly tied to Claude Code local cost-tracking hooks/plugins (community origin from PR #1304 pattern)
- Reads from local path ~/.claude-cost-tracker/usage.db
- Typical usage table: one row per tool call or model invocation
- Supports breakdown by project, tool, session, model, and date
Adoption & trust: 1.1k installs on skills.sh; 210k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are running Claude Code heavily but only have vague chat memory of token use, with no trustworthy breakdown by session, project, or tool.
Who is it for?
Claude Code users who already have a cost-tracking hook writing to usage.db and want quick spend answers, trends, and exports in the agent.
Skip if: Anyone without a configured local cost database, or teams that need authoritative cloud invoices instead of hook-level usage rows.
When should I use this skill?
The user asks about costs, spending, usage, tokens, budgets, cost breakdowns by project/tool/session/date, trends, or CSV export of Claude Code usage.
What do I get? / Deliverables
You get verified SQLite-backed cost and usage reports—or a clear message that tracking is not configured—plus optional CSV export for budgeting and review.
- Spend and token usage summary for the requested scope
- Dimensional breakdown (project, tool, session, model, date)
- Optional CSV export of recent usage records
Recommended Skills
Journey fit
Cost and usage questions arise after you are actively running an agent setup in production-like daily use, not while ideating a product. Monitoring fits because the skill reads historical usage rows and reports spend, overruns, and trends rather than changing code or shipping features.
How it compares
Local hook-driven SQLite reporting for day-to-day agent spend, not a substitute for vendor billing dashboards or invented usage from chat history.
Common Questions / FAQ
Who is cost-tracking for?
Solo and indie builders using Claude Code who enabled a local cost-tracking hook or plugin and want the agent to query real usage rows instead of estimating from memory.
When should I use cost-tracking?
Use it when you ask about spending, token usage, budgets, overruns, or breakdowns by project, tool, session, model, or date—and when you want today vs yesterday trends or a CSV export of recent records.
Is cost-tracking safe to install?
It is read-oriented analysis of your own machine-local database; review the Security Audits panel on this Prism page and only enable hooks or plugins you trust to write usage data.
SKILL.md
READMESKILL.md - Cost Tracking
# Cost Tracking Use this skill to analyze Claude Code cost and usage history from a local SQLite database. It is intended for users who already have a cost-tracking hook or plugin writing usage rows to `~/.claude-cost-tracker/usage.db`. Source: salvaged from stale community PR #1304 by `MayurBhavsar`. ## When to Use - The user asks "how much have I spent?", "what did this session cost?", or "what is my token usage?" - The user mentions budgets, spending limits, overruns, or cost controls. - The user wants a cost breakdown by project, tool, session, model, or date. - The user wants to compare today against yesterday or inspect a recent trend. - The user asks for a CSV export of recent usage records. ## How It Works First verify prerequisites: ```bash command -v sqlite3 >/dev/null && echo "sqlite3 available" || echo "sqlite3 missing" test -f ~/.claude-cost-tracker/usage.db && echo "Database found" || echo "Database not found" ``` If the database is missing, do not fabricate usage data. Tell the user that cost tracking is not configured and suggest installing or enabling a trusted local cost-tracking hook/plugin. The expected `usage` table usually contains one row per tool call or model interaction. Column names vary by tracker, but the examples below assume: | Column | Meaning | | --- | --- | | `timestamp` | ISO timestamp for the usage event | | `project` | Project or repository name | | `tool_name` | Tool or event name | | `input_tokens` | Input token count, when recorded | | `output_tokens` | Output token count, when recorded | | `cost_usd` | Precomputed cost in USD | | `session_id` | Claude Code session identifier | | `model` | Model used for the event | Prefer `cost_usd` over hand-calculating pricing. Model prices and cache pricing change over time, and the tracker should be the source of truth for how each row was priced. ## Examples ### Quick Summary ```bash sqlite3 ~/.claude-cost-tracker/usage.db " SELECT 'Today: $' || ROUND(COALESCE(SUM(CASE WHEN date(timestamp) = date('now') THEN cost_usd END), 0), 4) || ' | Total: $' || ROUND(COALESCE(SUM(cost_usd), 0), 4) || ' | Calls: ' || COUNT(*) || ' | Sessions: ' || COUNT(DISTINCT session_id) FROM usage; " ``` ### Cost By Project ```bash sqlite3 -header -column ~/.claude-cost-tracker/usage.db " SELECT project, ROUND(SUM(cost_usd), 4) AS cost, COUNT(*) AS calls FROM usage GROUP BY project ORDER BY cost DESC; " ``` ### Cost By Tool ```bash sqlite3 -header -column ~/.claude-cost-tracker/usage.db " SELECT tool_name, ROUND(SUM(cost_usd), 4) AS cost, COUNT(*) AS calls FROM usage GROUP BY tool_name ORDER BY cost DESC; " ``` ### Last Seven Days ```bash sqlite3 -header -column ~/.claude-cost-tracker/usage.db " SELECT date(timestamp) AS date, ROUND(SUM(cost_usd), 4) AS cost, COUNT(*) AS calls FROM usage GROUP BY date(timestamp) ORDER BY date DESC LIMIT 7; " ``` ### Session Drilldown ```bash sqlite3 -header -column ~/.claude-cost-tracker/usage.db " SELECT session_id, MIN(timestamp) AS started, MAX(timestamp) AS ended, ROUND(SUM(cost_usd), 4) AS cost, COUNT(*) AS calls FROM usage GROUP BY session_id ORDER BY started DESC LIMIT 10; " ``` ## Reporting Guidance When presenting cost data, include: 1. Today's spend and yesterday comparison. 2. Total spend across the tracked database. 3. Top projects ranked by cost. 4. Top tools ranked by cost. 5. Session count and average cost per session when enough data exists. For small amounts, format currency with four decimal places. For larger amounts, two decimals are enough. ## Anti-Patterns - Do not estimate costs from raw token counts when `cost_usd` is present. - Do not