@ccusage/pi
Analyze pi-agent session usage with the same reporting experience as ccusage. Track token usage and costs from your pi-agent sessions with daily, monthly, and session-based reports.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.Quick Start
Installation
Shell Alias (Recommended)
Sincenpx @ccusage/pi@latest is quite long to type repeatedly, set up a shell alias:
Data Source
The CLI reads pi-agent session data from:- Default:
~/.pi/agent/sessions/ - Custom: Set
PI_AGENT_DIRenvironment variable or use--pi-pathflag
Common Commands
Daily Usage Report
View token usage and costs grouped by date:Monthly Report
View usage aggregated by month:Session Report
Detailed breakdown by individual sessions:JSON Output
Export structured data for scripting:Custom Path
Specify a custom pi-agent sessions directory:Date Range Filtering
Filter reports by specific date ranges:Features
Daily Reports
Same reporting options as ccusage for daily tracking
Monthly Reports
Aggregate usage by month for budget tracking
Session Reports
Detailed breakdown by individual conversation sessions
Accurate Costs
Uses LiteLLM pricing database for accurate cost calculation
JSON Output
Export data in structured JSON format with —json
Compact Mode
Use —compact flag for narrow terminals, perfect for screenshots
Environment Variables
| Variable | Description | Default |
|---|---|---|
PI_AGENT_DIR | Override pi-agent sessions directory | ~/.pi/agent/sessions/ |
LOG_LEVEL | Control log verbosity (0 silent … 5 trace) | - |
Use Cases
Budget Tracking
Track your pi-agent usage costs over time:Session Analysis
Analyze individual sessions to understand costs per conversation:Date Range Reports
Generate reports for specific time periods:Comparison with Other Tools
While pi-agent uses similar JSONL format to Claude Code, the directory structure differs:| Tool | Data Location | Format |
|---|---|---|
| Claude Code | ~/.claude/projects/ | JSONL per session |
| pi-agent | ~/.pi/agent/sessions/ | JSONL per session |
| OpenCode | ~/.local/share/opencode/ | JSON per message |
@ccusage/pi tool handles pi-agent’s specific directory structure while providing the same reporting capabilities.
Links
npm Package
View on npm registry
pi-agent
Official pi-agent repository
ccusage Family
Explore all related tools
Main Documentation
Full ccusage documentation