Claude Code Enhanced Statusline
October 1, 2025 ยท View on GitHub
Enhanced statusline for Claude Code that provides accurate token usage, costs, burn rate metrics, and optional codeindex integration. Compatible with all Claude Code versions including v1.0.92+.
โจ Features
- ๐ Accurate token usage percentage - Real-time usage against block limits
- ๐ฐ Complete cost tracking - Session, daily, and block costs
- ๐ฅ Token burn rate - Displayed in tokens/min with smart K/M/B formatting
- โฑ๏ธ Time remaining - Precise time left in current billing block
- ๐ฏ Session detection - Automatic detection of current project session
- ๐ Codeindex integration (optional) - Show active codebase indexing status
- โ ๏ธ Context limit warnings - Visual indicator when exceeding 200k tokens
- ๐ค Multiple model display - Shows comma-separated model names when using multiple models
๐ Version Compatibility
This project provides two statusline scripts for different Claude Code versions:
| Claude Code Version | Script | Features |
|---|---|---|
| v1.0.92+ (Latest) | claude-statusline-v1092.py | โ
Full v1.0.92+ JSON support โ Context limit warnings โ Enhanced error handling โ Multiple model display โ All cost tracking features |
| v1.0.88 and earlier | claude-statusline.py | โ
Legacy JSON support โ Basic cost tracking โ Codeindex integration โ No context warnings |
The installer automatically selects the correct script for your Claude Code version. For v1.0.92+, it uses the enhanced v1092 script.
๐ Prerequisites
Install ccusage
Using Homebrew:
brew install ccusage
Or using npm:
npm install -g ccusage
Requirements
- Python 3
- Claude Code
- curl (for optional codeindex integration)
Optional Dependencies
- claude-codeindex - For codebase indexing status display
- If installed and running, shows active indexing status
- Gracefully falls back if unavailable
- No configuration needed - auto-detected
๐ Quick Install
Option 1: Standard Installation (Recommended)
# Clone the repository
git clone https://github.com/WKassebaum/claude-statusline.git
cd claude-statusline
# Run the installer
./install.sh
Option 2: Binary Installation
Installs to ~/.local/bin for system-wide access:
# Clone the repository
git clone https://github.com/WKassebaum/claude-statusline.git
cd claude-statusline
# Run the binary installer
./install-bin.sh
The statusline will automatically update in Claude Code.
๐ Statusline Format
Standard format:
๐ค Opus 4.1 | ๐ฐ \$3.25 session / \$81.14 today / \$77.30 block (1h 14m left) | ๐ฅ 204K/min | 39.5M tokens | 40.4% used | ~1h14m left
With multiple models (v1.0.92+):
๐ค Opus 4.1, Sonnet 4 | ๐ฐ \$99.52 session / \$52.95 today / \$78.06 block (1h 40m left) | ๐ฅ 482K/min | 96.5M tokens | 98.8% used | ~1h40m left
With context limit warning (v1.0.92+):
๐ค Opus 4.1 โ ๏ธ Context limit | ๐ฐ \$3.25 session / \$81.14 today / \$77.30 block (1h 14m left) | ๐ฅ 204K/min | 39.5M tokens | 40.4% used | ~1h14m left
With codeindex integration (when available):
๐ค Opus 4.1 | ๐ โ
claude-codeindex | ๐ฐ \$3.25 session / \$81.14 today / \$77.30 block (1h 14m left) | ๐ฅ 204K/min | 39.5M tokens | 40.4% used | ~1h14m left
During active indexing:
๐ค Opus 4.1 | ๐ ๐ (42%) my-project | ๐ฐ \$3.25 session / \$81.14 today ...
What Each Field Shows
- Model: Currently active Claude model (Opus 4.1)
- Codeindex (optional): Current project indexing status
๐ โ project-name- Project is fully indexed๐ โ project-name- Project not indexed๐ ๐ (42%) project-name- Currently indexing (42% complete)๐ โ service down- Service unavailable- (not shown) - codeindex not installed (graceful fallback)
- Session cost: Total cost for current working directory session
- Today's cost: Total usage for today across all sessions
- Block cost: Current 5-hour block usage and time remaining
- Burn rate: Token consumption rate in tokens per minute
- Token count: Current block tokens (matches ccusage display)
- Usage %: Percentage of 97.6M token block limit used
- Time left: Estimated time remaining based on burn rate
Components:
- Model: Current Claude model
- Costs: Session, daily, and current block costs
- Burn rate: Token consumption rate per minute
- Tokens: Total session tokens
- Usage: Percentage of block limit consumed
- Time: Estimated time remaining
๐ ๏ธ Manual Installation
For Claude Code v1.0.92+ (Recommended)
-
Copy the v1092 statusline script:
cp claude-statusline-v1092.py ~/.claude/claude-statusline.py chmod +x ~/.claude/claude-statusline.py -
Update
~/.claude/settings.json:{ "statusLine": { "type": "command", "command": "python3 /Users/YOUR_USERNAME/.claude/claude-statusline.py" } }
For Claude Code v1.0.88 and Earlier
-
Copy the legacy statusline script:
cp claude-statusline.py ~/.claude/claude-statusline.py chmod +x ~/.claude/claude-statusline.py -
Update
~/.claude/settings.json(same as above)
Note: The automatic installer detects your Claude Code version and selects the appropriate script. Manual installation is only needed for custom setups.
๐งช Testing
Test the statusline output:
echo '{}' | python3 ~/.claude/claude-statusline.py
Testing Codeindex Integration
If you have claude-codeindex installed, you can test the integration:
# Check if codeindex service is running
curl -s http://localhost:3847/health
# Start codeindex in a project directory
/codeindex:start
# You should see the codeindex status in your statusline:
# ๐ค Opus 4.1 | ๐ โyour-project-name | ๐ฐ ...
๐ Codeindex Integration
The statusline automatically detects and displays codeindex status when available.
Status Indicators
| Indicator | Meaning | Description |
|---|---|---|
๐ โ
project-name | Indexed | Project is fully indexed and ready |
๐ โ project-name | Not Indexed | Project not in the index |
๐ ๐ (23%) project-name | Indexing | Currently indexing, 23% complete |
๐ ๐ (89%) project-name | Almost Done | Indexing nearly complete |
๐ โ service down | Service Error | codeindex-service not running |
| (not shown) | Not Installed | codeindex not available (graceful fallback) |
Benefits
- Current project awareness - Shows status of your working directory
- Real-time progress - Live percentage updates during indexing
- Instant feedback - Know if your project is indexed at a glance
- Zero configuration - Works automatically when codeindex available
- Graceful degradation - No impact when codeindex unavailable
How Progress Tracking Works
The statusline monitors codeindex logs for active indexing operations:
- Detects
๐ Insertingmessages in recent logs - Calculates progress based on insertion activity over time
- Updates percentage in real-time as indexing proceeds
- Shows
โwhen complete orโif not indexed
๐๏ธ Uninstall
./uninstall.sh
๐ Technical Details
How It Works
Both scripts follow the same core process:
- Query
ccusagefor session, daily, and block metrics - Parse JSON output and calculate accurate percentages
- Format output optimized for terminal display
- Return formatted statusline to Claude Code
Version-Specific Differences
claude-statusline-v1092.py (v1.0.92+):
- Enhanced JSON input parsing for new Claude Code format
- Supports
workspace.current_dirandcost.total_cost_usdfields - Detects
exceeds_200k_tokensfor context limit warnings - Improved block detection logic (active blocks + recent non-gap blocks)
- Longer ccusage timeouts (10s vs 3s) to prevent command failures
- Enhanced model detection with
display_namefield support - Robust error handling with graceful fallbacks
claude-statusline.py (Legacy):
- Original JSON input format support
- Basic cost tracking and codeindex integration
- Shorter timeouts suitable for older ccusage versions
- Simpler error handling
Cost Tracking Algorithm
The statusline uses a sophisticated cost tracking system:
- Session costs: Matches current directory to ccusage session data
- Daily costs: Aggregates today's usage across all sessions
- Block costs: Uses most recent active or non-gap block
- Time estimates: Based on current burn rate and remaining block limit
๐ Troubleshooting
Statusline shows "Status unavailable"
- Verify
ccusageis installed:which ccusage - Check Python 3:
which python3 - Test manually with the command above
Session shows N/A
- Script detects sessions based on current working directory
- Ensure you're in an active project directory
Codeindex status not showing
- Check if codeindex service is running:
curl -s http://localhost:3847/health - This is normal - codeindex integration is optional
- Statusline works perfectly without codeindex
Codeindex shows "โ project-name" but I started indexing
- Check service status:
curl -s http://localhost:3847/status - Verify collections exist:
curl -s http://localhost:6333/collections - Large projects may take time - check progress with
codeindex projects
Codeindex shows percentage stuck at same value
- Normal for large projects - indexing pauses between file batches
- Check activity:
curl -s http://localhost:3847/logs - Progress updates when new files are inserted
Cost tracking shows $0.00 for all values
- You may be using the wrong script for your Claude Code version
- For v1.0.92+, use
claude-statusline-v1092.py - For v1.0.88 and earlier, use
claude-statusline.py - ccusage commands may be timing out - the v1092 script has longer timeouts
- Run the installer again to auto-detect your version
Context warning not showing (v1.0.92+)
- Ensure you're using
claude-statusline-v1092.py - Context warnings only appear when exceeding 200k tokens
- Feature is only available in Claude Code v1.0.88+
Multiple models not displaying correctly
- Ensure you're using
claude-statusline-v1092.pyfor v1.0.92+ - Legacy script may not properly handle multiple models
- Models should appear comma-separated: "Opus 4.1, Sonnet 4"
๐ License
MIT License - See LICENSE file
๐ค Contributing
Pull requests welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
๐ง Support
For issues, please include:
- Claude Code version
- Output of
ccusage --version - Error messages
- Manual test output