AI Usage Indicator
Bottom-bar indicator showing live Claude Code and Codex session usage, sourced from the official OAuth endpoints.
aimux can show the current session usage of AI CLI tools (Claude Code,
Codex) in the bottom status bar, with a click-to-open popover for detailed
metrics.
The indicator is fully opt-in via config — if you don't enable it, nothing is spawned, no network calls happen, and nothing is rendered.
What It Shows
For each enabled tool the indicator renders a compact line:
CC ━━━─ 48% · 00:07h CO ━━━━ 92% · 04:12h- a label (
CCfor Claude Code,COfor Codex) — short text until Nerd Fonts ships dedicated Anthropic / OpenAI brand glyphs - a 4-segment bar (25% per segment) using box-drawing characters
- the percentage used in the current session (5-hour window)
- a reset countdown in
HH:MMhuntil the window rolls over
Colors come from the active theme palette:
< 60%→successtone (muted-positive)60–84%→warningtone≥ 85%→errortone
Click the indicator to open a popover with per-tool details (tokens, cost,
burn rate, reset time). Press Esc to close.
Enabling It
Add a statusBar.aiUsage block to your aimux.config.ts:
import { defineConfig } from '@brimveyn/aimux-config'
export default defineConfig({
statusBar: {
aiUsage: {
enabled: true,
pollSeconds: 60,
tools: ['claude', 'codex'],
},
},
})Remove the block or set enabled: false to hide the indicator entirely and
stop all polling.
To show only one tool, pass a single-entry tools array:
statusBar: {
aiUsage: {
enabled: true,
tools: ['claude'],
},
}Fields
| Field | Type | Default | Notes |
|---|---|---|---|
enabled | boolean | false | Master switch. When false, no polling happens. |
tools | Array<'claude' | 'codex'> | ['claude', 'codex'] | Which tools to poll and render. |
pollSeconds | number | 60 | Polling interval. Clamped to a minimum of 5. |
claudePlan | 'auto' | 'pro' | 'max5' | 'max20' | 'auto' | Reserved for future use; the current Claude adapter ignores this because the OAuth endpoint returns the true percentage directly. |
codexWeeklyLimit | number | — | Reserved for future use; the current Codex adapter uses the OAuth endpoint. |
How It Works
Both adapters hit the same backend that the official CLIs use for their
/usage (Claude) and /status (Codex) commands. The percentage matches what
you see inside each CLI.
Claude Code
- The adapter reads the OAuth bearer token from the macOS Keychain entry
Claude Code-credentialsvia/usr/bin/security find-generic-password. - It calls
GET https://api.anthropic.com/api/oauth/usagewith:Authorization: Bearer <accessToken>anthropic-beta: oauth-2025-04-20
- The response's
five_hour.utilizationandfive_hour.resets_atare used directly. - Credentials are cached in memory until their
expiresAt, so the keychain is only touched once peraimuxsession.
Requirements:
- macOS (Keychain access is required for the token read).
- A logged-in Claude Code install (run
claudeonce to sign in). - The very first keychain read pops a macOS dialog asking if
securitymay read the item. Click Always Allow. The ACL is persisted and survives reboots, so you should not see it again unless you re-login to Claude, or a macOS update replaces/usr/bin/securityand invalidates its signature.
Codex
- The adapter reads
tokens.access_tokenandtokens.account_idfrom~/.codex/auth.json. - It calls
GET https://chatgpt.com/backend-api/wham/usagewith:Authorization: Bearer <access_token>ChatGPT-Account-Id: <account_id>
- It picks the 5-hour rate window (
limit_window_seconds === 18000) and readsused_percent+reset_atdirectly. - The
CODEX_HOMEenvironment variable and thechatgpt_base_urloverride in~/.codex/config.tomlare both honored, matching the Codex CLI's own rules.
Requirements:
- A logged-in Codex CLI install (run
codexonce to sign in). No keychain involved on any OS.
Fault Tolerance
- If the keychain read fails, or
~/.codex/auth.jsonis missing, the affected tool's cell renders a short error (CC —/CO —) and the other tool keeps working. - On
401 / 403from either endpoint, the cached credentials are evicted and the cell showsoauth expired — run <cli> to re-auth. - All network requests use a 15 s timeout and abort cleanly.
- No data is written to disk by the indicator.
Theming
Every color used by the indicator and popover comes from the active theme's
palette (success, warning, error, ink, muted). Switching themes at
runtime updates the indicator immediately. No hardcoded colors.
Removing the Feature
Delete the statusBar block from aimux.config.ts (or set
statusBar.aiUsage.enabled: false). The indicator disappears, the polling
service is torn down, and no further network or keychain access occurs.