π unclaimed β this page was auto-generated from GitHub. Are you the creator?
Claim this page β
claude-codex-battery
macOS menu bar widget showing Claude Code & Codex usage limits as battery icons π
git clone https://github.com/dennykim123/claude-codex-battery
π Claude & Codex Usage Battery
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. The only network call is an optional once-a-day update check (see Updating) β disable it and the widget makes none at all. (ccusage is an optional extra for the cost breakdown.)
What it shows
| Group | Batteries | Source |
|---|---|---|
C Claude | 5-hour session Β· weekly Β· Fable (top-model weekly cap) | ~/.claude/MEMORY/STATE/usage-cache.json β updated live by Claude Code |
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 %.
Requirements
| Required? | Install | |
|---|---|---|
| macOS | β | β |
| SwiftBar | β | brew install swiftbar |
| bun | β | curl -fsSL https://bun.sh/install | bash |
| Claude Code | β
for C batteries | needs ~/.claude/MEMORY/STATE/usage-cache.json to exist |
| 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 reads your own local usage files. If you don't use Claude Code (or Codex), there simply won't be any data to display.
Install
git clone https://github.com/dennykim123/claude-codex-battery.git
cd claude-codex-battery
./install.sh
install.sh will:
- Verify bun and SwiftBar are present (and tell you how to install them if not)
- Copy the plugin into
~/.swiftbar-plugins/, rewriting the shebang to your machine'sbunpath (SwiftBar runs plugins with a minimalPATH, so an absolute shebang is required) - Point SwiftBar at the plugin folder and launch it
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).
Manual install
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
Updating
The widget checks GitHub for a newer version at most once a day β a tiny background request that is the only network call it ever makes. 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).
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 widget makes zero network calls.
Privacy & security
- No usage data leaves your machine. Limits are read from local files and rendered locally; the only network call is the optional daily update check above.
- No secrets read. It never touches
auth.json, credentials, or keychains. - No conversation content. From Codex session logs it parses only the
rate_limitsobject (numbers), never the messages. - Usage values are read at runtime β nothing is baked into the code, so sharing the script shares no data.
How it works
The whole thing is one .js file run by bun on a timer.
- Battery icons are drawn pixel-by-pixel into an RGBA buffer and encoded to PNG using only
node:zlib(hand-rolled CRC32 + IHDR/IDAT/IEND chunks). A 5Γ7 bitmap font renders the numbers and theC/Xgroup labels. SwiftBar displays the PNG at pixels Γ· 2 pt. - Claude limits come from
usage-cache.json, which Claude Code keeps current. The Fable cap is theweekly_scopedentry. - Codex limits come from the newest session's
rate_limits. The premium plan reports acreditsobject instead of percentages when exhausted; the widget handles both shapes.
Codex has one quirk
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:
- flags values older than 3 hours in the dropdown, and
- optionally runs
codex exec --sandbox read-onlyin 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.
Customizing
| Want to change | Where |
|---|---|
| Refresh interval | filename .2m. β .1m., .5m., .30s., β¦ |
| Battery size | drawCapsule: bw / bh (5Γ7 font sets the floor) |
| Color thresholds | heatRemain / heatRemainHex (20 % / 50 %) |
| Disable Codex auto-refresh | comment out maybeAutoRefreshCodex(codex) |
| Which Claude limits to show | the battItems.push(...) block |
Why a SwiftBar plugin (and not a standalone app)?
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 is no barrier. A native .app would drop the SwiftBar requirement but adds a Swift codebase, Apple code-signing + notarization ($99/yr), and ongoing maintenance. Roadmap: if there's enough demand, ship a signed one-click menu-bar .app (likely bundling SwiftBar) for non-terminal users.
Contributing
Issues and PRs welcome β especially for other plans/tools (e.g. mapping additional rate_limit shapes, or adding providers). Keep it dependency-free.
License
// compatibility
| Platforms | cli |
|---|---|
| Operating systems | β |
| AI compatibility | claude |
| License | MIT |
| Pricing | open-source |
| Language | JavaScript |
// faq
What is claude-codex-battery?
macOS menu bar widget showing Claude Code & Codex usage limits as battery icons π. It is open-source on GitHub.
Is claude-codex-battery free to use?
claude-codex-battery is open-source under the MIT license, so it is free to use.
What category does claude-codex-battery belong to?
claude-codex-battery is listed under devtools in the Claudeers registry of Claude-compatible tools.
// embed badge
[](https://claudeers.com/claude-codex-battery)
// retro hit counter
[](https://claudeers.com/claude-codex-battery)
// reviews
// guestbook
// related in Developer Tools
The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursβ¦
Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA
AI coding assistant skill (Claude Code, Codex, OpenCode, Cursor, Gemini CLI, and more). Turn any folder of code, SQL schemas, R scripts, shell scripts, docs,β¦
π OpenHands: AI-Driven Development