claudeers.

πŸ”“ unclaimed β€” this page was auto-generated from GitHub. Are you the creator?

Claim this page β†’
// Developer Tools

claude-codex-battery

macOS menu bar widget showing Claude Code & Codex usage limits as battery icons πŸ”‹

// install
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 /usage again.

Menu bar battery widget

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

GroupBatteriesSource
C Claude5-hour session Β· weekly Β· Fable (top-model weekly cap)~/.claude/MEMORY/STATE/usage-cache.json β€” updated live by Claude Code
X Codex5-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 batteriesneeds ~/.claude/MEMORY/STATE/usage-cache.json to exist
Codex CLIoptionalfor the X batteries; without it, only Claude is shown
ccusageoptionaladds 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:

  1. Verify bun and SwiftBar are present (and tell you how to install them if not)
  2. Copy the plugin into ~/.swiftbar-plugins/, rewriting the shebang to your machine's bun path (SwiftBar runs plugins with a minimal PATH, so an absolute shebang is required)
  3. 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_limits object (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 the C/X group 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 the weekly_scoped entry.
  • Codex limits come from the newest session's rate_limits. The premium plan reports a credits object 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-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.


Customizing

Want to changeWhere
Refresh intervalfilename .2m. β†’ .1m., .5m., .30s., …
Battery sizedrawCapsule: bw / bh (5Γ—7 font sets the floor)
Color thresholdsheatRemain / heatRemainHex (20 % / 50 %)
Disable Codex auto-refreshcomment out maybeAutoRefreshCodex(codex)
Which Claude limits to showthe 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

MIT

// compatibility

Platformscli
Operating systemsβ€”
AI compatibilityclaude
LicenseMIT
Pricingopen-source
LanguageJavaScript

// 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.

0 views
β˜… 13 stars
unclaimed
updated about 3 hours ago

// embed badge

claude-codex-battery on Claudeers
[![Claudeers](https://claudeers.com/api/badge/claude-codex-battery.svg)](https://claudeers.com/claude-codex-battery)

// retro hit counter

claude-codex-battery hit counter
[![Hits](https://claudeers.com/api/counter/claude-codex-battery.svg)](https://claudeers.com/claude-codex-battery)

// reviews

// guestbook

0/500

// related in Developer Tools

πŸ”“

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Curs…

// devtoolsaffaan-m/⟨JavaScriptβŸ©β˜… 225,699β—· MIT[ claude ]
πŸ”“

Use Garry Tan's exact Claude Code setup: 23 opinionated tools that serve as CEO, Designer, Eng Manager, Release Manager, Doc Engineer, and QA

// devtoolsgarrytan/⟨TypeScriptβŸ©β˜… 119,234β—· MIT[ claude ]
πŸ”“

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,…

// devtoolssafishamsi/⟨PythonβŸ©β˜… 80,484β—· MIT[ claude ]
πŸ”“

πŸ™Œ OpenHands: AI-Driven Development

// devtoolsOpenHands/⟨PythonβŸ©β˜… 79,324β—· NOASSERTION[ claude ]
β†’ see how claude-codex-battery connects across the ecosystem