Advanced context monitoring and management for Claude Code
Project description
Claude Code Context Monitor
🚀 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
⚡ Quick Install
One-Line Install
curl -fsSL https://raw.githubusercontent.com/XiaoConstantine/claude-context-monitor/main/install.sh | bash
Manual Install
git clone https://github.com/XiaoConstantine/claude-context-monitor.git
cd claude-context-monitor
./install.sh
🎯 Usage
Once installed, the system works automatically in all Claude Code projects:
Global Commands
/handoff # Generate handoff document
/handoff --force # Force generation
Configuration
# Switch status modes globally
claude-context-config detailed # 💻 user:project │ 🔵 16.3% (98K) │ 🌿main ± │ 🎯MAX
claude-context-config compact # 📁project │ 🔵16% │ 🌿±main │ 🎯M
claude-context-config simple # 🔵 16.3% (98K/600K) [MAX] LOW
# Check current settings
claude-context-config info
# 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.
{
"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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file claude_context_monitor-1.0.0.tar.gz.
File metadata
- Download URL: claude_context_monitor-1.0.0.tar.gz
- Upload date:
- Size: 29.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2beb24b05aed28d415f855bfcca17894efc9a45fc6dea2af2fbd05ef461c7247
|
|
| MD5 |
44c049a357cc73d2157b9191b8180c7e
|
|
| BLAKE2b-256 |
be33733dff6740ea747d73318421040ee8562df2b45126eac15b6728b493d2db
|
File details
Details for the file claude_context_monitor-1.0.0-py3-none-any.whl.
File metadata
- Download URL: claude_context_monitor-1.0.0-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bff7e2ca9c0772b05ba905250502802772fefa5d858f731d72f8f0d1cf5a8f19
|
|
| MD5 |
ab9f5e5efa755c25a2f7805bac8a6110
|
|
| BLAKE2b-256 |
2593da9b64ac8820322b6bf3b73ef1d4cff2966dede7246124c5bdea26fb9729
|