dist/pi/skills/analyzing-usage/SKILL.md
Analyze pi-agent session usage, token cost, and efficiency using ccusage-pi. Use when user says "usage", "cost", "tokens", "how much did I spend", "pi usage", "session cost", "ccusage-pi". NOT for cloud billing or non-pi-agent usage analysis.
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.
Analyze pi-agent session usage via ccusage-pi.
Binary: ccusage-pi — reads ~/.pi/agent/sessions/ (override: PI_AGENT_DIR env var)
npx @ccusage/pi@latest <subcommand> [flags]
daily — token/cost by datemonthly — token/cost by monthsession — token/cost per conversationNo blocks, weekly, or statusline subcommands.
All subcommands share:
--since YYYYMMDD — start date (also accepts YYYY-MM-DD)--until YYYYMMDD — end date--json — JSON output (required for jq piping)--breakdown / -b — per-model breakdown rows--order asc|desc — sort order (default: desc)--timezone / -z — IANA timezone--pi-path <path> — override sessions directoryNo --jq, --offline, --mode, --instances, or --project flags.
# macOS
SINCE=$(date -v-14d +%Y%m%d)
UNTIL=$(date +%Y%m%d)
TODAY=$(date +%Y%m%d)
# Linux
SINCE=$(date -d '14 days ago' +%Y%m%d)
UNTIL=$(date +%Y%m%d)
Detect OS before computing: uname -s returns Darwin (macOS) or Linux.
ccusage-pi output. Never invent totals.totalTokens as inputTokens + outputTokens + cacheCreationTokens + cacheReadTokens — no totalTokens field in JSON.[], not { "sessions": [] } — guard with if type == "array".2>/dev/null to suppress npm resolver stderr.uvx termgraph for visualization when available; fall back to plain jq table otherwise.npx @ccusage/pi@latest daily --since $SINCE --until $UNTIL --json 2>/dev/null \
| jq -r '.daily[] | "\(.date[5:]),\(.totalCost | . * 100 | round / 100)"' \
| uvx termgraph --title "Daily Cost (USD)" --color cyan --width 60 --suffix " $"
npx @ccusage/pi@latest monthly --json 2>/dev/null \
| jq -r '.monthly[] | "\(.month),\(.totalCost | . * 100 | round / 100)"' \
| uvx termgraph --title "Monthly Cost (USD)" --color green --width 60 --suffix " $"
npx @ccusage/pi@latest session --since $TODAY --until $TODAY --json 2>/dev/null \
| jq -r 'if type == "array" then .[] else .sessions[] end
| "\(.sessionId | split("-") | last),\(.totalCost | . * 100 | round / 100)"'
npx @ccusage/pi@latest daily --since $SINCE --until $UNTIL --json 2>/dev/null \
| jq -r '.daily[] |
(.cacheReadTokens + .cacheCreationTokens) as $cache |
(.inputTokens + .outputTokens + $cache) as $total |
select($total > 0) |
"\(.date[5:]),\($cache / $total * 100 | . * 10 | round / 10)"' \
| uvx termgraph --title "Cache Rate %" --color blue --width 60 --suffix "%"
npx @ccusage/pi@latest daily --since $SINCE --until $UNTIL --json 2>/dev/null \
| jq -r '.daily[] |
(.inputTokens + .outputTokens + .cacheCreationTokens + .cacheReadTokens) as $total |
"\(.date[5:]),\($total / 1000000 | . * 100 | round / 100)"' \
| uvx termgraph --title "Daily Tokens (M)" --color yellow --width 60 --suffix " M"
--today: session breakdown + cache efficiency (7d context)monthly: monthly cost charttools
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).