Claude Context Monitor
Advanced context monitoring and adaptive threshold learning for Claude Code
🚀 Features
- Real-time status line showing context usage in all projects
- Intelligent plan detection using P90 analysis - no manual configuration needed!
- Automatic handoff generation when approaching context limits
- Claude Max/Pro support with appropriate token limits
- Global
/handoffcommand available everywhere - Git integration showing branch and status
- Zero configuration for new projects
📺 Demo
Your Claude Code status line will show:
💻 user:project │ 🔵 16.3% (98K) │ 🌿main ± │ 🎯MAX
⚡ Installation
🚀 Recommended: UV + UVX (Modern Python)
# Install with uvx (no global installation needed)
uvx claude-context-monitor status
# Or install globally
uv tool install claude-context-monitor
# Use commands anywhere
claude-context status
ccm handoff --record
📦 Traditional pip
pip install claude-context-monitor
claude-context install
🔧 Legacy Shell Install
curl -fsSL https://raw.githubusercontent.com/XiaoConstantine/claude-context-monitor/main/install.sh | bash
Development Install
git clone https://github.com/XiaoConstantine/claude-context-monitor.git
cd claude-context-monitor
./install.sh
🎯 Usage
CLI Commands
# Status monitoring
claude-context status # Current context status
claude-context status -f json # JSON output
ccm status -f compact # Compact format (short alias)
# Plan detection
claude-context plan # Detect Claude plan automatically
claude-context plan --json # JSON output
# Handoff tracking & adaptive learning
claude-context handoff --record # Record handoff for threshold learning
claude-context handoff --stats # Show historical handoff statistics
claude-context handoff --summary # Get summary for documents
# Configuration
claude-context config --show # Show current config
claude-context config --set CLAUDE_PLAN=max # Set values
claude-context config --get CONTEXT_THRESHOLD
# Installation (legacy compatibility)
claude-context install # Install to ~/.claude
claude-context install --force # Force reinstall
Global Claude Commands
/handoff # Generate handoff document (auto-records context %)
/handoff --force # Force generation
Automatic Features
- Real-time status: Shows in Claude Code status line
- Adaptive thresholds: Learns from your handoff patterns
- Plan detection: Automatically detects Pro/Max plans
- Git integration: Shows branch and dirty status
Manual plan override (optional - auto-detection is recommended)
export CLAUDE_PLAN=max # Force Claude Max (600K tokens) export CLAUDE_PLAN=pro # Force Claude Pro (200K tokens)
Leave unset for intelligent auto-detection
## 🧠 Intelligent Plan Detection
The monitor automatically detects your Claude plan using **P90 analysis** of your usage history:
- **Analyzes** your last 8 days of token usage patterns
- **Calculates** 90th percentile usage from recent sessions
- **Detects** if you're on Pro (200K) or Max (600K) plan with 85% confidence
- **Falls back** to conservative Pro limits if insufficient data
No manual configuration needed! The system learns from your actual usage patterns.
```json
{
"detected_plan": "max",
"confidence": 0.85,
"method": "p90_analysis",
"p90_limit": 160000,
"token_limit": 600000,
"sessions_analyzed": 8
}
🔧 How It Works
- Real-time monitoring: Reads token usage from Claude Code's session files (
~/.claude/projects/) - Intelligent detection: Uses P90 analysis to automatically detect your Claude plan
- Smart limits: Adjusts thresholds for Claude Max (600K) vs Pro (200K) tokens
- Auto-handoff: Generates detailed handoff documents at 90% usage
- Git integration: Shows current branch and dirty status
📊 Status Indicators
Context Usage Colors
- 🔵 Low (0-49%): Plenty of context remaining
- 🟢 OK (50-74%): Context usage moderate
- 🟡 High (75-89%): Approaching context limit
- 🔴 Critical (90%+): Handoff generation triggered
Git Status
- 📁 Clean: No uncommitted changes
- ⚡ Dirty: Uncommitted changes present
📋 Requirements
- Claude Code: Latest version with statusLine support
- Python 3.8+: For status monitoring scripts
- jq: For JSON configuration management
- Git: For project status detection (optional)
📖 Documentation
🤝 Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
📄 License
MIT License - see LICENSE file for details.
🙏 Acknowledgments
- Built for the Claude Code community
- Inspired by the need for better context management in AI-assisted development
- P90 analysis approach inspired by Maciek's Claude Code Usage Monitor
Metadata
Release files for claude-context-monitor 1.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| claude_context_monitor-1.4.2.tar.gz | 25.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| claude_context_monitor-1.4.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 50.7 kB
Release files / claude_context_monitor-1.4.2.tar.gz
| Download URL | claude_context_monitor-1.4.2.tar.gz |
|---|---|
| Size | 25.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
981d17007beaf9748a6366faef1139461f408da1f35e3246be34ff9a48f624c6
|
|
BLAKE2b-256 checksum How to use checksums |
1b47c119fe23d53d236953ee682b913a1fb396bf6d0b61b70f073aa141ae501f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.3
|
Release files / claude_context_monitor-1.4.2-py3-none-any.whl
| Download URL | claude_context_monitor-1.4.2-py3-none-any.whl |
|---|---|
| Size | 25.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c36601d25cc01cda461fe1cdfe92d2082fc2873b4162850bb116f86b4f17470d
|
|
BLAKE2b-256 checksum How to use checksums |
8e93ae55b50d53c7303f40981261336f96880f44cfe49e59daefb7de4e9af928
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.3
|