How it works
What it reads and writes
Exactly what usagebar reads, sends and writes on your Mac, how it finds Claude Code's config folder and credential, and why its token refresh can't sign you out.
usagebar uses the signed-in Claude Code account’s own OAuth credential. It never sends a model prompt, never changes Claude Code’s settings and never proxies Claude Code’s traffic.
Reads
- Claude Code’s credential. From your login Keychain: the item
Claude Code-credentials, orClaude Code-credentials-<8 hex characters>when Claude Code uses a custom config folder (the suffix is derived from the folder path, the same way Claude Code derives it). usagebar reads it with/usr/bin/security, so the item’s existing access list applies and no Keychain prompt appears. When the Keychain has no item, it reads<config folder>/.credentials.jsoninstead, as Claude Code does. .claude.json, for usage numbers Claude Code already fetched. It lives in your home folder (~/.claude.json) with the default config folder, or inside a custom one.- File change events in the config folder, as the signal that Claude Code is busy. Not file contents.
Sends
GET https://api.anthropic.com/api/oauth/usagewith the access token.- Only when the token has expired and a refresh is safe (see below):
POST https://platform.claude.com/v1/oauth/tokenwith the refresh token and Claude Code’s OAuth client ID.
Nothing else leaves your Mac.
Writes
- Claude Code’s credential, only after a refresh: to the same Keychain item or file it came from, with the new tokens and every other field kept as it was.
- Claude Code’s lock folders, while refreshing, the same ones Claude Code uses:
<config folder>/.oauth_refresh.lock,<config folder>/.storage-write.lockand the older<config folder>.lock. - Its own preferences (
defaults read xyz.ashray.usagebar): the menu bar style, a remembered config folder, and the end of a rate-limit wait.
Tokens are never logged, printed or shown, and never appear in process arguments: Keychain writes go through security -i on standard input.
Token refresh, and why it can’t sign you out
Claude Code’s access token expires regularly and is renewed with a refresh token. A refresh token works once: after it is sent, the stored one is dead. So a refresh whose result can’t be saved would sign Claude Code out.
Usually there is nothing to do: a running Claude Code refreshes first, and usagebar simply reads the new token. When usagebar does have to refresh, it does so only when it can show the save will work. Otherwise it stays read-only.
- It takes Claude Code’s locks. It holds Claude Code’s refresh lock and its credential store’s write lock for the whole refresh, and re-reads the credential inside them. If Claude Code refreshed in the meantime, usagebar just uses the new token.
- It only refreshes a credential it can write back exactly as Claude Code would. Not one split across several Keychain items, not one too large (allowing for longer tokens) to save in one
security -icommand, not a symlinked file, and only one that comes through usagebar’s encoder unchanged. - It proves the store accepts a write first. Before sending anything, it writes the unchanged credential back and reads it back byte for byte. That shows the Keychain is unlocked and writable.
- Claude Code always wins. It saves only if the stored refresh token is still the one it sent. If Claude Code stored a credential meanwhile, that one stays.
- A failed save is retried. If the save still fails, the new tokens are kept in memory only, and the save is retried on every read.
When any check fails (Keychain locked, credential too large, a custom OAuth server, and so on), usagebar sends nothing. It keeps showing the last numbers, dimmed once they are 30 minutes old, and the menu says it is waiting for Claude Code to refresh its sign-in. Using claude once does that.
Which Claude config folder
Claude Code keeps its state in a config folder, ~/.claude unless you set CLAUDE_CONFIG_DIR. usagebar looks for it in this order:
--config-dir <folder>passed on launch. usagebar also remembers it.CLAUDE_CONFIG_DIRin usagebar’s own environment.- A folder remembered from an earlier
--config-dir. CLAUDE_CONFIG_DIRfrom your login shell.- Otherwise
~/.claude.
Apps opened from Finder or at login don’t inherit variables you export in your shell profile, which is why step 4 exists. On each launch usagebar runs your $SHELL as a login shell (-lc, then interactive -lic if that found nothing) only to read those variables back. The answer is not stored.
CLAUDE_SECURESTORAGE_CONFIG_DIR and CLAUDE_CODE_CUSTOM_OAUTH_URL are honoured the way Claude Code honours them. With a custom OAuth server, usagebar never refreshes the token.
The menu shows the folder in use on the Claude config: line under Configure. To pin one, quit usagebar first (open passes arguments only when it starts the app), then:
open ~/Applications/usagebar.app --args --config-dir ~/my-claude-config # remembered
defaults delete xyz.ashray.usagebar claudeConfigDir # forget it