code-usage
v0.2.7
Published
Unified usage dashboard for AI coding tools (Claude Code, Codex CLI, OpenCode)
Maintainers
Readme
npx code-usageSee how much your AI coding actually costs — across all your tools, in one place.
code-usage reads local session files, calculates API-equivalent costs, and builds a self-contained HTML dashboard. No accounts, no APIs, no data leaves your machine.
Why code-usage?
Most usage trackers cover a single tool. If you use Claude Code and Codex and Amp, you need separate tools for each.
code-usage gives you one unified dashboard with combined views, stacked charts, and side-by-side comparisons — for every AI coding agent you use.
Supported Tools
| Tool | Status | |------|--------| | Claude Code | Supported | | Codex CLI | Supported | | OpenCode | Supported | | Amp | Supported | | Pi-Agent | Supported |
Only tools with local data appear in the dashboard — no empty tabs, no clutter.
Features
- Combined + per-agent views — stacked charts showing cost breakdown across all your tools
- Per-model costs — see exactly which models eat your budget (Opus 4.6 vs Sonnet 4.5 vs GPT-5.3)
- Per-project breakdown — donut chart with cost/session data per project
- Daily & weekly trends — spot patterns in your usage over time
- Date range filtering — This Week, This Month, Last 30/90 Days, All Time
- Dark mode — System / Light / Dark theme toggle, persisted across sessions
- Token breakdown — input, output, cache read/write, reasoning tokens with tooltips
- Usage streaks — see your consecutive days of AI coding activity
- JSON export —
--jsonflag for scripting and automation - 100% offline — everything runs locally, nothing is uploaded
Quick Start
npx code-usageOr install globally:
npm install -g code-usageThat's it. If you have session data from any supported tool, the dashboard opens automatically.
CLI Options
code-usage # Open dashboard in browser
code-usage --no-open # Generate HTML without opening
code-usage --json # Print structured JSON to stdout
code-usage --range 30d # Filter: 7d, 30d, 90d, all
code-usage -v # Version
code-usage -h # HelpOutput
~/.code-usage/current/code-usage-dashboard.html # Interactive dashboard
~/.code-usage/current/openusage-data.json # Raw data snapshotHow It Works
- Reads local session files from each tool's standard data directory
- Calculates token counts and API-equivalent cost estimates per model
- Aggregates by day, week, project, and model
- Builds a single self-contained HTML file with all data inlined
- Opens it in your browser
Pricing is based on published API rates. Fallback pricing powered by LiteLLM. If you're on a subscription plan (Claude Max, Codex Pro), actual billed cost may differ.
Privacy
All data stays on your machine. code-usage only reads standard local session files — no .env, no API keys, no network calls.
Development
npm install
npm run lint # Biome
npm test # Vitest (53 tests)
npm run build:dashboard # Rebuild template
node bin/code-usage.js # Run locally