| name | claude-code-usage-monitor |
| description | Monitor Claude AI token usage in real-time with ML predictions, cost analytics, and session limit warnings |
| triggers | ["how do I monitor my Claude token usage","track Claude API usage and costs","set up Claude usage monitoring","check my Claude token limits","monitor Claude Code session usage","predict when I'll hit Claude limits","analyze Claude usage patterns","configure Claude usage alerts"] |
Claude Code Usage Monitor
Skill by ara.so — Claude Code Skills collection.
What It Does
Claude Code Usage Monitor is a real-time terminal monitoring tool that tracks Claude AI token consumption, provides ML-based predictions for session limits, calculates costs, and warns you before hitting usage caps. It supports multiple Claude plans (Pro, Max5, Max20, Custom) with auto-detection, P90 percentile analysis, and intelligent session tracking.
Key capabilities:
- Real-time token/message/cost monitoring with Rich UI
- ML-based P90 predictions for session limits
- Multi-plan support with automatic plan detection
- Cost analytics with model-specific pricing
- Advanced warning system with predictive alerts
- Daily/monthly usage aggregation views
- Auto-detected timezone and time format
Installation
Recommended: Using uv (fastest, isolated)
uv tool install claude-monitor
git clone https://github.com/Maciek-roboblog/Claude-Code-Usage-Monitor.git
cd Claude-Code-Usage-Monitor
uv tool install .
Alternative: Using pip
pip install claude-monitor
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Alternative: Using pipx
pipx install claude-monitor
Basic Usage
Command-Line Interface
The monitor can be invoked with multiple aliases:
claude-monitor
claude-code-monitor
cmonitor
ccmonitor
ccm
Core Commands
claude-monitor
claude-monitor --plan pro
claude-monitor --plan max5
claude-monitor --plan max20
claude-monitor --plan custom
claude-monitor --plan custom --custom-limit-tokens 100000
claude-monitor --view realtime
claude-monitor --view daily
claude-monitor --view monthly
claude-monitor --refresh-rate 5
claude-monitor --refresh-per-second 1.0
claude-monitor --reset-hour 3
claude-monitor --theme dark
claude-monitor --time-format 24h
claude-monitor --timezone "America/New_York"
claude-monitor --log-level DEBUG
claude-monitor --log-file ~/claude-monitor.log
claude-monitor --debug
claude-monitor --version
claude-monitor --help
claude-monitor --clear
Configuration
Plan Options
| Plan | Token Limit | Cost Limit | Use Case |
|---|
pro | 44,000 | $18.00 | Claude Pro subscription |
max5 | 88,000 | $35.00 | Claude Max5 subscription |
max20 | 220,000 | $140.00 | Claude Max20 subscription |
custom | P90-based | $50.00 (default) | Auto-detection with ML |
Persistent Configuration
Settings are automatically saved to ~/.claude-monitor/last_used.json:
claude-monitor --plan pro --theme dark --timezone "Europe/London" --refresh-rate 5
claude-monitor --plan pro
claude-monitor --plan pro --theme light
claude-monitor --clear
What gets saved:
- View type (
--view)
- Theme (
--theme)
- Timezone (
--timezone)
- Time format (
--time-format)
- Refresh rates (
--refresh-rate, --refresh-per-second)
- Reset hour (
--reset-hour)
- Custom limits (
--custom-limit-tokens)
Note: Plan selection (--plan) is never saved and must be specified each time.
Python API Usage
While primarily a CLI tool, you can integrate it programmatically:
from claude_monitor.core.config import Config
from claude_monitor.core.data_fetcher import DataFetcher
from claude_monitor.core.analytics import SessionAnalyzer
from claude_monitor.models.plan import Plan
config = Config(
plan=Plan.PRO,
refresh_rate=10,
theme="dark",
timezone="America/New_York"
)
fetcher = DataFetcher(config)
usage_data = fetcher.fetch_usage()
print(f"Tokens used: {usage_data.token_usage}")
print(f"Messages: {usage_data.message_count}")
print(f"Cost: ${usage_data.cost:.2f}")
analyzer = SessionAnalyzer(config)
sessions = fetcher.fetch_sessions()
predictions = analyzer.analyze_sessions(sessions)
print(f"P90 token limit: {predictions.p90_tokens}")
print(f"Predicted session end: {predictions.estimated_end_time}")
Advanced Usage Patterns
Monitoring Long-Running Sessions
claude-monitor --plan custom --refresh-rate 15
claude-monitor --plan max20 --refresh-rate 5 --refresh-per-second 2.0
claude-monitor --plan pro --debug --log-file ./monitor.log
Cost Analysis
from claude_monitor.core.data_fetcher import DataFetcher
from claude_monitor.core.config import Config
config = Config()
fetcher = DataFetcher(config)
usage = fetcher.fetch_usage()
print(f"Total cost: ${usage.cost:.2f}")
print(f"Input tokens: {usage.input_tokens}")
print(f"Output tokens: {usage.output_tokens}")
print(f"Cache tokens: {usage.cache_read_tokens}")
for model, tokens in usage.model_usage.items():
print(f"{model}: {tokens} tokens")
Session Analysis
from claude_monitor.core.analytics import SessionAnalyzer
from claude_monitor.core.data_fetcher import DataFetcher
from claude_monitor.core.config import Config
config = Config(plan=Plan.CUSTOM)
fetcher = DataFetcher(config)
analyzer = SessionAnalyzer(config)
sessions = fetcher.fetch_sessions()
analysis = analyzer.analyze_sessions(sessions)
print(f"Total sessions: {len(sessions)}")
print(f"P90 tokens: {analysis.p90_tokens}")
print(f"P90 messages: {analysis.p90_messages}")
print(f"P90 cost: ${analysis.p90_cost:.2f}")
print(f"Burndown rate: {analysis.token_burndown_rate:.2f} tokens/min")
Custom Limit Detection
from claude_monitor.core.config import Config
from claude_monitor.models.plan import Plan
config = Config(
plan=Plan.CUSTOM,
view="realtime"
)
config = Config(
plan=Plan.CUSTOM,
custom_limit_tokens=150000,
view="realtime"
)
Warning System Integration
from claude_monitor.ui.warnings import WarningGenerator
from claude_monitor.core.data_fetcher import DataFetcher
from claude_monitor.core.config import Config
config = Config(plan=Plan.PRO)
fetcher = DataFetcher(config)
warning_gen = WarningGenerator(config)
usage = fetcher.fetch_usage()
warnings = warning_gen.generate_warnings(usage)
for warning in warnings:
print(f"[{warning.level}] {warning.message}")
if warning.suggestion:
print(f" Suggestion: {warning.suggestion}")
Configuration File Format
The monitor stores configuration in ~/.claude-monitor/last_used.json:
{
"view": "realtime",
"theme": "dark",
"timezone": "America/New_York",
"time_format": "24h",
"refresh_rate": 10,
"refresh_per_second": 0.75,
"reset_hour": 0,
"custom_limit_tokens": 100000
}
Environment Variables
export TZ="America/New_York"
export CLAUDE_MONITOR_LOG_LEVEL=DEBUG
export SENTRY_DSN="your-sentry-dsn"
Common Patterns
Daily Standup Usage Report
claude-monitor --view daily --plan pro
claude-monitor --view daily --log-file daily-report.log
Cost Tracking Workflow
claude-monitor --plan custom --theme dark --refresh-rate 10
Multi-Timezone Team
claude-monitor --timezone "America/New_York" --time-format 12h
claude-monitor --timezone "Europe/London" --time-format 24h
claude-monitor --timezone "Asia/Tokyo" --time-format 24h
Performance Optimization
claude-monitor --refresh-rate 30 --refresh-per-second 0.5
claude-monitor --refresh-rate 5 --refresh-per-second 2.0
Data Storage
The monitor stores data in ~/.claude-monitor/:
~/.claude-monitor/
├── last_used.json # Saved preferences
├── usage_cache.json # Cached usage data
└── sessions_cache.json # Cached session data
Troubleshooting
Command Not Found
pip list | grep claude-monitor
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
~/.local/bin/claude-monitor
Externally-Managed-Environment Error
uv tool install claude-monitor
pipx install claude-monitor
python3 -m venv ~/claude-monitor-env
source ~/claude-monitor-env/bin/activate
pip install claude-monitor
No Data Showing
claude-monitor --debug --log-file debug.log
cat ~/.claude-monitor/usage_cache.json
claude-monitor --plan custom --custom-limit-tokens 100000
Display Issues
claude-monitor --theme light
claude-monitor --clear
echo $COLORTERM
Timezone Problems
timedatectl
date +%Z
claude-monitor --timezone UTC
python3 -c "import zoneinfo; print('\n'.join(sorted(zoneinfo.available_timezones())))"
High CPU Usage
claude-monitor --refresh-rate 30 --refresh-per-second 0.5
cat ~/.claude-monitor/last_used.json
Cache Issues
rm -rf ~/.claude-monitor/
claude-monitor --clear
Integration Examples
Shell Script Integration
#!/bin/bash
claude-monitor --plan pro --log-file session.log &
MONITOR_PID=$!
echo "Session started, monitoring in background..."
trap "kill $MONITOR_PID 2>/dev/null" EXIT
CI/CD Usage Tracking
#!/bin/bash
claude-monitor --view daily --plan custom --log-file ci-usage.log
grep "Total Tokens" ci-usage.log | tail -1
Alerting Script
#!/bin/bash
claude-monitor --plan pro --refresh-rate 60 --log-file usage.log &
PID=$!
while true; do
if grep -q "CRITICAL" usage.log; then
echo "Usage limit critical!" | mail -s "Claude Alert" admin@example.com
break
fi
sleep 300
done
kill $PID
API Rate Limits
The monitor respects Claude API rate limits:
- Default refresh: 10 seconds (safe for all plans)
- Minimum recommended: 5 seconds
- Maximum frequency: 1 second (use sparingly)
Performance Tips
-
Optimal refresh rates:
- Active monitoring:
--refresh-rate 10 --refresh-per-second 1.0
- Background monitoring:
--refresh-rate 30 --refresh-per-second 0.5
- Intensive development:
--refresh-rate 5 --refresh-per-second 2.0
-
Resource usage:
- Memory: ~50-100 MB
- CPU: <5% with default settings
- Network: ~1 KB per refresh
-
Cache optimization:
- Session cache: 8 days (192 hours)
- Usage cache: Updated per refresh rate
- Auto-cleanup of old data
Related Tools
- Claude Desktop App (official client)
- Claude API (direct API access)
- Claude Code (IDE integration)
License
MIT License - see project repository for details.