Cost Tracking Skill
- Installs
- 9.1k
- Repo stars
- 316k
- Repo updated
- Dec 1, 2026
TL;DR
cost-tracking is a Claude Code skill that reports token usage, session costs, and spending trends from a local SQLite metrics database for developers who need Claude Code budget visibility.
Install if
Developers using Claude Code with a local cost-tracking hook writing to ~/.claude-cost-tracker/usage.db who need spend visibility.
Skip if
Teams without the cost-tracking hook installed or developers asking about API billing outside the local Claude Code metrics database.
npx skills add https://github.com/affaan-m/ECC --skill cost-trackingTry it first through the Skillselion MCP - nothing to install, nothing on disk.
1. Add the remote connector:
claude mcp add --transport http skillselion https://mcp.skillselion.com/mcp2. Ask your agent:
Use Skillselion load_skill to load skill:affaan-m/ecc#cost-tracking (Cost Tracking) and follow it.Try it first through the Skillselion MCP - nothing to install, nothing on disk.
1. Add this URL as a custom connector (Claude.ai, ChatGPT or Cursor):
https://mcp.skillselion.com/mcp2. Ask your agent:
Use Skillselion load_skill to load skill:affaan-m/ecc#cost-tracking (Cost Tracking) and follow it.What cost-tracking covers
- Analyzes ~/.claude/metrics/costs.jsonl without double-counting cumulative snapshots
- Reports breakdowns by model, session, date, or budget threshold
- Uses precomputed estimated_cost_usd as the single source of truth
- Handles cache-write and cache-read token accounting
- Triggered automatically when the user asks about costs, tokens, or budgets
cost-tracking by the numbers
| All-time installs | 9,125 | skills.sh registry |
|---|---|---|
| Repo stars | ★ 316k | GitHub |
| Repo last updated | December 1, 2026 | GitHub |
| Repository | affaan-m/ECC ↗ | |
Data as of Dec 4, 2026 (Skillselion catalog sync)
- Stores usage metrics in ~/.claude-cost-tracker/usage.db
- Originated from community PR #1304 by MayurBhavsar
What does the Cost Tracking skill produce?
Cost breakdowns, spending trend summaries, budget status answers, and optional CSV exports of recent usage rows.
- Cost breakdown reports
- Spending trend summaries
- CSV usage exports
What files ship with cost-tracking?
コスト追跡
このスキルを使用して、ローカルSQLiteデータベースからClaude Codeのコストと使用履歴を分析します。これは、~/.claude-cost-tracker/usage.dbに使用行を書き込むコスト追跡フックまたはプラグインをすでに持っているユーザーを対象としています。
出典: MayurBhavsarによるコミュニティのPR #1304から救済されました。
使用時期
- ユーザーが「いくら使いましたか?」「このセッションのコストは?」「トークン使用量は?」と尋ねる場合
- ユーザーが予算、支出制限、超過、またはコスト管理について言及する場合
- ユーザーがプロジェクト、ツール、セッション、モデル、または日付ごとのコスト内訳を求める場合
- ユーザーが今日と昨日を比較したい、または最近のトレンドを確認したい場合
- ユーザーが最近の使用記録のCSVエクスポートを求める場合
動作方法
まず前提条件を確認します:
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"データベースが見つからない場合、使用データを作成しません。ユーザーにコスト追跡が設定されていないことを伝え、信頼できるローカルコスト追跡フック/プラグインのインストールまたは有効化を提案します。
期待されるusageテーブルには通常、ツール呼び出しまたはモデルインタラクションごとに1行が含まれます。列名はトラッカーによって異なりますが、以下の例では次のように仮定します:
| 列 | 意味 |
|---|---|
timestamp | 使用イベントのISOタイムスタンプ |
project | プロジェクトまたはリポジトリ名 |
tool_name | ツールまたはイベント名 |
input_tokens | 記録された場合の入力トークン数 |
output_tokens | 記録された場合の出力トークン数 |
cost_usd | USDで事前計算されたコスト |
session_id | Claude Codeセッション識別子 |
model | イベントに使用されたモデル |
cost_usdを使用して手動で価格計算するよりも優先します。モデルの価格とキャッシュ価格は時間とともに変化し、トラッカーが各行の価格設定の信頼できる情報源であるべきです。
例
クイックサマリー
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;
"プロジェクト別コスト
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;
"ツール別コスト
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;
"過去7日間
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;
"セッション詳細
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;
"レポートガイダンス
コストデータを表示する場合、以下を含めます:
- 今日の支出と昨日の比較。
- 追跡されたデータベース全体の合計支出。
- コスト順にランク付けされた上位プロジェクト。
- コスト順にランク付けされた上位ツール。
- 十分なデータがある場合のセッション数とセッションごとの平均コスト。
少額の場合、通貨を小数点4桁でフォーマットします。大きな金額には2桁で十分です。
アンチパターン
cost_usdが存在する場合に生のトークン数からコストを推定しないこと。- 確認せずにデータベースが存在すると仮定しないこと。
- 大規模なデータベースで無制限の
SELECT *エクスポートを実行しないこと。 - ユーザー向けの回答で現在のモデル価格をハードコードしないこと。
- 任意のコードを実行する未審査のフックやプラグインのインストールを推奨しないこと。
関連
/cost-report- 同じデータベースを使用するコマンド形式のレポート。cost-aware-llm-pipeline- モデルルーティングと予算設計のパターン。token-budget-advisor- コンテキストとトークン予算の計画。strategic-compact- 繰り返しのトークン支出を削減するためのコンテキスト圧縮。
Which skills are related to cost-tracking?
What are the Cost Tracking skill forks?
Cost Tracking has 1 known copy in the catalog totaling 2.2k installs. They canonicalize to this original listing.
- affaan-m - 2.2k installs
Cost Tracking skill FAQ
Who is the Cost Tracking skill for?
Developers using Claude Code with a local cost-tracking hook writing to ~/.claude-cost-tracker/usage.db who need spend visibility. Skip if: Teams without the cost-tracking hook installed or developers asking about API billing outside the local Claude Code metrics database.
When should I use cost-tracking?
User asks about Claude Code cost, token usage, budget limits, spending trends, or per-project usage breakdowns.
Where does cost-tracking read Claude Code usage data?
cost-tracking reads from the local SQLite database at ~/.claude-cost-tracker/usage.db, which must be populated by an installed Claude Code cost-tracking hook or plugin.
What cost questions can cost-tracking answer?
cost-tracking answers session cost, token totals, budget status, overages, and breakdowns by project, tool, model, and date, plus day-over-day trend comparisons and CSV exports.
Add a cost-tracking badge
Show developers this skill is listed on Skillselion. Paste this into your README.