All skills
Skillintermediate
CLAUDE.md - Pi Package
This package provides usage tracking for pi-agent.
Claude Code Knowledge Pack7/10/2026
Overview
CLAUDE.md - Pi Package
This package provides usage tracking for pi-agent.
Package Overview
Name: @ccusage/pi
Description: Pi-agent usage tracking
Type: CLI tool with TypeScript exports
Development Commands
Testing and Quality:
pnpm run test- Run all tests using vitestpnpm run lint- Lint code using ESLintpnpm run format- Format and auto-fix code with ESLintpnpm typecheck- Type check with TypeScript
Build and Release:
pnpm run build- Build distribution files with tsdownpnpm run prerelease- Full release workflow (lint + typecheck + build)
Usage
# Show daily pi-agent usage
ccusage-pi daily
# Show monthly pi-agent usage
ccusage-pi monthly
# Show session-based pi-agent usage
ccusage-pi session
# JSON output
ccusage-pi daily --json
# Custom pi-agent path
ccusage-pi daily --pi-path /path/to/sessions
Architecture
This package reads usage data from pi-agent only.
Data Source:
- Pi-agent:
~/.pi/agent/sessions/
Key Modules:
src/index.ts- CLI entry point with Gunshi-based command routingsrc/data-loader.ts- Loads and aggregates pi-agent JSONL datasrc/_pi-agent.ts- Pi-agent data parsing and transformationsrc/commands/- CLI subcommands (daily, monthly, session)
Dependencies
Key Runtime Dependencies:
ccusage- Main ccusage package (workspace dependency)@ccusage/terminal- Shared terminal utilitiesgunshi- CLI frameworkvalibot- Schema validationtinyglobby- File globbing
Key Dev Dependencies:
vitest- Testing frameworktsdown- TypeScript build tooleslint- Linting and formattingfs-fixture- Test fixture creation
Testing
- In-Source Testing: Uses the same testing pattern as the main package
- Vitest Globals Enabled: Use
describe,it,expectdirectly without imports - Mock Data: Uses
fs-fixturefor testing data loading functionality - CRITICAL: NEVER use
await import()dynamic imports anywhere
Code Style
Follow the same code style guidelines as the main ccusage package:
- Error Handling: Prefer
@praha/byethrow Resulttype over try-catch - Imports: Use
.tsextensions for local imports - Exports: Only export what's actually used
- Dependencies: Add as
devDependenciesunless explicitly requested
Post-Change Workflow: Always run these commands in parallel after code changes:
pnpm run format- Auto-fix and formatpnpm typecheck- Type checkingpnpm run test- Run tests
Environment Variables
| Variable | Description |
|---|---|
PI_AGENT_DIR | Custom path to pi-agent sessions directory |
LOG_LEVEL | Adjust logging verbosity (0 silent … 5 trace) |
Package Exports
The package provides the following exports:
.- Main CLI entry point
Binary
The package includes a binary ccusage-pi that can be used to run the CLI from the command line.