src/skills/analyzing-usage/SKILL.md
Analyze AI coding agent usage, cost, efficiency, and burn rate — Claude Code (ccusage), Pi/pi-agent (ccusage-pi), or Codex CLI (ccusage-codex). Use when user says "usage", "cost", "spending", "tokens", "analyze usage", "how much did I spend", "usage report", "budget", "burn rate", "efficiency", "cache hits", "ccusage", "ccw", "ccp". NOT for general shell scripting, non-AI-agent cost analysis, or cloud infrastructure billing (use using-cloud-cli).
npx skillsauth add alexei-led/claude-code-config analyzing-usageInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
ccusage for Claude Code usage data. For workflow descriptions, show the exact ccusage query shape instead of generic analysis steps.uvx termgraph charts when describing trend visualization; mention uvx termgraph by name. If charts are unavailable, fall back to plain tables.CLAUDE_CONFIG_DIR=/Users/alexei/.claude-team-gaia-mbp-m2 ccusage — Enterprise, $1,500/mo limit, focus on cost burn rate and project allocationccp): ccusage (no env override) — Max plan, $100-$200/mo, token-based limit, focus on token efficiency and cache ratesBash tool uses zsh, not fish — always use full command form, not ccw/ccp aliases.
Parse skill arguments: work/ccw/personal/ccp -> profile. daily/weekly/monthly/session -> subcommand (default: daily). --since/--until -> date range (default: 14 days). --today -> today only. --compare -> both profiles.
Compute in zsh (macOS):
SINCE=$(date -v-14d +%Y%m%d) # 14 days ago
UNTIL=$(date +%Y%m%d) # today
TODAY=$(date +%Y%m%d) # for --today mode
MONTH_START=$(date +%Y%m01) # for burn rate projection
Bun global. Reads Claude Code JSONL logs -> token/cost stats.
Subcommands: daily (by date), weekly (ISO week), monthly (month), session (conversation), blocks (billing).
Key flags: -s YYYYMMDD since, -u YYYYMMDD until, -j JSON (required for piping to jq), -b model breakdown, -i instances, -p NAME project filter, -o asc|desc, -q 'JQ_EXPR' run jq inline (implies -j, outputs raw jq result — useful for standalone queries but NOT for piping to termgraph), -O offline pricing cache, --no-color disable ANSI.
JSON shape — daily returns .daily[], weekly .weekly[], monthly .monthly[], session .sessions[]. Each entry has: inputTokens, outputTokens, cacheCreationTokens, cacheReadTokens, totalTokens, totalCost, modelsUsed[], modelBreakdowns[].{modelName, inputTokens, outputTokens, cacheCreationTokens, cacheReadTokens, cost}. Date key varies: .date / .week / .month. Sessions add .sessionId, .projectPath, .lastActivity.
Always 2>/dev/null to suppress bun resolver stderr.
Always invoke: uvx termgraph. Input: CSV via stdin — label,value or label,v1,v2,v3.
Flags (no short forms — all long): --title STR, --width N (use 60), --color COLOR [...] (red/blue/green/cyan/magenta/yellow/white — positional for multi-series), --suffix STR (" $", " M", "%"), --stacked (multi-series only), --different-scale (non-stacked multi-series only — NOT with --stacked), --delim DELIM (default comma or space), --format FORMAT (Python format spec), --custom-tick CHAR (emoji work: "🔥"), --label-before (values before bars), --no-labels, --no-values, --space-between.
Calendar heatmap: --calendar --start-dt YYYY-MM-DD --color COLOR. Labels must be YYYY-MM-DD,value format (full date, not MM-DD).
--percentage multiplies values by 100 — only useful when raw values are 0-1 ratios. Do NOT use with pre-computed percentages or absolute values.
Always use colors — every termgraph call must have --color. Use distinct colors per view for visual variety. For multi-series (stacked), use --color red yellow blue (opus=red, haiku=yellow, sonnet=blue — consistent across views). Use --custom-tick "▇" or emoji ticks (e.g., --custom-tick "🔥" for cost spikes) when it adds clarity. Add --space-between for views with many rows (>10).
All 11 view templates (work/personal profile prefix, the CCU shorthand, and the
exact ccusage | jq | termgraph pipeline per view) and the reusable jq snippets
live in references/ccusage.md. Read it before running any view.
--today: views 4 + 2 (today only) + 5 (7d context)daily: views 1 + 2 + 3 + 5weekly/monthly: adapt view 1 with matching subcommand, replace .daily[]/.date with .weekly[]/.week or .monthly[]/.monthsession: view 4 over date range--compare: run views 1 + 6 for each profile sequentially, with echo "\n=== Work ===" / echo "\n=== Personal ===" dividersRun independent charts in parallel.
Always highlight in analysis: model mix shifts (opus vs sonnet vs haiku ratio changes), cost per output token trends (dropping = better efficiency), cache hit rate trends, sonnet/haiku share growth (signals routing optimization).
For work: compute daily burn rate, project to month-end, flag if trending over $1,500. For personal: focus on token totals vs plan limits, not cost.
Empty JSON -> "No usage data for this period". termgraph fails -> fall back to plain ccusage daily (no -j).
tools
Idiomatic shell development for POSIX sh, Bash, Zsh, Fish, hooks, CI shell steps, and scriptable CLI glue. Use when writing or changing `.sh`, `.bash`, `.zsh`, `.fish`, `.bats`, shell functions, shell pipelines, or command-runner recipes. Emphasizes portability, quoting, safe filesystem/process handling, non-TUI CLI tools, ShellCheck, shfmt, Bats, and ShellSpec. NOT for Python, TypeScript, Go, web code, or infrastructure operations.
tools
Use when planning, executing, checkpointing, finishing, or inspecting lightweight spec-driven work. Runs one task at a time using `.spec/` markdown files and the bundled `specctl` helper. NOT for broad product discovery beyond a short requirement interview.
testing
Author, inspect, troubleshoot, and review infrastructure across IaC, Kubernetes, cloud resources, containers, CI/CD, and Linux hosts. Use when changing Terraform/OpenTofu, Kubernetes, Helm, Kustomize, Dockerfiles, GitHub Actions, AWS, GCP, Cloud Run, BigQuery, IAM, logs, instances, or service health. NOT for deploy/apply/rollback workflows (see deploying-infra). NOT for shell scripts or generic command pipelines (see writing-shell).
development
Configure safe git workflow hygiene: pre-commit/pre-push hooks, Gitleaks secret scanning, .gitignore rules, local git config, and guardrails. Use when setting up git hooks, gitleaks/git leaks, staged pre-commit checks, pre-push validation, core.hooksPath, .gitignore, or git config best practices. NOT for creating commits (use committing-code), cleaning branches/worktrees (use cleanup-git), or creating worktrees (use using-git-worktrees).