Track your Claude Code usage and see what it would cost on API pricing. Get insights into your AI coding productivity with beautiful ASCII charts and real-time cost analysis.
- π° Cost Analysis: See what your usage would cost on API pay-as-you-go pricing vs Claude Code Max ($100/month)
- π Beautiful ASCII Charts: Visualize your daily usage patterns over the last 30 days
- π€ Model Breakdown: Track usage by model (Sonnet 4, Opus 4, etc.)
- π Projections: Daily and monthly cost estimates based on your usage
- π₯οΈ Menu Bar Widget: Real-time usage display in macOS menu bar
- βοΈ iCloud Sync: NEW! Sync usage data across multiple Macs
- π Multi-Mac Support: NEW! Reconcile and view combined usage from all your devices
- π§ Zero Dependencies: Uses only Python standard library for core features
- β‘ Fast: Analyzes thousands of conversations in seconds
Download the latest installer from the Releases page:
- ClaudeUsageTracker-MenuBar-1.0.0.dmg - Drag to Applications
- ClaudeUsageTracker-MenuBar-1.0.0.pkg - Double-click to install
The app runs in your menu bar and includes full iCloud sync support.
Important: See MACOS_INSTALLATION.md for security warning workaround on first launch.
# Clone the repository
git clone https://github.com/AndyBoWu/claude-usage-tracker.git
cd claude-usage-tracker
# Run the tracker
python3 claude_usage_tracker.py
# Or install the handy alias
echo 'alias cu="python3 $(pwd)/claude_usage_tracker.py"' >> ~/.zshrc
source ~/.zshrc
# Now just type:
cuπ° CLAUDE CODE USAGE SUMMARY
========================================
π USAGE (30 days):
Total requests: 18,186
Total tokens: 71,680,667
π΅ COSTS:
API equivalent: $951.49
Your cost: $100.00 (Max plan)
You saved: $851.49
π PROJECTIONS:
Daily average: $105.72
Monthly estimate: $3,171.64
π€ MODEL USAGE:
Claude Sonnet 4: 15,388 requests β $578.32
Claude Opus 4: 2,763 requests β $373.17
<synthetic>: 35 requests β $0.00
π
RECENT ACTIVITY:
π Activity Chart (max: 3,646 requests)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
06-07 ββββββββββββββββββββββββββββββ β 2,164
06-08 ββββββββββββββββββββββββββββββββββββββββ β 2,911
06-09 ββββββββββββββββββββββββββββββββββββββββββββββββββββ 3,646
06-10 ββββββββββββββββββββββββββββββ β 2,124
06-11 ββββββββββββββββββββββββββββββββββββββββββββββ β 3,307
06-12 βββββββββββββββββββββββββββββββββββββ β 2,689
06-13 ββββββββββββββ β 1,001
06-14 βββ β 215
06-15 ββ β 129
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Budget Planning: Understand if Claude Code Max subscription saves you money
- Usage Optimization: Identify peak usage days and patterns
- Team Insights: Track team-wide Claude usage (if sharing logs)
- Cost Allocation: Understand costs per project or time period
Show real-time usage in your menu bar
# Start the menu bar widget
python3 claude_menu_bar.py
# Or use the convenience script
./start_menu_bar.shThe widget shows:
- Daily token count
- Equivalent API cost
- Updates every 30 seconds
- Minimal resource usage
To have the menu bar widget start automatically when you log in:
Method 1: Using LaunchAgent (Recommended)
- Create a LaunchAgent plist file:
mkdir -p ~/Library/LaunchAgents
cat > ~/Library/LaunchAgents/com.claude.usage-tracker.plist << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.claude.usage-tracker</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python3</string>
<string>/Users/YOUR_USERNAME/claude-usage-tracker/claude_menu_bar.py</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<false/>
</dict>
</plist>
EOF- Replace
/Users/YOUR_USERNAME/claude-usage-trackerwith your actual path - Load the LaunchAgent:
launchctl load ~/Library/LaunchAgents/com.claude.usage-tracker.plistTo unload: launchctl unload ~/Library/LaunchAgents/com.claude.usage-tracker.plist
Method 2: Using Login Items
- Open System Settings β General β Login Items
- Click the + button under "Open at Login"
- Navigate to your
start_menu_bar.shscript - Select it and click Open
Method 3: Using a Startup App
Create an Automator app:
- Open Automator and create a new Application
- Add a "Run Shell Script" action
- Enter:
/path/to/your/claude-usage-tracker/start_menu_bar.sh - Save as "Claude Usage Tracker.app"
- Add to Login Items as in Method 2
Sync usage data across all your Macs via iCloud
- Install on Mac #1: Download and install the menu bar app
- Sync to iCloud: Click menu bar icon β "Sync to iCloud"
- Install on Mac #2: Repeat installation on your other Mac(s)
- Sync Mac #2: Click menu bar icon β "Sync to iCloud"
- Wait for iCloud: Give it 2-5 minutes to sync between devices
- Reconcile Data: Click "Reconcile All Macs" on either Mac
- View Combined: Click "View Combined Stats" to see total usage
- Automatic Machine ID: Each Mac is uniquely identified
- Incremental Sync: Only new data is synced to save bandwidth
- Conflict Resolution: Handles duplicate sessions intelligently
- Privacy First: Only usage metrics are synced, no conversation content
- iCloud Native: Uses your existing iCloud Drive, no external services
# Sync current Mac's data
claude-usage --sync
# Reconcile data from all Macs
claude-usage --reconcile
# View combined statistics
claude-usage --from-reconciled
# Check sync status
claude-usage --sync-statusSync data is stored in:
~/Library/Mobile Documents/com~apple~CloudDocs/ClaudeUsageTracker/
# Show JSON output
claude-usage --json
# Filter by date range
claude-usage --start-date 2025-01-01 --end-date 2025-01-14
# Specify custom Claude directory
claude-usage --claude-dir /path/to/.claude
# Sync to iCloud (NEW!)
claude-usage --sync
# Reconcile multi-Mac data (NEW!)
claude-usage --reconcile
# View combined stats from all Macs (NEW!)
claude-usage --from-reconciledAdd Claude usage to your tmux status bar
# Add to ~/.tmux.conf
set -g status-right '#(~/claude-usage-tracker/claude_tmux_status.sh) | %H:%M'See tmux_setup.md for detailed instructions.
- Reads your local Claude Code conversation logs from
~/.claude/projects/ - Parses the JSON to extract token usage per conversation
- Calculates costs based on current API pricing
- Compares with Claude Code Max subscription ($100/month)
- Visualizes usage patterns with ASCII charts
The tool is read-only and doesn't modify any files or send data anywhere.
- All analysis happens locally on your machine
- No data is sent to external servers
- No telemetry or analytics
- Completely open source
- Python 3.6 or higher
- Claude Code installed with conversation logs in
~/.claude/projects/ - No external Python dependencies!
- macOS: For menu bar widget functionality
rumps: Only if using the menu bar widget (pip install rumps)
Contributions are welcome! Areas for improvement:
- Export Features: Add CSV/JSON export functionality
- Web Dashboard: Create a web interface for usage visualization
- Windows/Linux Widgets: Port menu bar functionality
- Performance: Optimize for very large conversation histories
- Analytics: Add more detailed usage analytics
Please read CONTRIBUTING.md for details.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built for the Claude Code community
- Inspired by the need to understand AI tool costs
- Thanks to all contributors and testers
Made with β€οΈ for the Claude Code community
If this tool saves you money, consider starring β the repo!