claude-code-usage
Health Warn
- License รขโฌโ License: MIT
- Description รขโฌโ Repository has a description
- Active repo รขโฌโ Last push 0 days ago
- Low visibility รขโฌโ Only 8 GitHub stars
Code Warn
- process.env รขโฌโ Environment variable access in lib/github-prompt.js
- process.env รขโฌโ Environment variable access in lib/usage.js
Permissions Pass
- Permissions รขโฌโ No dangerous permissions requested
No AI report is available for this listing yet.
๐ CLI tool to track Claude Code usage, costs & token consumption. Analyze your AI coding assistant spending locally.
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
- ๐ Dual View Modes - Switch between daily aggregated view and detailed message view
- ๐ฏ Smart Project Detection - Auto-detects current project when run in project directories
- ๐ Clean Table Display - Organized tabular output 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
- ๐ Auto Update Check - Automatically checks for new versions and notifies when updates are available
- ๐ Easy to Use - Simple installation and intuitive commands
๐ Quick Start
Global Installation (Recommended)
npm install -g claude-code-usage
ccu # View statistics instantly
Alternative 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
These are the basic commands you can use:
# View usage statistics (default command)
ccu
# Display version information
ccu -v
# Display help information
ccu --help
# List all available projects
ccu --list-projects
# or use the short form
ccu -lp
# List all available models with pricing
ccu --list-models
# or use the short form
ccu -lm
๐ Filtering Options
Filter your usage data by time range and project.
Note: It's recommended to wrap time filters in quotes if they contain spaces.
โฐ Time Filtering Formats
The tool supports various time filtering formats for maximum flexibility:
Relative Time Filters (no quotes needed):
5min,30min- Last N minutes2h,12h- Last N hours7d,30d- Last N days1m,6m- Last N months1y,2y- Last N years
Date Range Filters:
6-8- Month range (June to August, current year)july-august,jan-mar- Named month ranges2024-7-2024-8- Cross-year month ranges2024-07-01,2024-08-31- Specific date ranges
Precise DateTime Filters (ISO 8601 format, recommended):
2024-07-30T16:00:00,2024-07-30T18:00:00- Second precision2024-07-30T16:00,2024-07-30T18:00- Minute precision2024-07-30T16,2024-07-30T18- Hour precision
Human-readable DateTime (requires quotes):
"2024-07-30 16:00:00,2024-07-30 18:00:00"- Second precision"2024-07-30 16:00,2024-07-30 18:00"- Minute precision
# Filter by relative time (no quotes needed)
ccu -t 5min # Last 5 minutes
ccu -t 2h # Last 2 hours
ccu -t 7d # Last 7 days
ccu -t 1m # Last 1 month
ccu -t 1y # Last 1 year
# Filter by month range (no quotes needed)
ccu -t 6-8 # June to August (current year)
ccu -t july-august # July to August (current year)
# Filter by date and time (T-separator, no quotes needed)
ccu -t 2024-07-01T14:30:15,2024-07-01T16:45:30 # With seconds
ccu -t 2024-07-01T14:30,2024-07-01T16:45 # With minutes
ccu -t 2024-07-01T14,2024-07-01T16 # With hours
# Filter by date and time (space separator, quotes needed)
ccu -t "2024-07-01 14:30,2024-07-01 16:45"
# Filter by specific date range
ccu -t 2024-07-01,2024-08-31
ccu -t 2024-7-2024-8 # July 2024 to August 2024
# Filter by project (partial matching supported)
ccu -p myproject # Show only messages from projects containing "myproject"
# Combine filters for precise results
ccu -t 1m -p my-website # Last month's my-website project data
๐ Sorting Options
Sort your results by different criteria:
# 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: ascending, newest at bottom)
ccu -s time -o asc
# Combine sorting with filtering
ccu -p my-website -s cost -o desc # my-website project sorted by cost
๐ฏ Project Auto-Detection
The tool automatically detects your current project and filters results accordingly:
# When run in a project directory, automatically filters to that project
cd my-project
ccu # Shows only my-project usage
# Show all projects explicitly
ccu --all # Shows usage for all projects
ccu -a
# Manual project filtering still works
ccu -p specific-project # Shows only specific-project usage
๐ View Modes
Switch between different viewing modes:
# Default: aggregated view (by project and date)
ccu
# Detailed view: show individual messages
ccu --detailed
ccu -d
# Comparing views for specific projects
ccu -p my-project # Aggregated entry for my-project
ccu -p my-project -d # All individual my-project messages
โญ GitHub Prompt Configuration
Manage the GitHub star prompt that appears after displaying results:
# Permanently disable the GitHub star prompt
ccu --disable-github-prompt
# Re-enable the GitHub star prompt
ccu --enable-github-prompt
# View all available options (including prompt settings)
ccu -h
The tool will show a friendly prompt asking you to star the repository on GitHub after displaying usage statistics. You can:
- Keep it enabled (default) - Helps support the project
- Disable it permanently - The setting is saved and respected across all future runs
- Re-enable it anytime - If you change your mind
Your preference is stored in ~/.claude-code-usage-config.json.
๐ ฐ๏ธ All Options Reference
Complete reference table of all available options:
| Option | Description | Values | Default |
|---|---|---|---|
-t, --time |
Time filter | 5min, 2h, 7d, 1m, 1y, 6-8, july-august, 2024-07-01T14:30,2024-07-01T16:45, etc. |
- |
-p, --project |
Project filter | Project name (partial matching) | auto-detect |
-s, --sort |
Sort field | cost, time, tokens, project |
time |
-o, --order |
Sort order | asc, desc |
asc |
-d, --detailed |
Show individual messages | - | false (aggregated) |
-a, --all |
Show all projects | - | false (auto-detect) |
-lp, --list-projects |
List all projects | - | - |
-lm, --list-models |
List all available models with pricing | - | - |
--disable-github-prompt |
Permanently disable the GitHub star prompt | - | - |
--enable-github-prompt |
Re-enable the GitHub star prompt | - | - |
๐ Sample Output
An example of what the output may look like:
๐ Options applied:
Project: my-website
Sort: cost โ
Results: 3 aggregated entries (45 messages from 58 total)
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโฌโโโโโโโโโโโโ
โ Time โ Project โ Messages โ Input โ Output โ Cache Create โ Cache Read โ Model โ Total โ Cost โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโค
โ 6/29/2025 โ my-website โ 15 โ 1,200 โ 400 โ 60,000 โ 20,000 โ claude-sonnet-4-20250514 โ 81,600 โ $0.249000 โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโค
โ 6/28/2025 โ my-website โ 20 โ 800 โ 300 โ 40,000 โ 15,000 โ claude-sonnet-4-20250514 โ 56,100 โ $0.168500 โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโค
โ 6/27/2025 โ my-website โ 10 โ 845 โ 428 โ 198,600 โ 652,976 โ claude-sonnet-4-20250514 โ 852,849 โ $0.734798 โ
โโโโโโโโโโโโโโโผโโโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโผโโโโโโโโโผโโโโโโโโโโโโโโโผโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโผโโโโโโโโโโโโค
โ TOTAL โ โ 45 โ 2,845 โ 1,128 โ 298,600 โ 687,976 โ โ 990,549 โ $1.152298 โ
โโโโโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโดโโโโโโโโโโโโ
๐ Project List Output
ccu --list-projects
# or use short form: ccu -lp
๐ 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
This tool reads Claude Code usage data from your local files:
~/.claude.json- Main Claude Code configuration~/.claude/projects/- Session records and project data~/.claude/settings.json- User settings (optional)
๐จ Setup Instructions
First time using this tool? If Claude Code isn't configured on your system, 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 Data - All Claude Code usage data read from your local files
- Minimal Network Usage - Only fetches model pricing from LiteLLM (cached for 1 hour)
- No API Keys - No authentication required
- Privacy First - Your usage data never leaves 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
๐ Links
Reviews (0)
Sign in to leave a review.
Leave a reviewNo results found