claude-usage-rzp
v0.1.2
Published
View Claude Code API usage directly in your terminal
Maintainers
Readme
Claude Usage CLI
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.
Features
✨ 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
Quick Start
Using npx (Recommended)
Run instantly without installation:
npx claude-usage-rzpInstallation
Install globally to use anywhere:
npm install -g claude-usage-rzpThen simply run:
claude-usageUsage
Interactive Mode (Default)
Running 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
Commands
Overview
Shows total usage statistics, token breakdown by model, and recent activity:
claude-usage overviewList Projects
View all projects with session counts and total costs:
claude-usage projectsView Project
See all sessions within a specific project:
claude-usage project /path/to/projectView Session
Get detailed message-level breakdown for a session:
claude-usage session <session-id>
# Or specify project
claude-usage session <session-id> --project /path/to/projectConfiguration
Check current settings and data directory:
claude-usage configOptions
Custom Data Directory
By 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-usageExample Output
Interactive Mode
██████╗██╗ █████╗ ██╗ ██╗██████╗ ███████╗
██╔════╝██║ ██╔══██╗██║ ██║██╔══██╗██╔════╝
██║ ██║ ███████║██║ ██║██║ ██║█████╗
██║ ██║ ██╔══██║██║ ██║██║ ██║██╔══╝
╚██████╗███████╗██║ ██║╚██████╔╝██████╔╝███████╗
╚═════╝╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
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
❌ ExitToken Usage by Model
💎 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 │
└───────────────────────┴────────────┴────────┴─────────────┴────────────┴───────────┘How It Works
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.
Development
Local Development
# Clone the repository
git clone https://github.com/hamid-miran/claude-usage-cli.git
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 devProject Structure
src/
├── 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.tsRequirements
- Node.js >= 18.0.0
- Claude Code data directory (usually
~/.claude)
Publishing to npm
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-rzpLicense
MIT
Contributing
Contributions welcome! Please open an issue or PR.
Created by Hamid 👋
