View your Claude Code API usage directly in your terminal π
A beautiful command-line tool to visualize Claude Code token usage, costs, and activity across all your projects.
β¨ Interactive Mode - Beautiful menu-driven interface with Claude branding π Token Breakdown - Input, Output, Cache Write, and Cache Read tokens by model π Project Analytics - View usage breakdown by project π¬ Session Details - Drill down to individual session messages π¨ Beautiful Output - Colorful tables with proper formatting and emojis β‘ Fast & Lightweight - No external services, reads local Claude data
Run instantly without installation:
npx claude-usage-cliInstall globally to use anywhere:
npm install -g claude-usage-cliThen simply run:
claude-usageRunning claude-usage launches an interactive menu where you can explore your usage data:
claude-usageThe interactive mode features:
- π Summary with total sessions, messages, tokens, and costs
- π Last 7 Days Activity
- π Token Usage by Model
- π All Projects view
- π Refresh Data
- Beautiful Claude ASCII art header in orange
Shows total usage statistics, token breakdown by model, and recent activity:
claude-usage overviewView all projects with session counts and total costs:
claude-usage projectsSee all sessions within a specific project:
claude-usage project /path/to/projectGet detailed message-level breakdown for a session:
claude-usage session <session-id>
# Or specify project
claude-usage session <session-id> --project /path/to/projectCheck current settings and data directory:
claude-usage configBy default, the tool reads from ~/.claude. To use a different location:
claude-usage --data-dir /custom/path/to/claude/dataOr set the CLAUDE_DATA_DIR environment variable:
export CLAUDE_DATA_DIR=/custom/path/to/claude/data
claude-usage ββββββββββ ββββββ βββ ββββββββββ ββββββββ
βββββββββββ βββββββββββ βββββββββββββββββββ
βββ βββ βββββββββββ ββββββ βββββββββ
βββ βββ βββββββββββ ββββββ βββββββββ
βββββββββββββββββββ ββββββββββββββββββββββββββββ
ββββββββββββββββββ βββ βββββββ βββββββ ββββββββ
Usage Visualizer γ» Track your AI costs
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Summary:
π¬ Total Sessions: 32
π¨ Total Messages: 5,393
π’ Total Tokens Used: 141,115,796
β¬οΈ Total Input Tokens: 54,341,054
β¬οΈ Total Output Tokens: 12,326
π° Estimated Cost: $1063.1512
? What would you like to see? (Use arrow keys)
β― π
Last 7 Days Activity
π Token Usage by Model
π All Projects
ββββββββββββββ
π Refresh Data
β Exit
π Token Usage by Model:
βββββββββββββββββββββββββ¬βββββββββββββ¬βββββββββ¬ββββββββββββββ¬βββββββββββββ¬ββββββββββββ
β Model β Input β Output β Cache Write β Cache Read β Cost β
βββββββββββββββββββββββββΌβββββββββββββΌβββββββββΌββββββββββββββΌβββββββββββββΌββββββββββββ€
β opus-4-6 β 54,272,618 β 4,678 β 428,133 β 1,735,051 β $825.0702 β
β sonnet-4-5 (20250929) β 17,478 β 568 β 1,852,448 β 21,403,174 β $13.4286 β
βββββββββββββββββββββββββ΄βββββββββββββ΄βββββββββ΄ββββββββββββββ΄βββββββββββββ΄ββββββββββββ
Claude Usage CLI reads your local Claude Code data files:
stats-cache.json- Aggregated statisticshistory.jsonl- Session metadata and namesprojects/- Individual session message logs
All data stays local. No external API calls or data transmission.
# Clone the repository
git clone <your-repo>
cd claude-usage-cli
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run locally
node dist/index.js
# Or use tsx for development
npm run devsrc/
βββ index.ts # Main CLI entry point
βββ types.ts # TypeScript type definitions
βββ config.ts # Configuration and data directory
βββ loader.ts # Data loading from Claude files
βββ pricing.ts # Token pricing and cost calculation
βββ commands/ # CLI command implementations
βββ interactive.ts # Interactive menu mode
βββ overview.ts
βββ projects.ts
βββ project.ts
βββ session.ts
βββ config.ts
- Node.js >= 18.0.0
- Claude Code data directory (usually
~/.claude)
To make this available via npx for everyone:
- Create an npm account at npmjs.com
- Login locally:
npm login - Update package name to be unique (if needed)
- Publish:
npm publish
Then users can run:
npx claude-usage-cliMIT
Contributions welcome! Please open an issue or PR.
Created by Hamid π