@ccusage/pi
Analyze pi-agent session usage with the same reporting experience as ccusage.
Quick Start
npx @ccusage/pi@latest --help
bunx @ccusage/pi@latest --help
pnpm dlx @ccusage/pi
pnpx @ccusage/pi
Recommended: Shell Alias
Since npx @ccusage/pi@latest is quite long to type repeatedly, we strongly recommend setting up a shell alias:
ccusage-pi daily
ccusage-pi monthly --json
💡 The CLI reads pi-agent session data from ~/.pi/agent/sessions/ (configurable via PI_AGENT_DIR).
Common Commands
npx @ccusage/pi@latest daily
npx @ccusage/pi@latest monthly
npx @ccusage/pi@latest session
npx @ccusage/pi@latest daily --json
npx @ccusage/pi@latest daily --pi-path /path/to/sessions
npx @ccusage/pi@latest daily --since 2025-12-01 --until 2025-12-19
Useful environment variables:
PI_AGENT_DIR – override the pi-agent sessions directory (defaults to ~/.pi/agent/sessions)
LOG_LEVEL – control log verbosity (0 silent … 5 trace)
What is pi-agent?
Pi-agent is an alternative Claude coding agent. It stores usage data in a similar JSONL format to Claude Code but in a different directory structure.
Features
- 📊 Daily/Monthly/Session Reports: Same reporting options as ccusage
- 💵 Accurate Cost Calculation: Uses LiteLLM pricing database
- 🧠 Subagent-aware accounting: Usage totals include both top-level assistant usage and nested subagent usage from
message.details.results[].usage where message.toolName == "subagent"
- 📄 JSON Output: Export data in structured JSON format with
--json
- 📱 Compact Mode: Use
--compact flag for narrow terminals
Data Source
Pi-agent session data is read from:
| Pi-agent sessions | ~/.pi/agent/sessions/ |
Documentation
For detailed guides and examples, visit ccusage.com.
Check out ccusage: The Claude Code cost scorecard that went viral
License
MIT © @ryoppippi