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.
Last scanned: 7/10/2026
{
"issues": [
{
"file": "README.md",
"line": 55,
"type": "remote-install",
"message": "Install command (remote install script piped to a shell — review the source before running): \"curl -fsSL https://bun.sh/install \\| bash\"",
"severity": "low"
}
],
"status": "PASSED",
"scannedAt": "2026-07-10T07:35:09.005Z",
"npmAuditRan": true,
"pipAuditRan": true,
"promptInjectionRan": true
}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 74 GitHub stars.
Yes. claude-codex-battery passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.
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!
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: two official usage endpoints — Anthropic's and OpenAI's — each fetched with your own local Claude Code / Codex login (the same data /usage and Codex's /status show — see Privacy), plus 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's account-level usage API (backend-api/wham/usage), queried live with your local Codex login — same data Codex CLI's /status shows; falls back to ~/.codex/sessions/**/*.jsonl if offline |
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.)~/.codex/auth.json and calls chatgpt.com/backend-api/wham/usage — the same account-level endpoint Codex CLI polls itself. The token is sent only to chatgpt.com, via stdin (never visible in ps), and never written to disk or logs. (touch ~/.claude/swiftbar/.no-live disables both live queries; it then reads local files only.)OPENAI_API_KEY / ANTHROPIC_API_KEY.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 — live too. The widget queries the same account-level usage endpoint Codex CLI polls internally (backend-api/wham/usage), using your local Codex login token. It's a read-only call that costs no tokens, and because it's account-level, all your machines see the same numbers — so two Macs stay in sync. If the query fails (offline, logged out), it falls back to the newest local session log (labeled "measured N ago", warns past 3h) and then to its last live response.
TL;DR — Both Claude and Codex are live and account-level, so every device shows the same numbers. When a live query fails, each falls back to a clearly-labeled cached/snapshot reading.
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.backend-api/wham/usage with the token in ~/.codex/auth.json, normalized to the same shape as the session-log format, and cached at ~/.claude/swiftbar/.codex-usage.json as an offline fallback (with the newest session log as a second fallback). 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: