[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-72000":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":25,"hasPages":23,"topics":26,"createdAt":10,"pushedAt":10,"updatedAt":36,"readmeContent":37,"aiSummary":38,"trendingCount":16,"starSnapshotCount":16,"syncStatus":39,"lastSyncTime":40,"discoverSource":41},72000,"Claude-Code-Usage-Monitor","Maciek-roboblog\u002FClaude-Code-Usage-Monitor","Maciek-roboblog","Real-time Claude Code usage monitor with predictions and warnings","",null,"Python",8177,422,31,72,0,28,68,212,84,38.88,"MIT License",false,"main",true,[27,28,29,30,31,32,33,34,35],"ai","analytics","claude","claude-code","claude-usage","limits","monitoring","terminal","usage-tracking","2026-06-12 02:02:57","# 🎯 Claude Code Usage Monitor\n[![PyPI Version](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fclaude-monitor.svg)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-monitor\u002F)\n[![Python Version](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fpython-3.9+-blue.svg)](https:\u002F\u002Fpython.org)\n[![License: MIT](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-yellow.svg)](https:\u002F\u002Fopensource.org\u002Flicenses\u002FMIT)\n[![PRs Welcome](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPRs-welcome-brightgreen.svg)](http:\u002F\u002Fmakeapullrequest.com)\n[![codecov](https:\u002F\u002Fcodecov.io\u002Fgh\u002FMaciek-roboblog\u002FClaude-Code-Usage-Monitor\u002Fbranch\u002Fmain\u002Fgraph\u002Fbadge.svg)](https:\u002F\u002Fcodecov.io\u002Fgh\u002FMaciek-roboblog\u002FClaude-Code-Usage-Monitor)\n\nA beautiful real-time terminal monitoring tool for Claude AI token usage with advanced analytics, machine learning-based predictions, and Rich UI. Track your token consumption, burn rate, cost analysis, and get intelligent predictions about session limits.\n\n![Claude Token Monitor Screenshot](https:\u002F\u002Fraw.githubusercontent.com\u002FMaciek-roboblog\u002FClaude-Code-Usage-Monitor\u002Fmain\u002Fdoc\u002Fscnew.png)\n\n---\n\n## 📑 Table of Contents\n\n- [✨ Key Features](#-key-features)\n- [🚀 Installation](#-installation)\n  - [⚡ Modern Installation with uv (Recommended)](#-modern-installation-with-uv-recommended)\n  - [📦 Installation with pip](#-installation-with-pip)\n  - [🛠️ Other Package Managers](#️-other-package-managers)\n- [📖 Usage](#-usage)\n  - [Get Help](#get-help)\n  - [Basic Usage](#basic-usage)\n  - [Configuration Options](#configuration-options)\n  - [Available Plans](#available-plans)\n- [🙏 Please Help Test This Release!](#-please-help-test-this-release)\n- [✨ Features & How It Works](#-features--how-it-works)\n  - [Current Features](#current-features)\n  - [Understanding Claude Sessions](#understanding-claude-sessions)\n  - [Token Limits by Plan](#token-limits-by-plan)\n  - [Smart Detection Features](#smart-detection-features)\n- [🚀 Usage Examples](#-usage-examples)\n  - [Common Scenarios](#common-scenarios)\n  - [Best Practices](#best-practices)\n- [🔧 Development Installation](#-development-installation)\n- [Troubleshooting](#troubleshooting)\n  - [Installation Issues](#installation-issues)\n  - [Runtime Issues](#runtime-issues)\n- [📞 Contact](#-contact)\n- [📚 Additional Documentation](#-additional-documentation)\n- [📝 License](#-license)\n- [🤝 Contributors](#-contributors)\n- [🙏 Acknowledgments](#-acknowledgments)\n\n\n\n## ✨ Key Features\n\n### 🚀 **v3.0.0 Major Update - Complete Architecture Rewrite**\n\n- **🔮 ML-based predictions** - P90 percentile calculations and intelligent session limit detection\n- **🔄 Real-time monitoring** - Configurable refresh rates (0.1-20 Hz) with intelligent display updates\n- **📊 Advanced Rich UI** - Beautiful color-coded progress bars, tables, and layouts with WCAG-compliant contrast\n- **🤖 Smart auto-detection** - Automatic plan switching with custom limit discovery\n- **📋 Enhanced plan support** - Updated limits: Pro (44k), Max5 (88k), Max20 (220k), Custom (P90-based)\n- **⚠️ Advanced warning system** - Multi-level alerts with cost and time predictions\n- **💼 Professional Architecture** - Modular design with Single Responsibility Principle (SRP) compliance\n- **🎨 Intelligent theming** - Scientific color schemes with automatic terminal background detection\n- **⏰ Advanced scheduling** - Auto-detected system timezone and time format preferences\n- **📈 Cost analytics** - Model-specific pricing with cache token calculations\n- **🔧 Pydantic validation** - Type-safe configuration with automatic validation\n- **📝 Comprehensive logging** - Optional file logging with configurable levels\n- **🧪 Extensive testing** - 100+ test cases with full coverage\n- **🎯 Error reporting** - Optional Sentry integration for production monitoring\n- **⚡ Performance optimized** - Advanced caching and efficient data processing\n\n### 📋 Default Custom Plan\n\nThe **Custom plan** is now the default option, specifically designed for 5-hour Claude Code sessions. It monitors three critical metrics:\n- **Token usage** - Tracks your token consumption\n- **Messages usage** - Monitors message count\n- **Cost usage** - The most important metric for long sessions\n\nThe Custom plan automatically adapts to your usage patterns by analyzing all your sessions from the last 192 hours (8 days) and calculating personalized limits based on your actual usage. This ensures accurate predictions and warnings tailored to your specific workflow.\n\n\n## 🚀 Installation\n### ⚡ Modern Installation with uv (Recommended)\n\n**Why uv is the best choice:**\n- ✅ Creates isolated environments automatically (no system conflicts)\n- ✅ No Python version issues\n- ✅ No \"externally-managed-environment\" errors\n- ✅ Easy updates and uninstallation\n- ✅ Works on all platforms\n\nThe fastest and easiest way to install and use the monitor:\n\n[![PyPI](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fclaude-monitor.svg)](https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-monitor\u002F)\n\n#### Install from PyPI\n\n```bash\n# Install directly from PyPI with uv (easiest)\nuv tool install claude-monitor\n\n# Run from anywhere\nclaude-monitor  # or cmonitor, ccmonitor for short\n```\n\n\n#### Install from Source\n\n```bash\n# Clone and install from source\ngit clone https:\u002F\u002Fgithub.com\u002FMaciek-roboblog\u002FClaude-Code-Usage-Monitor.git\ncd Claude-Code-Usage-Monitor\nuv tool install .\n\n# Run from anywhere\nclaude-monitor\n```\n\n\n#### First-time uv users\nIf you don't have uv installed yet, get it with one command:\n\n```bash\n# On Linux\u002FmacOS:\ncurl -LsSf https:\u002F\u002Fastral.sh\u002Fuv\u002Finstall.sh | sh\n\n# On Windows:\npowershell -ExecutionPolicy ByPass -c \"irm https:\u002F\u002Fastral.sh\u002Fuv\u002Finstall.ps1 | iex\"\n\n# After installation, restart your terminal\n```\n\n\n### 📦 Installation with pip\n\n```bash\n# Install from PyPI\npip install claude-monitor\n\n# If claude-monitor command is not found, add ~\u002F.local\u002Fbin to PATH:\necho 'export PATH=\"$HOME\u002F.local\u002Fbin:$PATH\"' >> ~\u002F.bashrc\nsource ~\u002F.bashrc  # or restart your terminal\n\n# Run from anywhere\nclaude-monitor  # or cmonitor, ccmonitor for short\n```\n\n\n>\n> **⚠️ PATH Setup**: If you see WARNING: The script claude-monitor is installed in '\u002Fhome\u002Fusername\u002F.local\u002Fbin' which is not on PATH, follow the export PATH command above.\n>\n> **⚠️ Important**: On modern Linux distributions (Ubuntu 23.04+, Debian 12+, Fedora 38+), you may encounter an \"externally-managed-environment\" error. Instead of using --break-system-packages, we strongly recommend:\n> 1. **Use uv instead** (see above) - it's safer and easier\n> 2. **Use a virtual environment** - python3 -m venv myenv && source myenv\u002Fbin\u002Factivate\n> 3. **Use pipx** - pipx install claude-monitor\n>\n> See the Troubleshooting section for detailed solutions.\n\n### 🛠️ Other Package Managers\n\n#### pipx (Isolated Environments)\n```bash\n# Install with pipx\npipx install claude-monitor\n\n# Run from anywhere\nclaude-monitor  # or claude-code-monitor, cmonitor, ccmonitor, ccm for short\n```\n\n\n#### conda\u002Fmamba\n```bash\n# Install with pip in conda environment\npip install claude-monitor\n\n# Run from anywhere\nclaude-monitor  # or cmonitor, ccmonitor for short\n```\n\n\n## 📖 Usage\n\n### Get Help\n\n```bash\n# Show help information\nclaude-monitor --help\n```\n\n#### Available Command-Line Parameters\n\n| Parameter | Type | Default | Description |\n|-----------|------|---------|-------------|\n| --plan | string | custom | Plan type: pro, max5, max20, or custom |\n| --custom-limit-tokens | int | None | Token limit for custom plan (must be > 0) |\n| --view | string | realtime | View type: realtime, daily, or monthly |\n| --timezone | string | auto | Timezone (auto-detected). Examples: UTC, America\u002FNew_York, Europe\u002FLondon |\n| --time-format | string | auto | Time format: 12h, 24h, or auto |\n| --theme | string | auto | Display theme: light, dark, classic, or auto |\n| --refresh-rate | int | 10 | Data refresh rate in seconds (1-60) |\n| --refresh-per-second | float | 0.75 | Display refresh rate in Hz (0.1-20.0) |\n| --reset-hour | int | None | Daily reset hour (0-23) |\n| --log-level | string | INFO | Logging level: DEBUG, INFO, WARNING, ERROR, CRITICAL |\n| --log-file | path | None | Log file path |\n| --debug | flag | False | Enable debug logging |\n| --version, -v | flag | False | Show version information |\n| --clear | flag | False | Clear saved configuration |\n\n#### Plan Options\n\n| Plan | Token Limit | Cost Limit       | Description |\n|------|-------------|------------------|-------------|\n| pro | 19,000 | $18.00           | Claude Pro subscription |\n| max5 | 88,000 | $35.00           | Claude Max5 subscription |\n| max20 | 220,000 | $140.00          | Claude Max20 subscription |\n| custom | P90-based | (default) $50.00 | Auto-detection with ML analysis |\n\n#### Command Aliases\n\nThe tool can be invoked using any of these commands:\n- claude-monitor (primary)\n- claude-code-monitor (full name)\n- cmonitor (short)\n- ccmonitor (short alternative)\n- ccm (shortest)\n\n#### Save Flags Feature\n\nThe monitor automatically saves your preferences to avoid re-specifying them on each run:\n\n**What Gets Saved:**\n- View type (--view)\n- Theme preferences (--theme)\n- Timezone settings (--timezone)\n- Time format (--time-format)\n- Refresh rates (--refresh-rate, --refresh-per-second)\n- Reset hour (--reset-hour)\n- Custom token limits (--custom-limit-tokens)\n\n**Configuration Location:** ~\u002F.claude-monitor\u002Flast_used.json\n\n**Usage Examples:**\n```bash\n# First run - specify preferences\nclaude-monitor --plan pro --theme dark --timezone \"America\u002FNew_York\"\n\n# Subsequent runs - preferences automatically restored\nclaude-monitor --plan pro\n\n# Override saved settings for this session\nclaude-monitor --plan pro --theme light\n\n# Clear all saved preferences\nclaude-monitor --clear\n```\n\n**Key Features:**\n- ✅ Automatic parameter persistence between sessions\n- ✅ CLI arguments always override saved settings\n- ✅ Atomic file operations prevent corruption\n- ✅ Graceful fallback if config files are damaged\n- ✅ Plan parameter never saved (must specify each time)\n\n### Basic Usage\n\n#### With uv tool installation (Recommended)\n```bash\n# Default (Custom plan with auto-detection)\nclaude-monitor\n\n# Alternative commands\nclaude-code-monitor  # Full descriptive name\ncmonitor             # Short alias\nccmonitor            # Short alternative\nccm                  # Shortest alias\n\n# Exit the monitor\n# Press Ctrl+C to gracefully exit\n```\n\n#### Development mode\nIf running from source, use python -m claude_monitor from the src\u002F directory.\n\n### Configuration Options\n\n#### Specify Your Plan\n\n```bash\n# Custom plan with P90 auto-detection (Default)\nclaude-monitor --plan custom\n\n# Pro plan (~44,000 tokens)\nclaude-monitor --plan pro\n\n# Max5 plan (~88,000 tokens)\nclaude-monitor --plan max5\n\n# Max20 plan (~220,000 tokens)\nclaude-monitor --plan max20\n\n# Custom plan with explicit token limit\nclaude-monitor --plan custom --custom-limit-tokens 100000\n```\n\n#### Custom Reset Times\n\n```bash\n# Reset at 3 AM\nclaude-monitor --reset-hour 3\n\n# Reset at 10 PM\nclaude-monitor --reset-hour 22\n```\n\n#### Usage View Configuration\n\n```bash\n# Real-time monitoring with live updates (Default)\nclaude-monitor --view realtime\n\n# Daily token usage aggregated in table format\nclaude-monitor --view daily\n\n# Monthly token usage aggregated in table format\nclaude-monitor --view monthly\n\n```\n\n#### Performance and Display Configuration\n\n```bash\n# Adjust refresh rate (1-60 seconds, default: 10)\nclaude-monitor --refresh-rate 5\n\n# Adjust display refresh rate (0.1-20 Hz, default: 0.75)\nclaude-monitor --refresh-per-second 1.0\n\n# Set time format (auto-detected by default)\nclaude-monitor --time-format 24h  # or 12h\n\n# Force specific theme\nclaude-monitor --theme dark  # light, dark, classic, auto\n\n# Clear saved configuration\nclaude-monitor --clear\n```\n\n#### Timezone Configuration\n\nThe default timezone is **auto-detected from your system**. Override with any valid timezone:\n\n```bash\n# Use US Eastern Time\nclaude-monitor --timezone America\u002FNew_York\n\n# Use Tokyo time\nclaude-monitor --timezone Asia\u002FTokyo\n\n# Use UTC\nclaude-monitor --timezone UTC\n\n# Use London time\nclaude-monitor --timezone Europe\u002FLondon\n```\n\n#### Logging and Debugging\n\n```bash\n# Enable debug logging\nclaude-monitor --debug\n\n# Log to file\nclaude-monitor --log-file ~\u002F.claude-monitor\u002Flogs\u002Fmonitor.log\n\n# Set log level\nclaude-monitor --log-level WARNING  # DEBUG, INFO, WARNING, ERROR, CRITICAL\n```\n\n### Available Plans\n\n| Plan | Token Limit     | Best For |\n|------|-----------------|----------|\n| **custom** | P90 auto-detect | Intelligent limit detection (default) |\n| **pro** | ~19,000         | Claude Pro subscription |\n| **max5** | ~88,000         | Claude Max5 subscription |\n| **max20** | ~220,000        | Claude Max20 subscription |\n\n#### Advanced Plan Features\n\n- **P90 Analysis**: Custom plan uses 90th percentile calculations from your usage history\n- **Cost Tracking**: Model-specific pricing with cache token calculations\n- **Limit Detection**: Intelligent threshold detection with 95% confidence\n\n\n## 🚀 What's New in v3.0.0\n\n### Major Changes\n\n#### **Complete Architecture Rewrite**\n- Modular design with Single Responsibility Principle (SRP) compliance\n- Pydantic-based configuration with type safety and validation\n- Advanced error handling with optional Sentry integration\n- Comprehensive test suite with 100+ test cases\n\n#### **Enhanced Functionality**\n- **P90 Analysis**: Machine learning-based limit detection using 90th percentile calculations\n- **Updated Plan Limits**: Pro (44k), Max5 (88k), Max20 (220k) tokens\n- **Cost Analytics**: Model-specific pricing with cache token calculations\n- **Rich UI**: WCAG-compliant themes with automatic terminal background detection\n\n#### **New CLI Options**\n- --refresh-per-second: Configurable display refresh rate (0.1-20 Hz)\n- --time-format: Automatic 12h\u002F24h format detection\n- --custom-limit-tokens: Explicit token limits for custom plans\n- --log-file and --log-level: Advanced logging capabilities\n- --clear: Reset saved configuration\n- Command aliases: claude-code-monitor, cmonitor, ccmonitor, ccm for convenience\n\n#### **Breaking Changes**\n- Package name changed from claude-usage-monitor to claude-monitor\n- Default plan changed from pro to custom (with auto-detection)\n- Minimum Python version increased to 3.9+\n- Command structure updated (see examples above)\n\n\n## ✨ Features & How It Works\n\n### v3.0.0 Architecture Overview\n\nThe new version features a complete rewrite with modular architecture following Single Responsibility Principle (SRP):\n\n### 🖥️ User Interface Layer\n\n| Component            | Description           |\n| -------------------- | --------------------- |\n| **CLI Module**       | Pydantic-based        |\n| **Settings\u002FConfig**  | Type-safe             |\n| **Error Handling**   | Sentry-ready          |\n| **Rich Terminal UI** | Adaptive Theme        |\n\n---\n\n### 🎛️ Monitoring Orchestrator\n\n| Component                | Key Responsibilities                                             |\n| ------------------------ | ---------------------------------------------------------------- |\n| **Central Control Hub**  | Session Mgmt · Real-time Data Flow · Component Coordination      |\n| **Data Manager**         | Cache Mgmt · File I\u002FO · State Persist                           |\n| **Session Monitor**      | Real-time · 5 hr Windows · Token Track                           |\n| **UI Controller**        | Rich Display · Progress Bars · Theme System                     |\n| **Analytics**            | P90 Calculator · Burn Rate · Predictions                        |\n\n---\n\n### 🏗️ Foundation Layer\n\n| Component           | Core Features                                           |\n| ------------------- | ------------------------------------------------------- |\n| **Core Models**     | Session Data · Config Schema · Type Safety             |\n| **Analysis Engine** | ML Algorithms · Statistical · Forecasting              |\n| **Terminal Themes** | Auto-detection · WCAG Colors · Contrast Opt            |\n| **Claude API Data** | Token Tracking · Cost Calculator · Session Blocks      |\n\n---\n\n**🔄 Data Flow:**\nClaude Config Files → Data Layer → Analysis Engine → UI Components → Terminal Display\n\n\n### Current Features\n\n#### 🔄 Advanced Real-time Monitoring\n- Configurable update intervals (1-60 seconds)\n- High-precision display refresh (0.1-20 Hz)\n- Intelligent change detection to minimize CPU usage\n- Multi-threaded orchestration with callback system\n\n#### 📊 Rich UI Components\n- **Progress Bars**: WCAG-compliant color schemes with scientific contrast ratios\n- **Data Tables**: Sortable columns with model-specific statistics\n- **Layout Manager**: Responsive design that adapts to terminal size\n- **Theme System**: Auto-detects terminal background for optimal readability\n\n#### 📈 Multiple Usage Views\n- **Realtime View** (Default): Live monitoring with progress bars, current session data, and burn rate analysis\n- **Daily View**: Aggregated daily statistics showing Date, Models, Input\u002FOutput\u002FCache tokens, Total tokens, and Cost\n- **Monthly View**: Monthly aggregated data for long-term trend analysis and budget planning\n\n#### 🔮 Machine Learning Predictions\n- **P90 Calculator**: 90th percentile analysis for intelligent limit detection\n- **Burn Rate Analytics**: Multi-session consumption pattern analysis\n- **Cost Projections**: Model-specific pricing with cache token calculations\n- **Session Forecasting**: Predicts when sessions will expire based on usage patterns\n\n#### 🤖 Intelligent Auto-Detection\n- **Background Detection**: Automatically determines terminal theme (light\u002Fdark)\n- **System Integration**: Auto-detects timezone and time format preferences\n- **Plan Recognition**: Analyzes usage patterns to suggest optimal plans\n- **Limit Discovery**: Scans historical data to find actual token limits\n\n### Understanding Claude Sessions\n\n#### How Claude Code Sessions Work\n\nClaude Code operates on a **5-hour rolling session window system**:\n\n1. **Session Start**: Begins with your first message to Claude\n2. **Session Duration**: Lasts exactly 5 hours from that first message\n3. **Token Limits**: Apply within each 5-hour session window\n4. **Multiple Sessions**: Can have several active sessions simultaneously\n5. **Rolling Windows**: New sessions can start while others are still active\n\n#### Session Reset Schedule\n\n**Example Session Timeline:**\n10:30 AM - First message (Session A starts at 10 AM)\n03:00 PM - Session A expires (5 hours later)\n\n12:15 PM - First message (Session B starts 12PM)\n05:15 PM - Session B expires (5 hours later 5PM)\n\n\n#### Burn Rate Calculation\n\nThe monitor calculates burn rate using sophisticated analysis:\n\n1. **Data Collection**: Gathers token usage from all sessions in the last hour\n2. **Pattern Analysis**: Identifies consumption trends across overlapping sessions\n3. **Velocity Tracking**: Calculates tokens consumed per minute\n4. **Prediction Engine**: Estimates when current session tokens will deplete\n5. **Real-time Updates**: Adjusts predictions as usage patterns change\n\n### Token Limits by Plan\n\n#### v3.0.0 Updated Plan Limits\n\n| Plan | Limit (Tokens) | Cost Limit       | Messages | Algorithm |\n|------|----------------|------------------|----------|-----------|\n| **Claude Pro** | 19,000         | $18.00           | 250 | Fixed limit |\n| **Claude Max5** | 88,000         | $35.00           | 1,000 | Fixed limit |\n| **Claude Max20** | 220,000        | $140.00          | 2,000 | Fixed limit |\n| **Custom** | P90-based      | (default) $50.00 | 250+ | Machine learning |\n\n#### Advanced Limit Detection\n\n- **P90 Analysis**: Uses 90th percentile of your historical usage\n- **Confidence Threshold**: 95% accuracy in limit detection\n- **Cache Support**: Includes cache creation and read token costs\n- **Model-Specific**: Adapts to Claude 3.5, Claude 4, and future models\n\n### Technical Requirements\n\n#### Dependencies (v3.0.0)\n\n```toml\n# Core dependencies (automatically installed)\npytz>=2023.3                # Timezone handling\nrich>=13.7.0                # Rich terminal UI\npydantic>=2.0.0             # Type validation\npydantic-settings>=2.0.0    # Configuration management\nnumpy>=1.21.0               # Statistical calculations\nsentry-sdk>=1.40.0          # Error reporting (optional)\npyyaml>=6.0                 # Configuration files\ntzdata                      # Windows timezone data\n```\n\n#### Python Requirements\n\n- **Minimum**: Python 3.9+\n- **Recommended**: Python 3.11+\n- **Tested on**: Python 3.9, 3.10, 3.11, 3.12, 3.13\n\n### Smart Detection Features\n\n#### Automatic Plan Switching\n\nWhen using the default Pro plan:\n\n1. **Detection**: Monitor notices token usage exceeding 7,000\n2. **Analysis**: Scans previous sessions for actual limits\n3. **Switch**: Automatically changes to custom_max mode\n4. **Notification**: Displays clear message about the change\n5. **Continuation**: Keeps monitoring with new, higher limit\n\n#### Limit Discovery Process\n\nThe auto-detection system:\n\n1. **Scans History**: Examines all available session blocks\n2. **Finds Peaks**: Identifies highest token usage achieved\n3. **Validates Data**: Ensures data quality and recency\n4. **Sets Limits**: Uses discovered maximum as new limit\n5. **Learns Patterns**: Adapts to your actual usage capabilities\n\n\n## 🚀 Usage Examples\n\n### Common Scenarios\n\n#### 🌅 Morning Developer\n**Scenario**: You start work at 9 AM and want tokens to reset aligned with your schedule.\n\n```bash\n# Set custom reset time to 9 AM\n.\u002Fclaude_monitor.py --reset-hour 9\n\n# With your timezone\n.\u002Fclaude_monitor.py --reset-hour 9 --timezone US\u002FEastern\n```\n\n\n**Benefits**:\n- Reset times align with your work schedule\n- Better planning for daily token allocation\n- Predictable session windows\n\n#### 🌙 Night Owl Coder\n**Scenario**: You often work past midnight and need flexible reset scheduling.\n\n```bash\n# Reset at midnight for clean daily boundaries\n.\u002Fclaude_monitor.py --reset-hour 0\n\n# Late evening reset (11 PM)\n.\u002Fclaude_monitor.py --reset-hour 23\n```\n\n\n**Strategy**:\n- Plan heavy coding sessions around reset times\n- Use late resets to span midnight work sessions\n- Monitor burn rate during peak hours\n\n#### 🔄 Heavy User with Variable Limits\n**Scenario**: Your token limits seem to change, and you're not sure of your exact plan.\n\n```bash\n# Auto-detect your highest previous usage\nclaude-monitor --plan custom_max\n\n# Monitor with custom scheduling\nclaude-monitor --plan custom_max --reset-hour 6\n```\n\n\n**Approach**:\n- Let auto-detection find your real limits\n- Monitor for a week to understand patterns\n- Note when limits change or reset\n\n#### 🌍 International User\n**Scenario**: You're working across different timezones or traveling.\n\n```bash\n# US East Coast\nclaude-monitor --timezone America\u002FNew_York\n\n# Europe\nclaude-monitor --timezone Europe\u002FLondon\n\n# Asia Pacific\nclaude-monitor --timezone Asia\u002FSingapore\n\n# UTC for international team coordination\nclaude-monitor --timezone UTC --reset-hour 12\n```\n\n\n#### ⚡ Quick Check\n**Scenario**: You just want to see current status without configuration.\n\n```bash\n# Just run it with defaults\nclaude-monitor\n\n# Press Ctrl+C after checking status\n```\n\n#### 📊 Usage Analysis Views\n**Scenario**: Analyzing your token usage patterns over different time periods.\n\n```bash\n# View daily usage breakdown with detailed statistics\nclaude-monitor --view daily\n\n# Analyze monthly token consumption trends\nclaude-monitor --view monthly --plan max20\n\n# Export daily usage data to log file for analysis\nclaude-monitor --view daily --log-file ~\u002Fdaily-usage.log\n\n# Review usage in different timezone\nclaude-monitor --view daily --timezone America\u002FNew_York\n```\n\n**Use Cases**:\n- **Realtime**: Live monitoring of current session and burn rate\n- **Daily**: Analyze daily consumption patterns and identify peak usage days\n- **Monthly**: Long-term trend analysis and monthly budget planning\n\n\n### Plan Selection Strategies\n\n#### How to Choose Your Plan\n\n**Start with Default (Recommended for New Users)**\n```bash\n# Pro plan detection with auto-switching\nclaude-monitor\n```\n\n- Monitor will detect if you exceed Pro limits\n- Automatically switches to custom_max if needed\n- Shows notification when switching occurs\n\n**Known Subscription Users**\n```bash\n# If you know you have Max5\nclaude-monitor --plan max5\n\n# If you know you have Max20\nclaude-monitor --plan max20\n```\n\n\n**Unknown Limits**\n```bash\n# Auto-detect from previous usage\nclaude-monitor --plan custom_max\n```\n\n\n### Best Practices\n\n#### Setup Best Practices\n\n1. **Start Early in Sessions**\n\n```bash\n   # Begin monitoring when starting Claude work (uv installation)\n   claude-monitor\n\n   # Or development mode\n   .\u002Fclaude_monitor.py\n   ```\n\n   - Gives accurate session tracking from the start\n   - Better burn rate calculations\n   - Early warning for limit approaches\n\n2. **Use Modern Installation (Recommended)**\n\n```bash\n   # Easy installation and updates with uv\n   uv tool install claude-monitor\n   claude-monitor --plan max5\n   ```\n\n   - Clean system installation\n   - Easy updates and maintenance\n   - Available from anywhere\n\n3. **Custom Shell Alias (Legacy Setup)**\n\n```bash\n   # Add to ~\u002F.bashrc or ~\u002F.zshrc (only for development setup)\n   alias claude-monitor='cd ~\u002FClaude-Code-Usage-Monitor && source venv\u002Fbin\u002Factivate && .\u002Fclaude_monitor.py'\n   ```\n\n\n#### Usage Best Practices\n\n1. **Monitor Burn Rate Velocity**\n   - Watch for sudden spikes in token consumption\n   - Adjust coding intensity based on remaining time\n   - Plan big refactors around session resets\n\n2. **Strategic Session Planning**\n\n```bash\n   # Plan heavy usage around reset times\n   claude-monitor --reset-hour 9\n   ```\n\n   - Schedule large tasks after resets\n   - Use lighter tasks when approaching limits\n   - Leverage multiple overlapping sessions\n\n3. **Timezone Awareness**\n\n```bash\n   # Always use your actual timezone\n   claude-monitor --timezone Europe\u002FWarsaw\n   ```\n\n   - Accurate reset time predictions\n   - Better planning for work schedules\n   - Correct session expiration estimates\n\n#### Optimization Tips\n\n1. **Terminal Setup**\n   - Use terminals with at least 80 character width\n   - Enable color support for better visual feedback (check COLORTERM environment variable)\n   - Consider dedicated terminal window for monitoring\n   - Use terminals with truecolor support for best theme experience\n\n2. **Workflow Integration**\n\n```bash\n   # Start monitoring with your development session (uv installation)\n   tmux new-session -d -s claude-monitor 'claude-monitor'\n\n   # Or development mode\n   tmux new-session -d -s claude-monitor '.\u002Fclaude_monitor.py'\n\n   # Check status anytime\n   tmux attach -t claude-monitor\n   ```\n\n\n3. **Multi-Session Strategy**\n   - Remember sessions last exactly 5 hours\n   - You can have multiple overlapping sessions\n   - Plan work across session boundaries\n\n#### Real-World Workflows\n\n**Large Project Development**\n```bash\n# Setup for sustained development\nclaude-monitor --plan max20 --reset-hour 8 --timezone America\u002FNew_York\n```\n\n\n**Daily Routine**:\n1. **8:00 AM**: Fresh tokens, start major features\n2. **10:00 AM**: Check burn rate, adjust intensity\n3. **12:00 PM**: Monitor for afternoon session planning\n4. **2:00 PM**: New session window, tackle complex problems\n5. **4:00 PM**: Light tasks, prepare for evening session\n\n**Learning & Experimentation**\n```bash\n# Flexible setup for learning\nclaude-monitor --plan pro\n```\n\n\n**Sprint Development**\n```bash\n# High-intensity development setup\nclaude-monitor --plan max20 --reset-hour 6\n```\n\n\n## 🔧 Development Installation\n\nFor contributors and developers who want to work with the source code:\n\n### Quick Start (Development\u002FTesting)\n\n```bash\n# Clone the repository\ngit clone https:\u002F\u002Fgithub.com\u002FMaciek-roboblog\u002FClaude-Code-Usage-Monitor.git\ncd Claude-Code-Usage-Monitor\n\n# Install in development mode\npip install -e .\n\n# Run from source\npython -m claude_monitor\n```\n\n\n### v3.0.0 Testing Features\n\nThe new version includes a comprehensive test suite:\n\n- **100+ test cases** with full coverage\n- **Unit tests** for all components\n- **Integration tests** for end-to-end workflows\n- **Performance tests** with benchmarking\n- **Mock objects** for isolated testing\n\n```bash\n# Run tests\ncd src\u002F\npython -m pytest\n\n# Run with coverage\npython -m pytest --cov=claude_monitor --cov-report=html\n\n# Run specific test modules\npython -m pytest tests\u002Ftest_analysis.py -v\n```\n\n\n### Prerequisites\n\n1. **Python 3.9+** installed on your system\n2. **Git** for cloning the repository\n\n\n### Virtual Environment Setup\n\n#### Why Use Virtual Environment?\n\nUsing a virtual environment is **strongly recommended** because:\n\n- **🛡️ Isolation**: Keeps your system Python clean and prevents dependency conflicts\n- **📦 Portability**: Easy to replicate the exact environment on different machines\n- **🔄 Version Control**: Lock specific versions of dependencies for stability\n- **🧹 Clean Uninstall**: Simply delete the virtual environment folder to remove everything\n- **👥 Team Collaboration**: Everyone uses the same Python and package versions\n\n#### Installing virtualenv (if needed)\n\nIf you don't have venv module available:\n\n```bash\n# Ubuntu\u002FDebian\nsudo apt-get update\nsudo apt-get install python3-venv\n\n# Fedora\u002FRHEL\u002FCentOS\nsudo dnf install python3-venv\n\n# macOS (usually comes with Python)\n# If not available, install Python via Homebrew:\nbrew install python3\n\n# Windows (usually comes with Python)\n# If not available, reinstall Python from python.org\n# Make sure to check \"Add Python to PATH\" during installation\n```\n\n\nAlternatively, use the virtualenv package:\n```bash\n# Install virtualenv via pip\npip install virtualenv\n\n# Then create virtual environment with:\nvirtualenv venv\n# instead of: python3 -m venv venv\n```\n\n\n#### Step-by-Step Setup\n\n```bash\n# 1. Clone the repository\ngit clone https:\u002F\u002Fgithub.com\u002FMaciek-roboblog\u002FClaude-Code-Usage-Monitor.git\ncd Claude-Code-Usage-Monitor\n\n# 2. Create virtual environment\npython3 -m venv venv\n# Or if using virtualenv package:\n# virtualenv venv\n\n# 3. Activate virtual environment\n# On Linux\u002FMac:\nsource venv\u002Fbin\u002Factivate\n# On Windows:\n# venv\\Scripts\\activate\n\n# 4. Install Python dependencies\npip install pytz\npip install rich>=13.0.0\n# 5. Make script executable (Linux\u002FMac only)\nchmod +x claude_monitor.py\n\n# 6. Run the monitor\npython claude_monitor.py\n```\n\n\n#### Daily Usage\n\nAfter initial setup, you only need:\n\n```bash\n# Navigate to project directory\ncd Claude-Code-Usage-Monitor\n\n# Activate virtual environment\nsource venv\u002Fbin\u002Factivate  # Linux\u002FMac\n# venv\\Scripts\\activate   # Windows\n\n# Run monitor\n.\u002Fclaude_monitor.py  # Linux\u002FMac\n# python claude_monitor.py  # Windows\n\n# When done, deactivate\ndeactivate\n```\n\n\n#### Pro Tip: Shell Alias\n\nCreate an alias for quick access:\n```bash\n# Add to ~\u002F.bashrc or ~\u002F.zshrc\nalias claude-monitor='cd ~\u002FClaude-Code-Usage-Monitor && source venv\u002Fbin\u002Factivate && .\u002Fclaude_monitor.py'\n\n# Then just run:\nclaude-monitor\n```\n\n\n## Troubleshooting\n\n### Installation Issues\n\n#### \"externally-managed-environment\" Error\n\nOn modern Linux distributions (Ubuntu 23.04+, Debian 12+, Fedora 38+), you may encounter:\n```\nerror: externally-managed-environment\n× This environment is externally managed\n```\n\n\n**Solutions (in order of preference):**\n\n1. **Use uv (Recommended)**\n\n```bash\n   # Install uv first\n   curl -LsSf https:\u002F\u002Fastral.sh\u002Fuv\u002Finstall.sh | sh\n\n   # Then install with uv\n   uv tool install claude-monitor\n   ```\n\n\n2. **Use pipx (Isolated Environment)**\n\n```bash\n   # Install pipx\n   sudo apt install pipx  # Ubuntu\u002FDebian\n   # or\n   python3 -m pip install --user pipx\n\n   # Install claude-monitor\n   pipx install claude-monitor\n   ```\n\n\n3. **Use virtual environment**\n\n```bash\n   python3 -m venv myenv\n   source myenv\u002Fbin\u002Factivate\n   pip install claude-monitor\n   ```\n\n\n4. **Force installation (Not Recommended)**\n\n```bash\n   pip install --user claude-monitor --break-system-packages\n   ```\n\n   ⚠️ **Warning**: This bypasses system protection and may cause conflicts. We strongly recommend using a virtual environment instead.\n\n#### Command Not Found After pip Install\n\nIf claude-monitor command is not found after pip installation:\n\n1. **Check if it's a PATH issue**\n\n```bash\n   # Look for the warning message during pip install:\n   # WARNING: The script claude-monitor is installed in '\u002Fhome\u002Fusername\u002F.local\u002Fbin' which is not on PATH\n   ```\n\n\n2. **Add to PATH**\n\n```bash\n   # Add this to ~\u002F.bashrc or ~\u002F.zshrc\n   echo 'export PATH=\"$HOME\u002F.local\u002Fbin:$PATH\"' >> ~\u002F.bashrc\n\n   # Reload shell\n   source ~\u002F.bashrc  # or source ~\u002F.zshrc\n   ```\n\n\n3. **Verify installation location**\n\n```bash\n   # Find where pip installed the script\n   pip show -f claude-monitor | grep claude-monitor\n   ```\n\n\n4. **Run directly with Python**\n\n```bash\n   python3 -m claude_monitor\n   ```\n\n\n#### Python Version Conflicts\n\nIf you have multiple Python versions:\n\n1. **Check Python version**\n\n```bash\n   python3 --version\n   pip3 --version\n   ```\n\n\n2. **Use specific Python version**\n\n```bash\n   python3.11 -m pip install claude-monitor\n   python3.11 -m claude_monitor\n   ```\n\n\n3. **Use uv (handles Python versions automatically)**\n\n```bash\n   uv tool install claude-monitor\n   ```\n\n\n### Runtime Issues\n\n#### No active session found\nIf you encounter the error No active session found, please follow these steps:\n\n1. **Initial Test**:\n   Launch Claude Code and send at least two messages. In some cases, the session may not initialize correctly on the first attempt, but it resolves after a few interactions.\n\n2. **Configuration Path**:\n   If the issue persists, consider specifying a custom configuration path. By default, Claude Code uses ~\u002F.config\u002Fclaude. You may need to adjust this path depending on your environment.\n\n```bash\nCLAUDE_CONFIG_DIR=~\u002F.config\u002Fclaude .\u002Fclaude_monitor.py\n```\n\n\n\n## 📞 Contact\n\nHave questions, suggestions, or want to collaborate? Feel free to reach out!\n\n**📧 Email**: [maciek@roboblog.eu](mailto:maciek@roboblog.eu)\n\nWhether you need help with setup, have feature requests, found a bug, or want to discuss potential improvements, don't hesitate to get in touch. I'm always happy to help and hear from users of the Claude Code Usage Monitor!\n\n\n## 📚 Additional Documentation\n\n- **[Development Roadmap](DEVELOPMENT.md)** - ML features, PyPI package, Docker plans\n- **[Contributing Guide](CONTRIBUTING.md)** - How to contribute, development guidelines\n- **[Troubleshooting](TROUBLESHOOTING.md)** - Common issues and solutions\n\n\n## 📝 License\n\n[MIT License](LICENSE) - feel free to use and modify as needed.\n\n## 🤝 Contributors\n\n- [@adawalli](https:\u002F\u002Fgithub.com\u002Fadawalli)\n- [@taylorwilsdon](https:\u002F\u002Fgithub.com\u002Ftaylorwilsdon)\n- [@moneroexamples](https:\u002F\u002Fgithub.com\u002Fmoneroexamples)\n\nWant to contribute? Check out our [Contributing Guide](CONTRIBUTING.md)!\n\n\n## 🙏 Acknowledgments\n\n### Sponsors\n\nA special thanks to our supporters who help keep this project going:\n\n**Ed** - *Buy Me Coffee Supporter*\n> \"I appreciate sharing your work with the world. It helps keep me on track with my day. Quality readme, and really good stuff all around!\"\n\n## Star History\n\n[![Star History Chart](https:\u002F\u002Fapi.star-history.com\u002Fsvg?repos=Maciek-roboblog\u002FClaude-Code-Usage-Monitor&type=Date)](https:\u002F\u002Fwww.star-history.com\u002F#Maciek-roboblog\u002FClaude-Code-Usage-Monitor&Date)\n\n---\n\n\u003Cdiv align=\"center\">\n\n**⭐ Star this repo if you find it useful! ⭐**\n\n[Report Bug](https:\u002F\u002Fgithub.com\u002FMaciek-roboblog\u002FClaude-Code-Usage-Monitor\u002Fissues) • [Request Feature](https:\u002F\u002Fgithub.com\u002FMaciek-roboblog\u002FClaude-Code-Usage-Monitor\u002Fissues) • [Contribute](CONTRIBUTING.md)\n\n\u003C\u002Fdiv>\n","Claude Code Usage Monitor 是一个实时监控 Claude AI 代码使用情况的终端工具，支持预测和警告功能。它利用机器学习技术提供智能预测，如 P90 百分位计算和会话限制检测，并具备高度可配置的刷新率（0.1-20 Hz）以实现实时更新。此外，该工具采用先进的 Rich UI 设计，包括美观的颜色编码进度条、表格等，符合 WCAG 对比度标准。自动检测用户计划并根据自定义限制进行调整是其另一大亮点。适用于需要密切跟踪 Claude AI 服务使用量及成本分析的各种开发场景，帮助开发者更好地管理资源消耗与预算控制。",2,"2026-06-11 03:39:53","high_star"]