Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (claude-code-usage) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Claude Code Usage
A lightweight CLI tool for analyzing Claude Code usage statistics and costs locally.
✨ Features
- 🔒 100% Local & Secure - No API keys required, reads local Claude Code data only
- ⚡ Quick Analysis - View all usage statistics with a single
ccucommand - 💰 Cost Tracking - Accurate cost calculation based on Claude pricing
- 📊 Detailed Table View - Clean tabular display with token counts, costs, and project info
- 🔍 Smart Filtering - Filter by time ranges and project names
- 📈 Flexible Sorting - Sort by cost, time, tokens, or project name
- 🚀 Easy to Use - Simple installation and intuitive commands
🚀 Quick Start
Global Installation (Recommended)
npm install -g claude-code-usage
ccu # View statistics instantlyAlternative Installation Methods
# One-time usage (no installation required)
npx claude-code-usage
# Local project installation
npm install claude-code-usage
npx claude-code-usage📋 Usage
Basic Commands
# View usage statistics (default)
ccu
# Show version
ccu -v
# Show help
ccu --help
# List all available projects
ccu --list-projects🔍 Filtering Options
# Filter by time range
ccu -t 7d # Last 7 days
ccu -t 1m # Last 1 month
ccu -t 1y # Last 1 year
ccu -t 6-8 # June to August (current year)
ccu -t july-august # July to August (current year)
ccu -t 2024-7-2024-8 # July 2024 to August 2024
ccu -t 2024-07-01,2024-08-31 # Specific date range
# Filter by project (partial matching supported)
ccu -p myproject # Show only messages from projects containing "myproject"
ccu -p my-website # Show only my-website project
# Combine filters
ccu -t 1m -p my-website # Last month's my-website project data📈 Sorting Options
# Sort by cost (highest first)
ccu -s cost -o desc
# Sort by cost (lowest first)
ccu -s cost -o asc
# Sort by total tokens
ccu -s tokens -o desc
# Sort by project name
ccu -s project -o asc
# Sort by time (default)
ccu -s time -o desc
# Combine with filtering
ccu -p my-website -s cost -o desc # my-website project sorted by cost🎛️ All Options
| Option | Description | Values | Default |
|---|---|---|---|
-t, --time |
Time filter | 7d, 1m, 1y, 6-8, july-august, etc. |
- |
-p, --project |
Project filter | Project name (partial matching) | - |
-s, --sort |
Sort field | cost, time, tokens, project |
time |
-o, --order |
Sort order | asc, desc |
desc |
--list-projects |
List all projects | - | - |
📊 Sample Output
🔍 Options applied:
Project: my-website
Sort: cost ↓
Results: 45 messages (58 total)
┌────────────────────────┬─────────────┬──────────┬───────┬────────┬──────────────┬────────────┬──────────────────────────┬───────────┬───────────┐
│ Time │ Project │ Messages │ Input │ Output │ Cache Create │ Cache Read │ Model │ Total │ Cost │
├────────────────────────┼─────────────┼──────────┼───────┼────────┼──────────────┼────────────┼──────────────────────────┼───────────┼───────────┤
│ 6/29/2025, 6:35:47 PM │ my-website │ 45 │ 402 │ 26 │ 20,144 │ 0 │ claude-sonnet-4-20250514 │ 20,572 │ $0.062028 │
├────────────────────────┼─────────────┼──────────┼───────┼────────┼──────────────┼────────────┼──────────────────────────┼───────────┼───────────┤
│ 6/29/2025, 6:35:50 PM │ my-website │ 45 │ 402 │ 26 │ 20,144 │ 0 │ claude-sonnet-4-20250514 │ 20,572 │ $0.062028 │
├────────────────────────┼─────────────┼──────────┼───────┼────────┼──────────────┼────────────┼──────────────────────────┼───────────┼───────────┤
│ 6/29/2025, 6:35:25 PM │ my-website │ 45 │ 3 │ 1 │ 19,617 │ 0 │ claude-sonnet-4-20250514 │ 19,621 │ $0.058875 │
├────────────────────────┼─────────────┼──────────┼───────┼────────┼──────────────┼────────────┼──────────────────────────┼───────────┼───────────┤
│ TOTAL │ │ 45 │ 2,845 │ 1,128 │ 298,600 │ 687,976 │ │ 990,549 │ $1.152298 │
└────────────────────────┴─────────────┴──────────┴───────┴────────┴──────────────┴────────────┴──────────────────────────┴───────────┴───────────┘📁 Project List Output
ccu --list-projects📁 Available projects:
• my-website (45 messages)
• data-analysis (8 messages)
• chatbot-app (5 messages)🛠️ Requirements
- Node.js >= 14.0.0
- Claude Code installed and configured
- At least one Claude Code project with conversation history
📁 Data Sources
Reads local data from:
~/.claude.json- Main Claude Code configuration~/.claude/projects/- Session records and project data~/.claude/settings.json- User settings (optional)
🚨 Setup Instructions
If Claude Code isn't configured, you'll see:
❌ Claude Code configuration not found!
📋 To fix this:
1. Install Claude Code:
npm install -g @anthropic-ai/claude-code
2. Authenticate:
claude
# Follow authentication prompts
3. Start a conversation:
claude "Hello, world!"
4. Run this tool:
ccu🔒 Privacy & Security
- 100% Local - All data read from your local Claude Code files
- No Network Calls - No data sent anywhere
- No API Keys - No authentication required
- Privacy First - Your data stays on your machine
🤝 Contributing
Contributions welcome! Please submit a Pull Request.
📄 License
MIT License - see LICENSE file for details.
🐛 Issues
Found a bug? Create an issue