Sign in
Explore
Prompts · PromptEveryday codingReviewed

cost-report

Generate a local Claude Code cost report from the ECC cost-tracker metrics log.

Kind
Prompt
Works with
Claude Code, Codex
Source
affaan-m/ECC @ d3b8a3e90890
Path
commands/cost-report.md

Credit

Made by
affaan-m
Original
github.com/affaan-m/ECC/blob/d3b8a3e908904e242ed2dbe66af62cca…
License
MIT

Listed by Skill Manifest; not made by us.

InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
Install factsScanned 3 Nov 2026
Adds
  • .claude/commands/cost-report.md (run as /cost-report)
Runs scripts
Yes
  • shell block in the text
Uses the network
None found
Needs secrets
None found
Reads outside the project
  • ~/.claude/metrics/costs.jsonl (cost-report.md)
Source revision
d3b8a3e90890
Licence
MIT
Last activity
23 Nov 2026
Source changed after the scan
Yes
  • Last push 23 Nov 2026, scanned 3 Nov 2026; read it again before you rely on this scan
Review
Reviewed

Found by a static scan of the stored text; nothing is run. “None found” is not a guarantee, so read what you install before you run it.

# 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

```bash
node -e '
const fs=require("fs"),os=require("os"),path=require("path");
…