Skip to content

xixifast/claude-xbar-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Usage Monitor for xbar

A beautiful macOS menu bar plugin that tracks your Claude API usage and costs in real-time.

image

Real-time Claude API cost tracking with detailed breakdowns by model, project, and daily usage

Features

🤖 Real-time Cost Tracking

  • See today's Claude API costs at a glance in the menu bar
  • Clean display showing only what matters most: today's spending

📊 Detailed Analytics

  • Today's Usage - Track daily spending, sessions, and tokens
  • Model Breakdown - Visualize costs by model with progress bars
  • Project Analytics - Top 5 projects by cost
  • Token Statistics - Detailed breakdown of all token types

🎨 Beautiful Interface

  • Clean, professional design optimized for macOS
  • Visual progress bars and tree structures
  • Supports both light and dark mode
  • Icons and emojis for better readability

⚡ Performance

  • Auto-refreshes every 10 seconds (configurable)
  • Efficient JSONL parsing
  • Memory-conscious for large datasets

Installation

Prerequisites

  • macOS (10.12 or later)
  • xbar - Install via Homebrew: brew install --cask xbar
  • Python 3 (included with macOS)
  • Claude API usage data in ~/.claude/projects/

Quick Install

  1. Install xbar (if not already installed):

    brew install --cask xbar
  2. Install the plugin:

    # Download and install in one command
    curl -sSL https://raw.githubusercontent.com/xixifast/claude-xbar-plugin/main/install.sh | bash

Manual Install

  1. Download claude-usage.10s.py from this repository
  2. Copy to xbar plugins directory:
    cp claude-usage.10s.py ~/Library/Application\ Support/xbar/plugins/
    chmod +x ~/Library/Application\ Support/xbar/plugins/claude-usage.10s.py
  3. Refresh xbar or restart the app

Configuration

Refresh Interval

The plugin refreshes every 10 seconds by default. To change this, rename the file:

  • claude-usage.5s.py - Refresh every 5 seconds
  • claude-usage.30s.py - Refresh every 30 seconds
  • claude-usage.1m.py - Refresh every minute
  • claude-usage.5m.py - Refresh every 5 minutes

Model Pricing

To update model pricing, edit the MODEL_PRICING dictionary in the script:

MODEL_PRICING = {
    "opus-4": {
        "name": "Opus 4",
        "input_per_million": 15.0,
        "output_per_million": 75.0,
        "cache_write_per_million": 18.75,
        "cache_read_per_million": 1.50
    },
    # Add more models here...
}

What It Shows

The plugin displays:

  • Menu Bar: Today's cost

    • Format: 🤖 $125.80
  • Dropdown Menu:

    • 💰 Overview: Total cost, sessions, and average cost per session
    • 📅 Today: Today's cost, sessions, and token usage
    • 🔤 Token Usage: Detailed breakdown with tree structure
    • 🎯 By Model: Cost distribution with visual progress bars
    • 📁 Top Projects: Top 5 projects by cost
    • 🔧 Actions: Refresh and quick access to Claude projects

Troubleshooting

No data showing?

  1. Check if ~/.claude/projects/ exists and contains .jsonl files
  2. Ensure the plugin has read permissions
  3. Check Console.app for any Python errors

Incorrect costs?

The plugin uses Claude's official pricing. If you see discrepancies:

  1. Check if your model names match the configured patterns
  2. Verify the pricing in MODEL_PRICING matches current rates

Performance issues?

For large usage histories, consider:

  1. Increasing the refresh interval (e.g., claude-usage.1m.py)
  2. Cleaning old .jsonl files from ~/.claude/projects/

Development

Project Structure

claude-xbar-plugin/
├── README.md
├── LICENSE
├── claude-usage.10s.py    # Main plugin script
├── install.sh             # Installation script
├── assets/                # Screenshots and images
└── examples/             # Example configurations

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Testing

Test the plugin locally:

python3 claude-usage.10s.py

License

MIT License - see LICENSE file for details

Acknowledgments

  • Built for xbar (formerly BitBar)
  • Inspired by the Claude AI community
  • Icons from Apple's SF Symbols

Support


Made with ❤️ for Claude users everywhere

About

Beautiful macOS menu bar plugin for tracking Claude API usage and costs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published