cost-report

cost-report is a command for Claude Code from affaan-m/ECC. It costs 16 tokens per session (1,095 once invoked), scanned A, original, MIT.

A local report command that summarizes Claude Code spending from the metrics log recorded on the computer.

In plain words
What is it for?
Use it to inspect recent estimated costs or export the recorded rows as CSV. It requires the cost-tracking hook to have created the metrics file.
Why use it?
It turns session-level usage records into totals by day, model, and session. It avoids counting repeated cumulative snapshots more than once.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter. Also seen: reads .claude/ paths; mentions Claude Code.

Part of the ecc plugin — 78 skills, 58 commands, 70 agents, 1 MCP server shipped together

Good fit Use it to inspect recent estimated costs or export the recorded rows as CSV. It requires the cost-tracking hook to have created the metrics file.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/affaan-m/ecc/cost-report
About the project

ECC is a toolkit that organizes and improves how coding agents work through skills, memory, security checks, research practices, and related extensions. It is for developers using agents such as Claude Code, Codex, OpenCode, and Cursor.

affaan-m/ECC · 286,530 stars · on GitHub · ecc.tools

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.

Clone the repo
git clone --depth 1 https://github.com/affaan-m/ECC

Made for: Claude Code.

Or install ecc, the plugin that ships this one along with the rest of its 78 skills, 58 commands, 70 agents, 1 MCP server.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cost-report

README.md
[![agentmods](https://agentmods.dev/badge/commands/affaan-m/ecc/cost-report/github.svg)](https://agentmods.dev/commands/affaan-m/ecc/cost-report)
Your own site
<a href="https://agentmods.dev/commands/affaan-m/ecc/cost-report"><img src="https://agentmods.dev/badge/commands/affaan-m/ecc/cost-report/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cost-report

Your own site · 80×15
<a href="https://agentmods.dev/commands/affaan-m/ecc/cost-report"><img src="https://agentmods.dev/badge/commands/affaan-m/ecc/cost-report.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,095 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. ✓ AI security review Fable 5.1 · 6 Sept 2026 📄 Read the review
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.1 $0.00016 $0.01095
Opus 5.5 $0.00006 $0.00438
Sonnet 5.5 $0.00003 $0.00219
Haiku 4.5 $0.00002 $0.00110

Measured 1mo ago against content hash 65ce57cef961, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

cost-report scanned grade A with 0 findings 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 1mo 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/cost-report.md · 82 lines

How it starts

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

Cost Report

Summarize local Claude Code spend by day, model, and session 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 the report takes the latest row per session_id and sums across sessions (summing every row would multiply-count).

Row schema: { timestamp, session_id, transcript_path, model, input_tokens, output_tokens, cache_write_tokens, cache_read_tokens, estimated_cost_usd }

What this command does

  1. Check that ~/.claude/metrics/costs.jsonl exists. If it does not, tell the user the tracker is not set up yet (it populates after the first session ends with the stop:cost-tracker hook enabled).
  2. Reduce rows to the latest snapshot per session and aggregate.
  3. Present a compact report, or export recent rows as CSV when the argument is csv.

node is used instead of sqlite3/jq so this works identically on macOS, Linux, and Windows.

Report

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 tracker not set up: "+f+" not found. Enable the stop:cost-tracker hook and finish a session first.");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;
const day=r=>String(r.timestamp||"").slice(0,10);
const today=new Date().toISOString().slice(0,10);
const d=new Date(Date.now()-864e5).toISOString().slice(0,10);
const sum=a=>a.reduce((s,r)=>s+cost(r),0);
const f4=n=>"$"+n.toFixed(4);
console.log("=== Cost summary ===");
console.log("today:     "+f4(sum(latest.filter(r=>day(r)===today))));
console.log("yesterday: "+f4(sum(latest.filter(r=>day(r)===d))));
console.log("total:     "+f4(sum(latest))+"  ("+latest.length+" sessions)");
const by=(key)=>{const m=new Map();for(const r of latest){const k=key(r)||"(unknown)";m.set(k,(m.get(k)||0)+cost(r));}return [...m.entries()].sort((a,b)=>b[1]-a[1]);};
console.log("\n=== By model ===");for(const [k,v] of by(r=>r.model))console.log(f4(v).padStart(12)+"  "+k);
console.log("\n=== Last 7 days ===");
const days=new Map();for(const r of latest){const k=day(r);days.set(k,(days.get(k)||0)+cost(r));}
[...days.entries()].sort((a,b)=>b[0]<a[0]?-1:1).slice(0,7).forEach(([k,v])=>console.log(k+"  "+f4(v)));
'

Read the full file on GitHub · 82 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. 1mo ago First seen · 82 lines · 16 tokens per session scan A 65ce57cef961

Subscribe to this mod's changes

cost-report is a command published in the GitHub repository affaan-m/ECC (286,530 stars, last pushed 2d ago), licensed MIT. It adds 16 tokens to every session and 1,095 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.