Sandbox
@bozdemir/claude-usage-widget

Claude Code usage widget and CLI

Claude Usage Widget shows your Claude Code limits in a transparent always-on-top overlay, with a popup for deeper usage, cost, forecast, and history views. It reads Claude Code’s usage data directly, can also poll local Codex usage if you opt in, and keeps its state in `config.json`.

49 stars16 forksPythonUpdated 1mo ago
Who it's for

Builders who use Claude Code and want live usage, cost, and limit tracking on their desktop.

What it delivers

You can keep track of session and weekly usage without opening Claude Code or re-checking limits by hand.

What it does

Live usage overlay

Shows session and weekly Claude Code utilization in an always-on-top desktop widget.

Optional Codex tracking

Adds Codex 5h and weekly usage rows when you enable the `codex` provider.

Cost and forecast views

Shows per-turn cost, model cost breakdowns, burn-rate forecasts, and projected spend.

Alerts and notifications

Sends threshold, burn, anomaly, and budget notifications with optional webhooks.

Theme and layout switching

Includes 11 themes and two OSD view modes that persist in config.

CLI and local API

Provides `--json`, `--once`, `--export`, `--statusline`, and a localhost `/usage` API for scripts and status bars.

How to get it

  1. 1Run
    pip install --user --upgrade claude-usage-widget
    claude-usage              # launches the OSD overlay (foreground)
    claude-usage --detach     # …or run it in the background and free the shell (Linux/macOS; on Windows use Start-Process or pythonw)
    claude-usage --version    # 0.12.5
  2. 2Run
    systemctl --user enable --now claude-usage
  3. 3If you prefer brew over pip
    brew tap bozdemir/tap
    brew install claude-usage-widget
  4. 4Run
    git clone https://github.com/bozdemir/claude-usage-widget.git
    cd claude-usage-widget
    pip install -e .
    python3 main.py

README

Claude Usage Widget

A cross-platform desktop widget that displays your Claude Code usage limits in real time. Always-on-top OSD overlay showing session and weekly utilization — built with PySide6 (Qt), so a single pip install works on Linux, macOS, and Windows.

PyPI Tests Platform Python License

Screenshots

OSD overlay
Always-on-top OSD: session + weekly utilisation, reset timers, live token-per-minute badge, subagent counter, and a scrolling per-turn cost ticker along the bottom.

Detail popup with usage bars, heatmaps, cost breakdown, and the AI-generated weekly report
Click the OSD to open the detail popup: forecasts, 5h/7d sparklines, 90-day heatmap, 52-week GitHub-style calendar, per-model cost breakdown with Anthropic-published rates, top projects, tips, and a Claude-authored weekly summary.

OSD view modes

Two layouts, switch with right-click → OSD View ▸. Selection persists to ~/.config/claude-usage/config.json so a restart keeps it.

Bars — default, includes the scrolling tickerGauge — circular rings, car-dashboard vibe
bars viewgauge view

Themes

11 built-in palettes — 5 classics + 6 Claude-designed skins. Right-click the OSD → Theme ▸ to switch instantly; the choice persists to ~/.config/claude-usage/config.json.

Classics (dark):

defaultcatppuccin-mochadracula
defaultcatppuccin-mochadracula
nordgruvbox-dark
nordgruvbox-dark

Claude-designed skins:

terminal
htop vibe, green-on-black
dashboard
Bloomberg-terminal cool blue
hud
car-dashboard amber
terminaldashboardhud
receipt (light)
thermal-paper cream + red
strip
cool mint on mono-gray
brutalist (light)
white, heavy rules, crimson
receiptstripbrutalist

Gauge variants for every theme are available at screenshots/osd-gauge-<theme>.png.

Features

  • Single pip install -- no apt/brew/system libraries required, Qt is bundled
  • Real API data -- 5h / 7d plan utilisation read from Claude Code's /api/oauth/usage endpoint (the same data the Claude UI shows)
  • Model-scoped weekly bar -- when Anthropic reports a separate weekly cap for a specific model (e.g. Fable), a third bar appears automatically below Session and Weekly, labelled with the model name. It auto-hides when the API stops reporting it — works in bars, gauge, all 11 themes, and the detail popup.
  • Second provider (opt-in) -- also track your local OpenAI Codex usage alongside Claude's: add "codex" to the providers config and the widget shows Codex 5h/weekly rows beneath Claude's (extra bars in bars view, a 2×2 ring grid in gauge), rendered natively in all 11 themes. Auto-hides when the Codex CLI is missing or logged out; off by default. See Second provider: OpenAI Codex.
  • OSD overlay -- transparent, frameless; left-click opens the details popup, right-click shows a context menu. Stays on top by default — toggle it off to use it as a background desktop widget.
  • Live token stream -- ● LIVE 5.3k tok/min badge on the OSD while a Claude Code session is actively writing, derived from the conversation JSONLs
  • Per-turn cost ticker -- a scrolling strip at the bottom of the OSD shows the USD cost of each assistant turn as it lands ($0.156 ← Bash · 116), colour-coded by quartile within the visible window so the tape always stays visually varied. Toggle via right-click → "Show cost ticker" or set "show_ticker": false in config.json.
  • Live news ticker (opt-in) -- a second scrolling strip shows the latest Anthropic/Claude headlines sourced from Hacker News (top stories with 50+ upvotes). Fetched lazily, cached locally for 1 hour. Click the strip to open the article in your browser. Off by default because it makes outbound calls to a 3rd-party feed; enable via right-click → "Show news ticker" or set "show_news": true in config.json.
  • Subagent badge -- when you spawn parallel subagents via the Task tool, the CLAUDE title gets a ⚙ N counter next to it showing how many are currently writing. Hidden when zero so single-session use isn't cluttered.
  • Detail popup -- usage bars, forecast, 5h/7d sparklines, 90-day heatmap, 52-week GitHub-style calendar, per-model cost breakdown, top projects, active sessions (resizable)
  • Auto-refresh -- every 60 seconds by default; the interval adapts automatically, backing off up to 300 s when the endpoint rate-limits and snapping back on the next clean refresh (refresh_seconds / refresh_max_seconds)
  • Positioning -- snap the OSD to any screen corner via right-click → "OSD Position", or drag it anywhere; the spot is remembered (osd_position, osd_x/osd_y)
  • Resizable -- scroll wheel on the OSD (0.6x -- 4.0x); drag the popup window edges to widen it
  • Draggable -- left-click drag on the OSD
  • Cost estimation -- USD equivalent per model, cache savings, pay-as-you-go comparison for flat-fee subscribers
  • Usage forecasting -- burn-rate prediction: "At current rate: 2h 30m to limit"
  • Per-project breakdown -- top 5 projects by token usage today
  • Prompt-cache opportunities -- scans recent sessions for repeated prompt prefixes and suggests cache_control changes with a concrete $ savings estimate
  • AI-generated weekly report -- Claude Haiku writes a 3-4 sentence summary of your past week of usage (cached 1h; never leaks prompt text)
  • Anomaly detection -- flags days whose utilisation exceeds the 7/90-day baseline
  • Cost optimisation tips -- suggests cache-hit-rate improvements and model-mix changes
  • Real-time burn/spike alerts -- a bright OSD badge (▲42% / ▲SPIKE / ▲STORM) plus a debounced, once-per-episode notification when your 5-hour window burns abnormally fast or a single turn / retry-loop spikes tokens. The badge renders on the 5 classic themes for now; notifications and the burn_alert webhook fire on all 11
  • Peak-window awareness -- an unobtrusive popup hint during Anthropic's weekday reduced-limit window (default ~5–11 AM Pacific; fully configurable)
  • Monthly budget -- optional spend cap: set monthly_budget_usd to see month-to-date + projected end-of-month spend in the popup and get a once-per-month heads-up when you're on track to exceed it
  • Themes -- 11 in all: 5 classic palettes (default, catppuccin-mocha, dracula, nord, gruvbox-dark) plus 6 designed skins (terminal, dashboard, hud, receipt, strip, brutalist)
  • Threshold notifications -- native desktop notifications on crossing 75% / 90%
  • Webhooks -- optional POST to Slack / Discord / custom URLs on threshold, daily-report, anomaly, budget-projection, or burn-alert events
  • Localhost JSON API -- optional http://127.0.0.1:8765/usage for tmux / polybar / waybar integrations (prompt previews redacted at the serialization boundary)
  • CLI mode -- --json, --once, --field, --export csv|json (with --days N, default 30) for scripts and status bars, plus --statusline for Claude Code's built-in statusLine
  • Update notifications -- a daily background check against the GitHub Releases API; when a newer version is published you get one desktop notification and a banner in the right-click menu (notified once per version, never nagging). The running build's version is also shown at the foot of the menu.
  • Single-instance guard -- a second claude-usage launch (login item, script, double-click) detects the running one via a per-user lock file and exits cleanly instead of stacking a duplicate OSD; a lock left behind by a crashed instance is reclaimed automatically.

Requirements

  • Python 3.10+
  • Claude Code CLI installed and authenticated (OAuth) — the widget reads the same token, checking the CLAUDE_CODE_OAUTH_TOKEN environment variable first, then ~/.claude/.credentials.json, then the macOS Keychain

Installation

Any platform (pip — recommended)

pip install --user --upgrade claude-usage-widget
claude-usage              # launches the OSD overlay (foreground)
claude-usage --detach     # …or run it in the background and free the shell (Linux/macOS; on Windows use Start-Process or pythonw)
claude-usage --version    # 0.12.5

That's it — no apt, no brew, no PyGObject, no rumps. pip pulls in just two pure-Python wheels (PySide6-Essentials, which ships Qt, and certifi for HTTPS), so the widget is self-contained with zero system libraries.

Autostart on login (desktop entry or systemd user service)

Add claude-usage --detach to your desktop environment's autostart (KDE/GNOME: Autostart settings — make sure the entry points at the venv/pip path that actually has the widget installed), or use a systemd user service:

# ~/.config/systemd/user/claude-usage.service
[Unit]
Description=Claude Usage Widget
After=graphical-session.target

[Service]
ExecStart=%h/.local/bin/claude-usage
Restart=on-failure

[Install]
WantedBy=graphical-session.target
systemctl --user enable --now claude-usage

The single-instance guard makes double-starts harmless — a second launch just exits.

macOS (Homebrew — optional)

If you prefer brew over pip:

brew tap bozdemir/tap
brew install claude-usage-widget

From source

git clone https://github.com/bozdemir/claude-usage-widget.git
cd claude-usage-widget
pip install -e .
python3 main.py

Usage

OSD overlay controls

ActionEffect
Left-clickOpen the details popup
Left-click dragMove the OSD
Right-clickOpen context menu (Details, Refresh, OSD Opacity, OSD View, OSD Position, Theme, Minimize/Restore, Show cost ticker, Show news ticker, Always on top, version, Quit)
Scroll up / downResize (0.6x -- 4.0x)

Context menu (right-click OSD)

  • (usage summary) -- a dim, non-clickable header at the top showing your live session/weekly % (with the live token-per-minute rate while a session is writing)
  • Details… -- open the detail popup
  • Refresh -- force an immediate data refresh
  • OSD Opacity -- 100% / 75% / 50% / 25%
  • OSD View ▸ -- switch between Bars (default — progress bars + cost ticker) and Gauge (two circular rings); auto-persisted
  • OSD Position ▸ -- snap the overlay to Top Left / Top Right / Bottom Left / Bottom Right, or drag it anywhere for a remembered Custom position; auto-persisted
  • Theme ▸ -- pick one of the 11 themes (5 classic palettes plus 6 skins: terminal, dashboard, hud, receipt, strip, brutalist); the choice persists to ~/.config/claude-usage/config.json so a restart keeps it
  • Minimize / Restore -- collapse the OSD to a thin progress strip
  • Show cost ticker -- toggle the scrolling per-turn cost strip on the OSD
  • Show news ticker -- toggle the Anthropic/Claude news headline strip on the OSD
  • Always on top -- keep the OSD pinned above other windows (default), or turn it off to let it sit as a normal background desktop widget the window manager stacks behind your focused windows; persisted
  • claude-usage v<version> -- a dim, disabled line showing the running build's version; when a newer release is published an ↑ Update available: <tag> banner appears at the top of the menu, under the usage summary (click to copy the pip install --upgrade command)
  • Updated <time> ago -- a dim, non-clickable line showing how long since the last successful refresh
  • Quit -- exit the widget

Statusline-fed rate limits

If your Claude Code statusLine command dumps its rate-limit payload to a JSON file, the widget can use it as a zero-cost data source — Claude Code rewrites the statusline continuously during an active session, so the file carries the same numbers as /api/oauth/usage at seconds freshness and no API spend. Point statusline_cache_path at a file shaped like:

{
  "captured_at": "2026-07-11T22:52:05+09:00",
  "rate_limits": {
    "five_hour": {"used_percentage": 54, "resets_at": 1783795800},
    "seven_day": {"used_percentage": 46, "resets_at": 1784026800}
  }
}

With this configured the widget uses it two ways:

  • Endpoint relief — while the dump is younger than 2 × refresh_seconds, the /api/oauth/usage call is skipped and only forced through at most once per usage_endpoint_min_seconds. The endpoint is a low-budget resource shared with Claude Code itself; the forced calls keep the model-scoped/overage fields fresh and pick up consumption from headless claude -p runs, which never render a statusline.
  • Rate-limit fallback — when the endpoint throttles us, a dump younger than 20 minutes beats the last on-disk sample, which can lag a whole rate-limit window behind.

Producing the file is up to your statusline script (it receives the payload from Claude Code on stdin and can tee the relevant part out). Expired windows in a stale dump are clamped to zero, and a missing/garbled file just disables the feature for that refresh.

Second provider: OpenAI Codex (opt-in)

Run OpenAI Codex alongside Claude Code? The widget can show its usage too, right beneath Claude's — no separate menu-bar app. Add "codex" to providers in config.json:

{
    "providers": ["claude", "codex"]
}

OSD showing Codex 5h and 7d rows beneath Claude's Session, Weekly and Fable rows

You get two extra rows in bars view — Codex 5h and Codex 7d — or a second pair of rings (a 2×2 grid) in gauge view, styled to match whichever of the 11 themes you're on.

  • Data source — the widget speaks JSON-RPC over stdio to your local codex app-server (account/rateLimits/read) — the same numbers codex reports itself. No scraping, no account data stored or logged.
  • Cheap — the RPC is spawned at most once per codex_poll_seconds (default 300 s), with an on-disk cache served in between; the read is hard-bounded so a stalled codex can never hang a refresh.
  • Graceful — the Codex rows auto-hide when the codex CLI is missing, logged out, or returns no rate-limit data. POSIX-only for now (Linux/macOS).

The default providers is ["claude"], so existing users see no change.

Configuration

All settings are optional. Copy config.json.example to config.json and edit the values you want to change:

cp config.json.example config.json
{
    "daily_message_limit": 200,
    "weekly_message_limit": 1000,
    "daily_token_limit": 5000000,
    "weekly_token_limit": 25000000,
    "refresh_seconds": 60,
    "refresh_max_seconds": 300,
    "osd_opacity": 0.75,
    "osd_scale": 1.0
}
SettingDefaultDescription
refresh_seconds60Base poll interval — how often to fetch new data from the API (seconds)
refresh_max_seconds300Max poll interval when the API rate-limits/errors; the interval backs off exponentially toward this cap and snaps back to refresh_seconds on the next clean refresh
statusline_cache_path""Path to a statusLine-dumped rate-limit JSON file (see Statusline-fed rate limits). Empty = disabled.
usage_endpoint_min_seconds300With statusline_cache_path set: while the dump is seconds-fresh, /api/oauth/usage is called at most once per this many seconds.
osd_opacity0.75OSD background opacity (0.15--1.0)
providers["claude"]Add "codex" to also poll the local OpenAI Codex CLI (codex app-server) and show its 5h/weekly usage beneath Claude's — an extra ring row in gauge view, two extra bars in bars view. POSIX-only.
codex_poll_seconds300How often (seconds) to spawn the codex app-server RPC; an on-disk cache is served in between.
daily_message_limit200Daily message limit for local tracking in the popup
weekly_message_limit1000Weekly message limit for local tracking in the popup
daily_token_limit5000000Daily token limit for local tracking
weekly_token_limit25000000Weekly token limit for local tracking
claude_dir~/.claudePath to the Claude Code data directory
themedefaultColor theme for the OSD and popup. One of default, catppuccin-mocha, dracula, nord, gruvbox-dark, terminal, dashboard, hud, receipt, strip, brutalist
show_tickertrueWhether the scrolling per-turn cost ticker is painted at the bottom of the OSD. Toggle at runtime via right-click → "Show cost ticker".
show_newsfalseWhether the live Anthropic/Claude news headline strip is shown on the OSD. Off by default because it makes outbound calls to a 3rd-party feed. Toggle at runtime via right-click → "Show news ticker".
osd_positiontop-rightWhere the OSD anchors: top-left, top-right, bottom-left, bottom-right, or custom. Set from right-click → "OSD Position", or automatically to custom when you drag the overlay.
osd_x / osd_ynullExact screen coordinates used only when osd_position is custom. Written automatically on drag.
osd_scale1.0OSD zoom level (0.6–4.0). Updated automatically when you scroll the mouse wheel over the OSD, so it reopens at the same size.
osd_minimizedfalseWhether the OSD is in its collapsed thin-strip form. Written automatically via right-click → "Minimize / Restore".
osd_visibletrueWhether the OSD overlay is shown. Written on quit so the widget reopens in the same visible/hidden state.
osd_always_on_toptrueKeep the OSD pinned above other windows. Set to false (or right-click → "Always on top") to let it sit as a normal background desktop widget.
osd_view_modebarsOSD layout: bars (progress bars + cost ticker) or gauge (circular rings).
notifications_enabledtrueWhether desktop notifications fire when usage crosses a threshold.
notify_thresholds[0.75, 0.90]Utilisation fractions that fire a notification when first crossed.
api_server_enabledfalseEnable the opt-in localhost JSON API (/usage, /healthz).
api_server_host / api_server_port127.0.0.1 / 8765Bind address and port for the localhost API.
webhooks{}Map of event → URL (threshold_crossed, daily_report, anomaly, budget_projection, burn_alert).
peak_awareness_enabledtrueShow an unobtrusive "reduced 5h limit" hint in the popup during Anthropic's weekday peak window. Tune the window with peak_start_hour (5), peak_end_hour (11, exclusive), peak_timezone (America/Los_Angeles), peak_weekdays ([0,1,2,3,4], Mon–Fri).
monthly_budget_usd0.0Monthly spend cap (USD). Set > 0 to show month-to-date + projected spend in the popup and a once-per-month alert when projected to exceed it. 0 disables the feature (and its extra month-wide scan).
budget_notify_enabled / budget_notify_ratiotrue / 1.0Whether the budget projection notification fires, and at what fraction of the cap (0.9 warns at 90%).
burn_alerts_enabledtrueReal-time OSD badge + debounced notification when the 5h window burns fast or a turn / retry-loop spikes tokens. Tune with burn_warn_pct_per_min (2.0), burn_crit_pct_per_min (5.0), burn_window_seconds (600), spike_token_multiplier (4.0), spike_min_tokens (20000), spike_baseline_min_turns (5), retry_storm_turns (3), retry_storm_window_seconds (120), burn_alert_cooldown_seconds (900).

Keys omitted from config.json fall back to built-in defaults, so config.json.example is an intentionally minimal starter listing only the most commonly changed keys. Everything else in the table above — the opt-in providers (Codex), statusline/endpoint tuning, the burn / peak / budget alerts, the localhost API, webhooks, and the auto-persisted OSD state — simply uses its default until you add it.

Themes

The widget ships with 11 built-in color themes — 5 classics plus 6 Claude-designed skins. Select one by adding "theme": "<name>" to your config.json:

{
    "theme": "dracula"
}

Available themes (gallery above):

Classics (dark):

  • default -- the original widget palette
  • catppuccin-mocha -- soft pastel dark theme
  • dracula -- classic purple-and-pink dark theme
  • nord -- cool arctic blue palette
  • **gruvbox-d

Files in the repo

Repository payload19 top-level entries
  • .github
  • claude_usage
  • docs
  • Formula
  • screenshots
  • scripts
  • skins-themes
  • tests
  • .editorconfig
  • .gitignore
  • CHANGELOG.md
  • config.json.example
  • CONTRIBUTING.md
  • LICENSE
  • main.py
  • MANIFEST.in
  • pyproject.toml
  • README.md
  • SECURITY.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More tools

JuliusBrussee/
caveman

🪨 why use many token when few token do trick — Claude Code skill that cuts 65% of tokens by talking like caveman

105k
1 add
MemPalace/
mempalace

The best-benchmarked open-source AI memory system. And it's free.

59k
stablyai/
orca

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

66k

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

132k

Never stop coding. Free MIT AI gateway: one endpoint, 352 providers (150+ free), 1200+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 550+ contributors

64k
headroomlabs-ai/
headroom

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

71k