Skip to content
MattJacksonPublic

About

See usage across multiple Claude Max accounts, switch instantly, and auto-swap before you hit the limit. macOS.

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

usagio

Sponsor

CI Release License: MIT MSRV

See your Claude usage across multiple Claude Max accounts from your menu bar, switch between them without the /login browser dance, and (optionally) auto-ride each account's quota to ~95% without ever slamming into the 100% wall that interrupts your work.

Renamed from claude-usage. v0.4.0 renames the project to usagio; upgrading Homebrew users get the new binary transparently, and on first run the config directory (~/.config/claude-usage/ → ~/.config/usagio/) and launchd label migrate themselves. The macOS Keychain service string is intentionally frozen at "claude-usage" so existing tokens survive without a re-login.

Unofficial. Not affiliated with, endorsed by, or supported by Anthropic. It talks only to the same first-party endpoints the official Claude Code CLI uses, with the same public OAuth client id. Use at your own risk. Runs on macOS, Linux, and Windows — a native menu-bar/tray app on each, using the OS credential store (macOS Keychain, Linux Secret Service, Windows Credential Manager) and the OS autostart mechanism (launchd, XDG autostart, HKCU Run).

Install

macOS — Homebrew:

brew tap mattjackson/tap
brew tap --trust mattjackson/tap        # third-party tap — approve once
brew install mattjackson/tap/usagio
usagio install                          # menu-bar app + auto-swap, now and at every login

Upgrades come through Homebrew: brew upgrade usagio — a running menu-bar app notices the new binary and relaunches itself into it, so you don't have to restart anything.

Linux — download usagio_*_amd64.deb (or the x86_64-unknown-linux-gnu tarball) from the latest release, install it, then run usagio install to register the tray app + auto-swap.

Windows — download and run usagio-*-x86_64-pc-windows-msvc-setup.exe from the latest release; it installs the tray app and starts it at login.

Building from source is covered below.

At a glance

Platform macOS · Linux · Windows
Interface Menu-bar app (primary) + CLI
Language Rust (single binary, no webview)
Talks to api.anthropic.com / platform.claude.com only
Token storage ~/.config/usagio/state.json (chmod 600) + OS keystore (macOS Keychain / Linux Secret Service / Windows Credential Manager)

Table of contents

Why

If you run more than one Claude Max subscription, there is no built-in way to:

  • see, at a glance, how much of each account's session (5h) and weekly (7d) limits you've used and when they reset;
  • switch which account claude uses without the interactive /login browser flow; or
  • keep working when one account hits its limit — normally you just get blocked.

usagio solves all three. Accounts are identified by their email — there are no nicknames to invent or keep in sync.

From source

Requires a recent Rust toolchain.

git clone https://github.com/MattJackson/claude-usage.git
cd usagio
cargo build --release
cp target/release/usagio /usr/local/bin/

Onboarding accounts

You log into each account once, the normal way, and usagio captures that login — keyed by the account's email.

Why capture? macOS holds exactly one Claude login in the Keychain at a time. So you log in as an account, capture it (its credentials are copied into ~/.config/usagio/state.json), then log in as the next one and capture that. Once captured, switching just rewrites that single Keychain item — no more logins.

# 1. Log in as your first account, then capture it.
claude              # /login as account A, back to the prompt
usagio capture          #  ->  Captured you@work.com

# 2. Log in as your second account, then capture it.
claude              # /login as account B
usagio capture          #  ->  Captured you@personal.com

# 3. See everything.
usagio

From the menu-bar app you don't even need claude: click the icon → Sign in to a new Claude account…, sign in as that account in usagio's own window (email code, then Authorize), and it's added — without switching to it. Or the original way: claude → /login as the new account, then Capture current login…. From a terminal, usagio login signs a new account in via your browser.

Notes:

  • capture takes no name — it reads the email of whoever is currently logged in. Capturing an email that already exists just refreshes it; it never silently creates a duplicate or overwrites a different account.
  • You log in once per account; after that usagio refreshes tokens itself.
  • When an account's login is about to expire (or has), its row says renew · 2d (or ⚠ renew) and you get one notification. Click Renew login… in its submenu: usagio opens its own small sign-in window for that account — separate from your browser, with that account's claude.ai session remembered — so it's usually a single Authorize click. No claude / /login needed, and it never changes which account is active. From a terminal: usagio renew <email> (uses your browser).
  • Remove an account from the menu, or with usagio rm <email>.

Menu bar app

usagio menubar is the primary interface: a status-bar item showing the % of the account at risk (or the provider you pin under Settings ▸ Tray Icon). Click it for a dropdown:

  • Accounts, grouped by provider (Claude, Codex, … in alphabetical order), each provider under a header row. Each account is a submenu labelled email on the left with S% / W% right-aligned battery-menu style. Within a provider, accounts are ordered by swap priority — usable accounts by soonest weekly reset, then locked accounts by when they unlock — so the list reads top-to-bottom as "use this first, then this." The active account is bold with a checkmark; any percentage in a danger band is colored (amber ≥80%, red ≥95%) so a nearly-spent account jumps out. A locked account shows its unlock countdown instead of the percentages. Each submenu opens:
    • a stats block — which window binds and when it frees (Weekly locked · unlocks in …, Session renews in …), the plan, and updated Xm ago
    • anything extra the provider itself reports, only when there's something to show: the spendable credit balance (Credits · 120, Credits · unlimited; never spend or a cap), where this week's usage went (This week · Claude Code 82% · Chats 18%), and per-model weekly limits in use (Fable 7d · 42% · resets in 2d 3h). Never estimated.
    • Switch to this account (not shown for the active account)
    • Renew login… — sign this account in again in usagio's own window
    • Remove…
  • Sign in to a new account ▸ and Capture current login ▸, one entry per provider
  • Settings ▸ Refresh usage now, Auto-swap ▸ (Off / 70% / 85% / 95% / 98%, Use credits when every plan is used up, Switch to best account now), Tray Icon ▸ (At risk, or pin one provider), Backups ▸ (Save… / Restore…) and Notifications ▸
  • Quit

Starting at login is not a menu item: use usagio install / usagio uninstall.

The menu bar also runs the auto-swap daemon in the same process. usagio install registers a launchd agent so it starts at every login (and runs Dock-less — menu bar only). usagio uninstall removes it.

CLI

Everything the menu does is scriptable. Accounts are selected by email or a unique prefix (an ambiguous prefix lists the matches).

usagio                     Show usage for every account (default)
usagio capture             Capture the account you're currently logged into
usagio switch [acct]       Make <acct> the active login (no launch)
usagio start [acct]        Switch, then launch the selected provider CLI
usagio continue [acct]     Switch, then resume the selected provider session
usagio token <acct>        Print an access token (for scripting; see below)
usagio login               Sign in to a new account in your browser (adds it)
usagio renew <acct>        Sign <acct> in again in your browser (fresh login)
usagio rm <acct>           Forget an account
usagio menubar             Run the menu-bar app
usagio watch               Headless auto-swap (foreground, no menu bar)
usagio install|uninstall   Run / stop the menu-bar app at every login
usagio report              Usage patterns by weekday / hour / account
usagio --version

With no [acct], switch / start / continue auto-pick from the cached usage: among accounts that are ready (at least 15 minutes of runway before your threshold), the one whose weekly limit resets earliest — so you burn quota that's about to reset anyway — with ties going to the one with the most runway. If no account is ready it picks the one near the threshold that lasts longest; it never picks an account at its limit.

usagio start               # auto-pick the best account and open claude
usagio continue dev        # prefix-match dev@…, switch, resume last conversation
TOKEN=$(usagio token dev)  # a fresh access token for scripts

usagio token refreshes an inactive account's token when it is due. For the active account it prints the token Claude Code is using and never refreshes it (that would sign Claude Code out); it warns on stderr if that token has expired.

For Codex, use an explicit provider when accounts share an email:

usagio capture codex
usagio switch codex:dev@example.com
usagio start codex:dev
usagio continue codex:dev  # codex resume --last

claude:email also works. Unqualified selectors retain Claude's existing priority; codex: auto-picks within Codex. With only Codex accounts saved, commands without a selector auto-pick within Codex.

On macOS and Linux, Codex switches promptly stop its shared daemon, publish the selected credentials, restart it, and verify its loaded account. Existing clients can reconnect; in-flight turns may be interrupted. Windows retains the graceful handoff that waits for running turns. The pending switch survives a usagio restart. Active-account renewal uses the same handoff; selecting an already-loaded account leaves its work running. This adapter supports Codex's default file credential store. Explicit keyring, auto, and ephemeral stores are rejected before a switch begins. Sessions owned by a separate embedded app-server remain owned by that process; changing the shared daemon does not transfer their ownership.

Auto-swap

The daemon's goal is to exhaust each account's weekly quota in order of soonest reset — spend what's about to expire before it evaporates — without ever letting your active session hit the wall. It does this two ways:

  • Reactive. When the active account's session or weekly usage reaches your threshold (default 95%, set from the menu), it switches to another account with room, so a long session keeps going instead of blocking. If the usage endpoint rate-limits (HTTP 429) and the active account was within 5 points of the threshold when last read, usagio projects its usage forward from the last reading at a conservative burn rate and moves once that projection reaches the threshold, rather than running out blind. A projection moves you onto an account whose usage was freshly verified or, when a 429 storm defers that read, one with a post-leave reading and at least 30 minutes of runway.
  • Proactive rebalance. The usual reason you leave an account is that its 5h session filled — its weekly still has room. When an account's weekly resets within the next 6 hours and it has usable room, the daemon moves to it to spend that quota before it evaporates. Accounts whose weekly reset is further away are not rebalanced to; they are chosen by soonest weekly reset when a switch is needed.

Hysteresis keeps it from thrashing:

  • a target must be ready: after the move it must have at least 15 minutes of runway before it would reach your threshold, at its recent burn rate (or a default rate when there is no history), in both session and weekly. A target's reading must also be fresh — it is re-checked right before the swap if its last reading is more than two minutes old;
  • a swap cooldown (5 minutes) on optional moves such as rebalancing — moving off an account that has hit the threshold is never delayed;
  • no bounce-back to an account it just left until it has a fresh reading taken after it was left; and
  • when no account is ready, a fallback move to a non-ready account happens only if it buys at least 5 more minutes of runway than staying.

Among ready accounts the one whose weekly resets soonest is used first.

Every account that can be switched — Claude and Codex alike — goes through the same rules, each provider with its own cooldown and backoff. If no account has room it notifies you of the soonest reset, and once the cooldown has passed it may move to the account that unlocks soonest (even over a manual pick) so it is ready when that reset lands. It runs inside the menu-bar app (so usagio install keeps it on), or headless via usagio watch on a machine with no menu bar; both run the same loop and use the threshold and auto-swap setting from the menu (usagio watch --trigger overrides the threshold).

Claude plan names also refresh for inactive accounts and accounts whose usage is locked. The app checks two profiles after each normal polling cycle, repeats successful checks after 30 minutes, and retries failed requests after five minutes. Manual Refresh (or usagio list --refresh) checks every eligible profile immediately. Accounts needing sign-in retain their status; expired access tokens wait for the existing credential lifecycle to refresh them.

Your own picks stick. When you switch yourself — from the menu or with usagio switch <acct> / start <acct> / continue <acct> — to an account already at or over your threshold, auto-swap leaves it alone and won't flip back off it either, until it is exhausted (100%) or its subscription lapses. A pick under your threshold auto-swaps at the threshold like any other. Picking another account (or letting usagio switch with no account auto-pick) ends the hold.

How it works

  • Usage comes from the same endpoint the /usage command uses, GET api.anthropic.com/api/oauth/usage, authenticated with the account's OAuth token. Usage is fetched only on the poll tick and cached — switch, list, and the menu read the cache, so ordinary use never rate-limits you.
  • Switching sets the active account by writing two things Claude Code reads: the OAuth token in the macOS Keychain item Claude Code-credentials, and the account identity (oauthAccount) in ~/.claude.json — exactly what a real /login persists. The write is atomic and serialized across processes with a file lock. A new claude session picks up the switched account; sessions already running keep their current account until they're restarted.
  • Token freshness is automatic: tokens are refreshed via platform.claude.com/v1/oauth/token before they expire, and the active account's tokens are re-synced from the Keychain (with an identity check, so a /login into a different account can't corrupt a stored one).

Contributing

Contributions are welcome. See CONTRIBUTING.md for the workflow (branch/PR against dev) and ground rules, and CODE_OF_CONDUCT.md for community expectations. CI runs cargo fmt --check, cargo clippy, and cargo test on macOS on every push and pull request.

Before / after each release the maintainer runs the on-demand QA screenshot pipeline (real EC2 VMs, one per OS) — see packaging/qa-screenshots/README.md.

Security

  • To report a vulnerability privately, see SECURITY.md.
  • Tokens live locally in ~/.config/usagio/state.json (owner-only, 0600) and the macOS Keychain, accessed via the security CLI. Under the single-user threat model this tool assumes, that CLI briefly places the token blob in its own process arguments; a code-signed build will move this back to the Security framework API. Tokens are never written to logs.
  • The tool uses the same public OAuth client id as the official Claude Code CLI, and sends tokens only to Anthropic's own endpoints — nowhere else.
  • If ANTHROPIC_API_KEY is set in your environment, Claude Code uses that and ignores the Keychain login — so account switching won't take effect until it's unset. usagio manages subscription (OAuth) logins, not API keys.

Changelog

See CHANGELOG.md for release notes.

License

MIT — see LICENSE.

About

See usage across multiple Claude Max accounts, switch instantly, and auto-swap before you hit the limit. macOS.

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages