Claude usage report

From CarlosCaPe/octorato · View interactive version

Claude usage report is an AI agent skill from the GitHub repository CarlosCaPe/octorato. Aggregate Claude Code usage (tokens, sessions, API-equivalent cost) by day, week, month, model, and project from local JSONL session logs. Use when the user asks about their Claude Code usage, consumption, costs, "cuánto he usado", "uso diario/semanal/mensual", or wants to audit which projects/model

How to use this skill

Skill file

Claude Usage Report

Purpose

Claude Code stores every assistant message — including token usage and model

identity — in JSONL files under ~/.claude/projects/. This skill parses those

logs and produces a usage breakdown so the operator can:

per-token at API list price.

Triggers

Activate when the user asks any of:

Workflow

1. Run the aggregator

python3 ~/.claude/skills/claude-usage-report/scripts/usage_report.py

Optional flags:

2. Output sections (in order)

  1. Header — files scanned, lines, messages with usage data
  2. ÚLTIMOS N DÍAS — day-by-day breakdown (sessions, msgs, tokens, $)
  3. POR SEMANA — last 8 ISO weeks
  4. POR MES — every month with activity
  5. POR MODELO — sorted by cost, shows which model dominates spend
  6. POR PROYECTO — top 10 projects by cost (uses cwd-derived names)
  7. TOTAL ACUMULADO — grand totals + cost note

3. Interpret with the user

Use the output to answer their actual question. Common follow-ups worth

volunteering:

the price — worth considering for non-critical tasks."

Keeping sessions warm matters."

consolidating may help cache hit rate.

Pricing source

The script embeds Anthropic public list prices (USD per 1M tokens) for the

Claude 4.x family. Pricing categories: in, out, cache_w (cache write),

cache_r (cache read).

When Anthropic updates prices or releases new models, edit the PRICING dict

at the top of scripts/usage_report.py. Unknown models fall back to family

heuristics (opus / sonnet / haiku) so the report still produces a number.

Best practices

dollar figure is "what this would cost at API list price" — i.e. value

extracted, not money owed. Always state this when reporting.

read volume is good news, not bad.

billed. They appear in counts but with $0.

sometimes writes user-only lines or aborted turns. The aggregator skips

records without usage, which is correct.

Error handling

running Claude Code at least once first.

truncated tails after crashes).

If neither opus nor haiku is in the name, defaults to Sonnet pricing.

Lessons Learned

canonical community tool for this (ccusage) is great but is blocked by

Claude Code's auto-mode classifier (external code execution). Parsing the

JSONL directly with Python avoids that gate entirely.

-home-user-Documents-github-foo. The script strips the home prefix

generically (no hardcoded usernames) so the same code works for any operator.

most billing dashboards report. Don't roll your own week math.

session that writes huge cache once then reads it many times is optimal;

one that re-writes cache every turn burns money.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.