cost-tracking

A tool for reading Claude Code token usage and spending from a local SQLite database, a small file-based database. It can organize usage by project, tool, session, model, or date.

In plain words
What is it for?
Use it to check spending, token usage, budgets, recent trends, or cost breakdowns, and to export recent usage records as CSV.
Why use it?
It gives you a way to inspect costs and token use instead of estimating them. It requires an existing local tracking database and does not create missing usage data.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/junmystery/agent-guidance-python/cost-tracking
Any agent
npx skills add JunMystery/Agent-Guidance-Python --skill cost-tracking
Clone the repo
git clone --depth 1 https://github.com/JunMystery/Agent-Guidance-Python

Made for: Claude Code, Codex.

Per session 54 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,139 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00054 $0.01139
Opus 5 $0.00027 $0.00570
Sonnet 5 $0.00011 $0.00228
Haiku 4.5 $0.00005 $0.00114

Measured 2d ago against content hash c48d78c1af32, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

cost-tracking scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Unrestricted tool accessmediumExcessive agency

A wildcard tool grant or "run any command" leaves no least-privilege boundary at all.

- Do not recommend installing unreviewed hooks or plugins that execute arbitrary code.
skills/cost-tracking/SKILL.md · 148 lines

How it starts

The opening of the file, as written. The whole thing — 148 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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:

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

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;
"

Read the full file on GitHub · 148 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 148 lines · 54 tokens per session scan B c48d78c1af32

Subscribe to this mod's changes

cost-tracking is a skill published in the GitHub repository JunMystery/Agent-Guidance-Python (2 stars, last pushed 1mo ago), licensed MIT. It adds 54 tokens to every session and 1,139 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it B with 1 finding (unrestricted tool access). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

crypto-data

Use for any crypto data question — token/coin prices, FX, commodities, stocks, OHLC history, DEX pairs and liquidity, DeFi TVL, yield/APY pools, on-chain SQL, wallet labels and net worth, social mindshare, news, or raw JSON-RPC against a chain. Routes across five tools that overlap heavily, so it also says which one…

BlockRunAI/blockrun-mcp · 170 tokens

signal-to-trade-demo

Prepare or run a polished BlockRun trading demo that discovers a current Polymarket market, combines live price, probability history, smart-money, and liquidity evidence into a balanced signal, produces a real order dry-run, and verifies orders or positions. Use for live demos, signal-to-trade workflows, current…

BlockRunAI/blockrun-mcp · 88 tokens

ib-collar

Generate tactical collar strategy reports for protecting PMCC positions through earnings or high-risk events. Requires TWS or IB Gateway running locally.

staskh/trading_skills · 30 tokens

technical-analysis

Compute technical indicators like RSI, MACD, Bollinger Bands, SMA, EMA for a stock. Use when user asks about technical analysis, indicators, RSI, MACD, moving averages, overbought/oversold, or chart analysis.

staskh/trading_skills · 52 tokens

ib-report-delta-adjusted-notional-exposure

Report delta-adjusted notional exposure across all IBKR accounts. Calculates option deltas using Black-Scholes and reports long/short exposure by account and underlying. Use when user asks about delta exposure, portfolio risk, or directional exposure.

staskh/trading_skills · 58 tokens

report-stock

Generate comprehensive stock analysis report (PDF or markdown) with trend, PMCC, and fundamental analysis.

staskh/trading_skills · 22 tokens