by dennykim123
macOS menu bar widget showing Claude Code & Codex usage limits as battery icons 🔋
# Add to your Claude Code skills
git clone https://github.com/dennykim123/claude-codex-batteryGuides for using ai agents skills like claude-codex-battery.
claude-codex-battery is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by dennykim123. macOS menu bar widget showing Claude Code & Codex usage limits as battery icons 🔋. It has 53 GitHub stars.
claude-codex-battery's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/dennykim123/claude-codex-battery" and add it to your Claude Code skills directory (see the Installation section above).
claude-codex-battery is primarily written in JavaScript. It is open-source under dennykim123 on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh claude-codex-battery against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
A macOS menu bar widget that shows your remaining Claude Code and Codex usage limits as battery icons — so you never have to open
/usageagain.
C = Claude · X = Codex. Each battery shows the remaining % of a limit window — full & green means plenty left, red means almost out. Click for a detailed breakdown with reset times.
Built as a single SwiftBar plugin — one self-contained script, no third-party libraries. The battery icons are rendered as PNGs from scratch in pure JavaScript (node:zlib only), so there's no image library and no npm install. Network calls: one to Anthropic's official usage endpoint (the same data /usage shows, fetched with your own local Claude Code login — see Privacy) and an optional once-a-day update check (see Updating). (ccusage is an optional extra for the cost breakdown.)
| Group | Batteries | Source |
|---|---|---|
C Claude |
5-hour session · weekly · Fable (top-model weekly cap) | Anthropic's OAuth usage API — queried live with your local Claude Code login; account-level, so usage from every device/surface is included |
X Codex |
5-hour · weekly (or credit balance on the premium plan) | ~/.codex/sessions/**/*.jsonl → rate_limits |
Click the widget for a dropdown with, per limit:
Claude Code
5h remaining ▕██████████████░░░░░░▏ 70% (used 30%) · resets 3h 18m
weekly ▕██████▋░░░░░░░░░░░░░▏ 33% (used 67%) · resets 3d 21h
Fable ▕████░░░░░░░░░░░░░░░░▏ 26% (used 74%) · resets 3d 21h
today by model ▕████████████▏ Fable $75 · Opus $46 · Sonnet $5 …
Codex · prolite
5h remaining ▕████████████████████▏ 100% (used 0%)
weekly ▕████████████████▋░░░▏ 83% (used 17%)
Colors follow a traffic-light scale: green ≥ 50 % left, amber < 50 %, red < 20 %.
| Required? | Install | |
|---|---|---|
| macOS | ✅ | — |
| SwiftBar | ✅ | brew install swiftbar |
| bun | ✅ | curl -fsSL https://bun.sh/install | bash |
| Claude Code | ✅ for C batteries |
just needs to be logged in on this Mac (the widget reuses its login to query the usage API) |
| Codex CLI | optional | for the X batteries; without it, only Claude is shown |
| ccusage | optional | adds the cost / token / per-model breakdown in the dropdown — the battery works fully without it |
Note: This widget shows your own account's limits — via your local Claude Code login and your local Codex session logs. If you don't use Claude Code (or Codex), there simply won't be any data to display.
git clone https://github.com/dennykim123/claude-codex-battery.git
cd claude-codex-battery
./install.sh
install.sh will:
~/.swiftbar-plugins/, rewriting the shebang to your machine's bun path (SwiftBar runs plugins with a minimal PATH, so an absolute shebang is required)No npm install, no bundled libraries — the plugin is a single self-contained script.
The battery appears in your menu bar within a few seconds. It refreshes every 2 minutes (the .2m. in the filename).
If you prefer not to run the script:
mkdir -p ~/.swiftbar-plugins
# rewrite shebang to your bun path, then copy:
sed "1s|.*|#!$(command -v bun)|" claude-codex-usage.2m.js > ~/.swiftbar-plugins/claude-codex-usage.2m.js
chmod +x ~/.swiftbar-plugins/claude-codex-usage.2m.js
defaults write com.ameba.SwiftBar PluginDirectory -string ~/.swiftbar-plugins
open -a SwiftBar
The widget checks GitHub for a newer version at most once a day — a tiny background request for the VERSION file. When a new version is out, a green 🆕 update row appears in the dropdown; click it to replace the plugin in place and refresh (your previous copy is kept as .bak). There's also an always-visible ⬆️ update now row that replaces the plugin with the latest main on demand — no waiting for the daily check.
Prefer to do it yourself? From your clone: git pull && ./install.sh.
To turn the check off entirely, comment out the getUpdateInfo() call near the bottom of the script — then the only network call left is the Anthropic usage query.
Claude Code-credentials) and calls api.anthropic.com/api/oauth/usage — the same endpoint /usage uses. The token is sent only to api.anthropic.com, passed via stdin (never visible in ps), and never written to disk or logs. macOS may show a one-time Keychain permission prompt — click Always Allow. (Clicking Deny makes macOS re-prompt on every refresh — if you'd rather the widget never touch the Keychain, run touch ~/.claude/swiftbar/.no-live instead; it then reads local cache files only, like v1.1.)auth.json and API keys are never touched.rate_limits object (numbers), never the messages.curl/fetch and you've seen every network call it can make.Claude — live. Every refresh queries Anthropic's usage API directly with your local Claude Code login — the same server-side data /usage shows, so the numbers match it by construction. Because the limits are account-level, usage from every surface and device (terminal, desktop app, web, another machine) is already included. If the query fails (offline, logged out), the widget falls back to its last successful response and labels the reading with its age in amber.
Codex — as fresh as your last Codex run. Codex writes rate-limit data to its session logs only while you use it, and records no reset time. So the value is a snapshot from your most recent session — the dropdown labels it "measured N ago" and warns past 3h. Run Codex and it re-syncs instantly.
TL;DR — Claude is live (same source as /usage); Codex is a clearly-labeled snapshot from your last session, not a live feed.
The whole thing is one .js file run by bun on a timer.
node:zlib (hand-rolled CRC32 + IHDR/IDAT/IEND chunks). A 5×7 bitmap font renders the numbers and the C/X group labels. SwiftBar displays the PNG at pixels ÷ 2 pt.~/.claude/swiftbar/.claude-usage.json as an offline fallback. The Fable cap is the weekly_scoped entry.rate_limits. The premium plan reports a credits object instead of percentages when exhausted; the widget handles both shapes.Codex only writes limit data to session logs while you use it, and doesn't record a reset time when exhausted. So if you haven't run Codex in a while, the value can be stale. The widget:
codex exec --sandbox read-only in the background to refresh — but only when Codex is exhausted and the value is 2h+ old, at most once every 6 hours (≈4×/day, ~20k tokens each).If you'd rather it never spend tokens on its own, comment out the maybeAutoRefreshCodex(codex) call near the render section.
| Want to change | Where |
|---|---|
| Refresh interval | filename .2m. → .1m., .5m., .30s., … |
| Battery size | ↕ row in the dropdown — toggles between big (4×6 font, default) and small (3×5 font, ~25% narrower); stored in ~/.claude/swiftbar/.batt-size |
| Color thresholds | heatRemain / heatRemainHex (20 % / 50 %) |
| Disable Codex auto-refresh | comment out maybeAutoRefreshCodex(codex) |
| Disable live Claude API / Keychain access | touch ~/.claude/swiftbar/.no-live (falls back to local cache files) |
| Which Claude limits to show | the battItems.push(...) block |
A single script stays dependency-free, easy to audit, and trivial to fork — and its audience (Claude Code / Codex developers) already lives in the terminal, so brew install swiftbar