Agent skill

Cost Tracking

by affaan-m in affaan-m/ECC

ローカルのコスト追跡データベースからClaude Codeのトークン使用量、支出、予算を追跡・レポートします。コスト、支出、使用量、トークン、予算、またはプロジェクト、ツール、セッション、日付によるコスト内訳について質問する場合に使用します。

MITAuto-check passedAI & LLM Engineering

Install Cost Tracking

skills CLI
$ npx skills add affaan-m/ECC --skill cost-tracking -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install affaan-m/ECC cost-tracking --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/affaan-m/ECC.git skills-src && mkdir -p .claude/skills && cp -r skills-src/docs/ja-JP/skills/cost-tracking .claude/skills/cost-tracking && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cost-tracking
GitHub stars
276k
Token cost
~829 tokens
SKILL.md length
71 words
Files
1
Skills in repo
683
Repo updated
First seen
Licence
MIT

At a glance

ローカルのコスト追跡データベースからClaude Codeのトークン使用量、支出、予算を追跡・レポートします。コスト、支出、使用量、トークン、予算、またはプロジェクト、ツール、セッション、日付によるコスト内訳について質問する場合に使用します。

  • Works in 5 steps: 今日の支出と昨日の比較。 → 追跡されたデータベース全体の合計支出。 → コスト順にランク付けされた上位プロジェクト。 → …
  • Tasks that involve LLM cost and token optimization
  • SKILL.md covers 使用時期, 動作方法, 例 and レポートガイダンス, plus 2 more sections
  • Calls sqlite3

What it does

Cost Tracking is an agent skill from affaan-m/ECC. ローカルのコスト追跡データベースからClaude Codeのトークン使用量、支出、予算を追跡・レポートします。コスト、支出、使用量、トークン、予算、またはプロジェクト、ツール、セッション、日付によるコスト内訳について質問する場合に使用します。

Its SKILL.md is about 830 tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering LLM cost and token optimization. The repository describes itself as: The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond. The licence is MIT.

When your agent uses it

  • Tasks that involve LLM cost and token optimization

Example prompts

  • “/cost-tracking”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. 今日の支出と昨日の比較。
  2. 追跡されたデータベース全体の合計支出。
  3. コスト順にランク付けされた上位プロジェクト。
  4. コスト順にランク付けされた上位ツール。
  5. 十分なデータがある場合のセッション数とセッションごとの平均コスト。

What it can do on your machine

Read from SKILL.md and the folder at commit 4eb71d9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • sqlite3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Cost Tracking loads about 829 tokens when it runs. Until then it costs about 34 tokens; SKILL.md has 71 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~34
When it runs · the whole SKILL.md, loaded when a task matches
~829

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from affaan-m/ECC at commit 4eb71d9, republished under its MIT licence (© affaan-m). 71 words, ~829 tokens.

Download SKILL.mdSave it as .claude/skills/cost-tracking/SKILL.md (or your agent's skills folder).
name
cost-tracking
description
ローカルのコスト追跡データベースからClaude Codeのトークン使用量、支出、予算を追跡・レポートします。コスト、支出、使用量、トークン、予算、またはプロジェクト、ツール、セッション、日付によるコスト内訳について質問する場合に使用します。
origin
community

コスト追跡

このスキルを使用して、ローカルSQLiteデータベースからClaude Codeのコストと使用履歴を分析します。これは、~/.claude-cost-tracker/usage.dbに使用行を書き込むコスト追跡フックまたはプラグインをすでに持っているユーザーを対象としています。

出典: MayurBhavsarによるコミュニティのPR #1304から救済されました。

使用時期

  • ユーザーが「いくら使いましたか?」「このセッションのコストは?」「トークン使用量は?」と尋ねる場合
  • ユーザーが予算、支出制限、超過、またはコスト管理について言及する場合
  • ユーザーがプロジェクト、ツール、セッション、モデル、または日付ごとのコスト内訳を求める場合
  • ユーザーが今日と昨日を比較したい、または最近のトレンドを確認したい場合
  • ユーザーが最近の使用記録のCSVエクスポートを求める場合

動作方法

まず前提条件を確認します:

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"

データベースが見つからない場合、使用データを作成しません。ユーザーにコスト追跡が設定されていないことを伝え、信頼できるローカルコスト追跡フック/プラグインのインストールまたは有効化を提案します。

期待されるusageテーブルには通常、ツール呼び出しまたはモデルインタラクションごとに1行が含まれます。列名はトラッカーによって異なりますが、以下の例では次のように仮定します:

列意味
timestamp使用イベントのISOタイムスタンプ
projectプロジェクトまたはリポジトリ名
tool_nameツールまたはイベント名
input_tokens記録された場合の入力トークン数
output_tokens記録された場合の出力トークン数
cost_usdUSDで事前計算されたコスト
session_idClaude Codeセッション識別子
modelイベントに使用されたモデル

cost_usdを使用して手動で価格計算するよりも優先します。モデルの価格とキャッシュ価格は時間とともに変化し、トラッカーが各行の価格設定の信頼できる情報源であるべきです。

例

クイックサマリー
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;
"
プロジェクト別コスト
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;
"
ツール別コスト
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;
"
過去7日間
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;
"
セッション詳細
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;
"

レポートガイダンス

コストデータを表示する場合、以下を含めます:

  1. 今日の支出と昨日の比較。
  2. 追跡されたデータベース全体の合計支出。
  3. コスト順にランク付けされた上位プロジェクト。
  4. コスト順にランク付けされた上位ツール。
  5. 十分なデータがある場合のセッション数とセッションごとの平均コスト。

少額の場合、通貨を小数点4桁でフォーマットします。大きな金額には2桁で十分です。

アンチパターン

  • cost_usdが存在する場合に生のトークン数からコストを推定しないこと。
  • 確認せずにデータベースが存在すると仮定しないこと。
  • 大規模なデータベースで無制限のSELECT *エクスポートを実行しないこと。
  • ユーザー向けの回答で現在のモデル価格をハードコードしないこと。
  • 任意のコードを実行する未審査のフックやプラグインのインストールを推奨しないこと。

関連

  • /cost-report - 同じデータベースを使用するコマンド形式のレポート。
  • cost-aware-llm-pipeline - モデルルーティングと予算設計のパターン。
  • token-budget-advisor - コンテキストとトークン予算の計画。
  • strategic-compact - 繰り返しのトークン支出を削減するためのコンテキスト圧縮。

© affaan-m, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in docs/ja-JP/skills/cost-tracking of affaan-m/ECC.

Open the folder on GitHubat commit 4eb71d9

Compare with similar skills

Cost Tracking next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cost Tracking compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cost Tracking this skillaffaan-m/ECC276k—~829Automated safety check: PassMIT
Context Compressionguanyang/open-agent-hub9772 repos~4.6kAutomated safety check: PassMIT
Bounty Hunter1sadjlk/bounty-hunter-skill2821 repos~761Automated safety check: PassMIT
Skill Shortenerluongnv89/asm955—~3.8kAutomated safety check: NotesMIT
Context Auditundefined-ui/second-brain-os1k—~802Automated safety check: PassMIT
Headroommomori777/Artemis380—~562Automated safety check: PassMIT

Similar skills

  • Context Compression

    guanyang/open-agent-hub

    This skill should be used when long-running agent sessions need context compression, structured summarization, compaction, token-per-task optimization, or durable handoff summaries that preserve…

    977 GitHub starsUsed in 2 repos~4.6k tokens
    AI & LLM EngineeringAuto-check passed
  • Bounty Hunter

    1sadjlk/bounty-hunter-skill

    A professional AI bounty hunter persona named Atlas. An agent skill from 1sadjlk/bounty-hunter-skill.

    282 GitHub starsUsed in 1 repo~761 tokens
    AI & LLM EngineeringAuto-check passed
  • Skill Shortener

    luongnv89/asm

    Refactor a too-long SKILL.md by progressive disclosure: measure token cost, classify every section KEEP/CUT/MOVE, shorten the body into references/ and scripts/, verify nothing was lost.

    955 GitHub stars~3.8k tokensUpdated today
    AI & LLM EngineeringAuto-check: notes
  • Context Audit

    undefined-ui/second-brain-os

    Audit an agent's context layout against the four places: system prompt, tools, history, tail.

    1k GitHub stars~802 tokensUpdated yesterday
    AI & LLM EngineeringAuto-check passed
  • Headroom

    momori777/Artemis

    SmartCrusher + CCR context compression — crunch large JSON arrays, tool outputs, and search results to save tokens.

    380 GitHub stars~562 tokensUpdated 11 days ago
    AI & LLM EngineeringAuto-check passed
  • AI

    butterbase-ai/butterbase-skills

    A skill your agent uses when calling the app's AI gateway from agent tools — chat completions, embeddings, listing models, configuring defaults or BYOK, reading token/cost usage

    534 GitHub stars~1.1k tokensUpdated 5 days ago
    AI & LLM EngineeringAuto-check passed

More from affaan-m/ECC

All 682 skills in this repo
  • Skill Stocktake

    affaan-m/ECC

    Audits your installed Claude skills and commands for quality, with a quick mode for recently changed skills and a full mode that evaluates all of them through subagents.

    277k GitHub starsUsed in 5 repos~3.1k tokens
    Auto-check passed
  • Ingests, indexes, searches, edits and monitors video, audio and live streams through the VideoDB Python SDK, returning stream links, clips and timestamps.

    277k GitHub starsUsed in 3 repos~3.5k tokens
    Auto-check: notes
  • Docs Governance

    affaan-m/ECC

    Route broad documentation-governance requests to existing ECC skills and run an opt-in, read-only audit of mapped documentation roles, links, ADR indexes, and evidence references.

    277k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Rules Distillation

    affaan-m/ECC

    Scans installed skills for principles that recur across them and proposes rule-file changes: append, revise, add a section, create a file or leave as covered.

    277k GitHub starsUsed in 2 repos~2.3k tokens
    Auto-check passed
  • Builds DRAFT counterparty agreements from one markdown template and a small JSON spec per party, with clauses picked by the party's role.

    277k GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Set an ECC-specific frontend design direction for production UI work.

    277k GitHub starsUsed in 1 repo~2.2k tokens
    Auto-check passed

Questions about Cost Tracking

What does Cost Tracking do?

ローカルのコスト追跡データベースからClaude Codeのトークン使用量、支出、予算を追跡・レポートします。コスト、支出、使用量、トークン、予算、またはプロジェクト、ツール、セッション、日付によるコスト内訳について質問する場合に使用します。. Cost Tracking is an agent skill from affaan-m/ECC.

When should I use Cost Tracking?

Cost Tracking fits situations like: tasks that involve LLM cost and token optimization.

How do I install Cost Tracking in Claude Code?

Run `npx skills add affaan-m/ECC --skill cost-tracking -a claude-code`. Or copy the skill folder (docs/ja-JP/skills/cost-tracking in affaan-m/ECC) into .claude/skills/cost-tracking in your project. Claude Code loads it when a task matches its description.

How do I install Cost Tracking in Codex?

Run `npx skills add affaan-m/ECC --skill cost-tracking -a codex`. Or copy the skill folder (docs/ja-JP/skills/cost-tracking in affaan-m/ECC) into .agents/skills/cost-tracking in your project. Codex loads it when a task matches its description.

Can I use Cost Tracking in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add affaan-m/ECC --skill cost-tracking -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cost-tracking, .gemini/skills/cost-tracking, .github/skills/cost-tracking and .opencode/skills/cost-tracking in your project.

What does Cost Tracking need to run?

Going by SKILL.md and its folder, Cost Tracking needs the command-line tools its instructions call (sqlite3).

Does Cost Tracking access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Cost Tracking safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Cost Tracking use?

Cost Tracking is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cost Tracking use?

About 829 tokens (SKILL.md is roughly 3.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Cost Tracking?

Skills that share tags, products or a category with Cost Tracking: Context Compression (guanyang/open-agent-hub, 977 stars), Bounty Hunter (1sadjlk/bounty-hunter-skill, 282 stars), Skill Shortener (luongnv89/asm, 955 stars) and Context Audit (undefined-ui/second-brain-os, 1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cost Tracking?

affaan-m (a GitHub user) maintains it in affaan-m/ECC, which has 276,111 GitHub stars. The repository holds 683 skills in this directory. The repository was last updated on October 10, 2026.

Source: affaan-m/ECC on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.