From cc-usage
Analyze Claude Code token usage, costs, billing blocks, and tool activity from local session data. TRIGGER WHEN: the user asks about their usage, costs, burn rate, or wants a usage dashboard/report. DO NOT TRIGGER WHEN: the task is outside the specific scope of this component.
npx claudepluginhub acaprino/alfio-claude-plugins --plugin cc-usageThis skill uses the workspace's default tool permissions.
Analyze Claude Code session data to generate usage reports with token counts, cost estimates, billing block tracking, tool usage stats, and per-project breakdowns.
Guides Payload CMS config (payload.config.ts), collections, fields, hooks, access control, APIs. Debugs validation errors, security, relationships, queries, transactions, hook behavior.
Builds scalable data pipelines, modern data warehouses, and real-time streaming architectures using Spark, dbt, Airflow, Kafka, and cloud platforms like Snowflake, BigQuery.
Builds production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. For data pipelines, workflow orchestration, and batch job scheduling.
Analyze Claude Code session data to generate usage reports with token counts, cost estimates, billing block tracking, tool usage stats, and per-project breakdowns.
Inspired by paulrobello/par_cc_usage.
Claude Code stores session data as JSONL files in:
~/.config/claude/projects/ (primary)~/.claude/projects/ (legacy)CLAUDE_CONFIG_DIR env varThe script parses these files, extracts assistant message token usage, deduplicates by request ID, and computes:
Run the analysis script:
python plugins/cc-usage/skills/cc-usage/scripts/cc_usage.py
| Flag | Description |
|---|---|
-d, --days N | Number of days to analyze (default: 7) |
-p, --project NAME | Filter by project name (substring match) |
--no-block | Hide current billing block section |
--no-projects | Hide project breakdown |
--no-tools | Hide tool usage stats |
--no-sessions | Hide recent sessions list |
-n, --top N | Number of top items per section (default: 10) |
--json | Output raw JSON instead of formatted markdown |
# Last 7 days, full report
python cc_usage.py
# Last 30 days, filter to one project
python cc_usage.py -d 30 -p "my-project"
# Quick overview, no details
python cc_usage.py --no-tools --no-sessions -n 5
# Machine-readable JSON output
python cc_usage.py --json
Run this script for the user when they ask about:
Execute via Bash:
python <path-to-script>/cc_usage.py [options]
Then present the markdown output directly to the user -- it renders as formatted tables.
The script reads Claude Code's native JSONL format. Key fields extracted:
message.usage - token counts (input, output, cache_creation, cache_read)message.model - model identifier for pricing tiermessage.content[].type == "tool_use" - tool call trackingcostUSD - native cost field (used when available, falls back to calculated)requestId - deduplication keytimestamp - for time-based analysisHardcoded Anthropic pricing tiers (per token):
| Model | Input | Output | Cache Create | Cache Read |
|---|---|---|---|---|
| Opus | $15/MTok | $75/MTok | $18.75/MTok | $1.50/MTok |
| Sonnet | $3/MTok | $15/MTok | $3.75/MTok | $0.30/MTok |
| Haiku | $0.80/MTok | $4/MTok | $1/MTok | $0.08/MTok |
When costUSD is present in the JSONL data, that value takes priority over calculated estimates.