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 VersionScriptFeatures
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 earlierclaude-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

# 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

  1. Copy the v1092 statusline script:

    cp claude-statusline-v1092.py ~/.claude/claude-statusline.py
    chmod +x ~/.claude/claude-statusline.py
    
  2. Update ~/.claude/settings.json:

    {
      "statusLine": {
        "type": "command",
        "command": "python3 /Users/YOUR_USERNAME/.claude/claude-statusline.py"
      }
    }
    

For Claude Code v1.0.88 and Earlier

  1. Copy the legacy statusline script:

    cp claude-statusline.py ~/.claude/claude-statusline.py
    chmod +x ~/.claude/claude-statusline.py
    
  2. 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

IndicatorMeaningDescription
๐Ÿ” โœ… project-nameIndexedProject is fully indexed and ready
๐Ÿ” โŒ project-nameNot IndexedProject not in the index
๐Ÿ” ๐Ÿ”„ (23%) project-nameIndexingCurrently indexing, 23% complete
๐Ÿ” ๐Ÿ”„ (89%) project-nameAlmost DoneIndexing nearly complete
๐Ÿ” โŒ service downService Errorcodeindex-service not running
(not shown)Not Installedcodeindex 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:

  1. Detects ๐Ÿ“ Inserting messages in recent logs
  2. Calculates progress based on insertion activity over time
  3. Updates percentage in real-time as indexing proceeds
  4. Shows โœ… when complete or โŒ if not indexed

๐Ÿ—‘๏ธ Uninstall

./uninstall.sh

๐Ÿ“ Technical Details

How It Works

Both scripts follow the same core process:

  1. Query ccusage for session, daily, and block metrics
  2. Parse JSON output and calculate accurate percentages
  3. Format output optimized for terminal display
  4. 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_dir and cost.total_cost_usd fields
  • Detects exceeds_200k_tokens for 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_name field 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:

  1. Session costs: Matches current directory to ccusage session data
  2. Daily costs: Aggregates today's usage across all sessions
  3. Block costs: Uses most recent active or non-gap block
  4. Time estimates: Based on current burn rate and remaining block limit

๐Ÿž Troubleshooting

Statusline shows "Status unavailable"

  • Verify ccusage is 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.py for 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:

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

๐Ÿ“ง Support

For issues, please include:

  • Claude Code version
  • Output of ccusage --version
  • Error messages
  • Manual test output