affaan-m/ECC

cost-tracking

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.

87CollectingClaude CodeRuns scriptsReads files
See how to use itView GitHub source
npx skills add https://github.com/affaan-m/ECC --skill "skills/cost-tracking"
Automated source guide

Source checked Jul 28, 2026·Refresh due Oct 26, 2026

Reorganized from the pinned upstream SKILL.md

Turn cost-tracking's source instructions into a guide you can follow

According to the pinned SKILL.md from affaan-m/ECC: Use this skill to analyze Claude Code cost and usage history from the metrics log that ECC's stop:cost-tracker hook writes.

npx skills add https://github.com/affaan-m/ECC --skill "skills/cost-tracking"
Check the pinned source

Best fit

  • The user asks "how much have I spent?", "what did this session cost?", or
  • The user mentions budgets, spending limits, overruns, or cost controls.
  • The user wants a cost breakdown by model, session, or date, or a CSV export.

Bring this context

  • A concrete task that matches the documented purpose of cost-tracking.
  • The files, examples, or context the task depends on.
  • Your constraints, target environment, and definition of done.

Expected outputs

  • For a session drilldown or CSV export, iterate the same latest set (or the raw rows for CSV) and print the fields you need.

Key source sections

Read cost-tracking through these 5 source sections

Sections are extracted automatically from the pinned SKILL.md and link back to the source.

01

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.

SKILL.md · 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 —…Prefer estimatedcostusd over hand-calculating pricing — model and cache prices change, and the tracker is the source of truth.
02

When to Use

The user asks "how much have I spent?", "what did this session cost?", or

SKILL.md · When to Use
The user asks "how much have I spent?", "what did this session cost?", orThe user mentions budgets, spending limits, overruns, or cost controls.The user wants a cost breakdown by model, session, or date, or a CSV export.
03

How It Works

First verify the log exists (use node, not sqlite3 — the tracker writes JSONL, and node is cross-platform):

SKILL.md · How It Works
First verify the log exists (use node, not sqlite3 — the tracker writes JSONL, and node is cross-platform):If the log is missing, do not fabricate usage data. Tell the user that cost tracking populates after the first session ends with the stop:cost-tracker hook enabled.
04

Example — summary, by model, last 7 days

For a session drilldown or CSV export, iterate the same latest set (or the raw rows for CSV) and print the fields you need.

SKILL.md · Example — summary, by model, last 7 days
For a session drilldown or CSV export, iterate the same latest set (or the raw rows for CSV) and print the fields you need.
05

Reporting Guidance

When presenting cost data, include today's spend vs yesterday, total across all sessions, a by-model breakdown, and session count. Format sub-dollar amounts with four decimals, larger amounts with two.

SKILL.md · Reporting Guidance
When presenting cost data, include today's spend vs yesterday, total across all sessions, a by-model breakdown, and session count. Format sub-dollar amounts with four decimals, larger amounts with two.

SkillSignal prompt templates

Provide the task, context, and acceptance criteria

These prompts were written by SkillSignal from the source structure; they are not upstream text.

Task-start prompt

Confirm source fit, inputs, and outputs before acting.

Use cost-tracking to help me with: [specific task]. Context: [files, data, or background]. Constraints: [environment, scope, and prohibited actions]. Before acting, check the pinned SKILL.md and explain which sections apply, what inputs are still missing, and what you will deliver.

Source-guided execution

Make the Agent explicitly follow the key extracted sections.

Apply the pinned cost-tracking source to [task]. Pay particular attention to these source sections: “Where the data lives”, “When to Use”, “How It Works”, “Example — summary, by model, last 7 days”, “Reporting Guidance”. Preserve the important decision at each step. Mark facts not covered by the source as “needs confirmation” instead of inventing them. Then verify the result against my acceptance criteria: [criteria].

Result-review prompt

Check omissions, permissions, and source drift before delivery.

Review the current cost-tracking result: (1) does it satisfy the original task; (2) were any applicable steps or limits in the pinned SKILL.md missed; (3) did it perform any unauthorized file, command, network, or data action; and (4) which conclusions remain unverified? List issues first, then fix only what the source or user authorization supports.

Output checklist

Verify each item before delivery

The task matches the purpose documented in the SKILL.md.

The source section “Where the data lives” has been checked.

The source section “When to Use” has been checked.

The source section “How It Works” has been checked.

The source section “Example — summary, by model, last 7 days” has been checked.

Inputs, constraints, and acceptance criteria are explicit.

Unverified facts, compatibility, and outcome claims are clearly marked.

Any file, command, network, or data action has been reviewed.

Choose a different workflow

When another Skill is the better fit

FAQ

What does cost-tracking do?

Use this skill to analyze Claude Code cost and usage history from the metrics log that ECC's stop:cost-tracker hook writes.

How do I start using cost-tracking?

The catalog detected this source-specific install command: npx skills add https://github.com/affaan-m/ECC --skill "skills/cost-tracking". Inspect the command and pinned source before running it.

Which Agent platforms does it declare?

claude code

Repository stars
234,327
Repository forks
35,711
Quality
87/100
Source repository last pushed

Quality breakdown

Based on traceable docs and repository signals; stars are not treated as quality.

87/100
Documentation28/30
Specificity19/25
Maintenance20/20
Trust signals20/25

Compare before choosing

Related Agent Skills and source variants

These links are selected from shared tasks, functions, stacks, platforms, and same-name variants. Compare the source owner, documentation, permissions, and maintenance signals.

cost-tracking by affaan-m

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

claude-skill-spec-audit by jackchuka

Audit skill SKILL.md files for compliance with the agentskills.io specification and house conventions. Checks frontmatter fields (name, description, compatibility, metadata, argument-hint), metadata sub-fields (author, scope, layer, confirms), and layer/suffix consistency. Use when adding new skills, reviewing skill quality, or ensuring all skills follow the spec. Triggers: "audit skills", "check skill spec", "skill compliance", "are my skills up to spec", "/claude-skill-spec-audit".

autonomous-loops by affaan-m

Patterns and architectures for autonomous Claude Code loops — from simple sequential pipelines to RFC-driven multi-agent DAG systems.

quality-nonconformance by affaan-m

Codified expertise for quality control, non-conformance investigation, root cause analysis, corrective action, and supplier quality management in regulated manufacturing. Informed by quality engineers with 15+ years experience across FDA, IATF 16949, and AS9100 environments. Includes NCR lifecycle management, CAPA systems, SPC interpretation, and audit methodology. Use when investigating non-conformances, performing root cause analysis, managing CAPAs, interpreting SPC data, or handling supplier

configure-ecc by affaan-m

Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.

View original Skill.mdThis page is parsed directly from the repository SKILL.md without editorial rewriting. Collected: Jul 28, 2026 · about 2 min

Cost Tracking

Use this skill to analyze Claude Code cost and usage 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 session_id and sum across sessions — summing every row multiply-counts.

Row schema:

FieldMeaning
timestampISO timestamp of the snapshot
session_idClaude Code session identifier
transcript_pathPath to the session transcript
modelModel used
input_tokens / output_tokensToken counts
cache_write_tokens / cache_read_tokensPrompt-cache token counts
estimated_cost_usdPrecomputed cumulative cost in USD for the session

Prefer estimated_cost_usd over hand-calculating pricing — model and cache prices change, and the tracker is the source of truth.

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 model, session, or date, or a CSV export.

How It Works

First verify the log exists (use node, not sqlite3 — the tracker writes JSONL, and node is cross-platform):

node -e 'const fs=require("fs"),os=require("os"),p=require("path");const f=p.join(os.homedir(),".claude","metrics","costs.jsonl");console.log(fs.existsSync(f)?"cost log found":"cost log not found: "+f)'

If the log is missing, do not fabricate usage data. Tell the user that cost tracking populates after the first session ends with the stop:cost-tracker hook enabled.

Example — summary, by model, last 7 days

node -e '
const fs=require("fs"),os=require("os"),path=require("path");
const f=path.join(os.homedir(),".claude","metrics","costs.jsonl");
if(!fs.existsSync(f)){console.log("cost log not found: "+f);process.exit(0);}
const rows=fs.readFileSync(f,"utf8").split(/\r?\n/).filter(Boolean).map(l=>{try{return JSON.parse(l)}catch{return null}}).filter(Boolean);
const bySession=new Map();
for(const r of rows){const k=r.session_id||r.transcript_path||r.timestamp;const p=bySession.get(k);if(!p||String(r.timestamp)>String(p.timestamp))bySession.set(k,r);}
const latest=[...bySession.values()];
const cost=r=>Number(r.estimated_cost_usd)||0, day=r=>String(r.timestamp||"").slice(0,10), sum=a=>a.reduce((s,r)=>s+cost(r),0), f4=n=>"$"+n.toFixed(4);
const today=new Date().toISOString().slice(0,10), yest=new Date(Date.now()-864e5).toISOString().slice(0,10);
console.log("today: "+f4(sum(latest.filter(r=>day(r)===today)))+" | yesterday: "+f4(sum(latest.filter(r=>day(r)===yest)))+" | total: "+f4(sum(latest))+" ("+latest.length+" sessions)");
const m=new Map();for(const r of latest){const k=r.model||"(unknown)";m.set(k,(m.get(k)||0)+cost(r));}
console.log("by model:");[...m.entries()].sort((a,b)=>b[1]-a[1]).forEach(([k,v])=>console.log("  "+f4(v)+"  "+k));
'

For a session drilldown or CSV export, iterate the same latest set (or the raw rows for CSV) and print the fields you need.

Reporting Guidance

When presenting cost data, include today's spend vs yesterday, total across all sessions, a by-model breakdown, and session count. Format sub-dollar amounts with four decimals, larger amounts with two.

Anti-Patterns

  • Do not sum every row — they are cumulative per session; reduce to the latest row per session_id first.
  • Do not estimate costs from raw token counts when estimated_cost_usd is present.
  • Do not assume the log exists without checking.
  • Do not hard-code current model pricing in user-facing answers.
  • Do not recommend installing unreviewed hooks or plugins that execute arbitrary code.

Related

  • /cost-report - Command-form report over the same metrics log.
  • cost-aware-llm-pipeline - Model-routing and budget-design patterns.
  • token-budget-advisor - Context and token-budget planning.
  • strategic-compact - Context compaction to reduce repeated token spend.
Source repo
affaan-m/ECC
Skill path
skills/cost-tracking/SKILL.md
Commit SHA
4e973d3eaf92
Repository license
MIT
Data collected