Skip to content

k6w/claude-manager

Repository files navigation

Claude Manager

A CLI for managing multiple Claude Code accounts with OAuth authentication and usage tracking.

Features

  • Add accounts via OAuth (automatic browser or manual code entry)
  • View rate-limit utilization per account (5h / 7d / Opus / Sonnet windows) with reset times
  • Automatic OAuth token refresh — tokens are refreshed transparently before they expire
  • Switch, rename, and remove accounts
  • Export environment variables for the active account
  • Secure encrypted storage of OAuth tokens (AES-256-GCM, key in the OS keychain)

Installation

npm install -g .

Commands

  • claude list - list configured accounts with utilization and token status
  • claude status - detailed per-account view (expiry, last usage snapshot)
  • claude import - import the account you're already logged into in Claude Code
  • claude add - add a new account via OAuth
  • claude switch - switch the active account
  • claude rename - rename an account
  • claude refresh [--all] - manually refresh OAuth tokens
  • claude remove - remove an account (asks for confirmation)
  • claude export-env - print shell export snippet for the active account
  • claude usage - refresh utilization data for all accounts
  • claude --help - show help

Usage

Adding an account

claude add

You'll be prompted for:

  1. Account label (e.g., "Work Account", "Personal")
  2. Account type (Pro, Max 5x, Max 20x, Other)
  3. OAuth flow (automatic browser or manual code)

Automatic flow opens your browser and handles the callback automatically. Manual flow shows a URL to open and prompts for the authorization code.

Usage stats need a full-scope token. A directly-pasted CLAUDE_CODE_OAUTH_TOKEN is inference-only (it lacks the user:profile scope), so claude usage returns a 403 for it. Use OAuth login or claude import to get a token that can read usage.

Importing from Claude Code

If you're already logged into Claude Code on this machine:

claude import

This reads Claude Code's own login credentials locally (a JSON file on Linux/WSL, or the macOS Keychain — which prompts you to allow access) and adds them as a managed account. That token is full-scope, so usage stats work and it auto-refreshes. Nothing is sent anywhere; the read happens on your machine.

Switching accounts

claude switch

Select which account should be active. The active account's token will be exported via claude export-env.

Exporting to shell

claude export-env
export CLAUDE_CODE_OAUTH_TOKEN="your_token_here..."

Use with eval to set in your shell:

eval $(claude export-env)

Viewing usage

claude usage   # fetch the latest utilization for all accounts
claude list    # show all accounts with utilization + token status
claude status  # detailed per-account view

The usage view reflects the Claude OAuth usage API, which reports rate-limit utilization (a percentage per window) and reset times — not token counts. Columns are color-coded: green < 50%, yellow < 80%, red ≥ 80%.

Notes

  • Config is written atomically (temp file + rename) to avoid corruption, and is stored with 0600 permissions. Running multiple claude commands at the exact same time can still cause one to overwrite the other's change (last write wins) — atomic writes prevent corruption, not logical races.
  • Directly-pasted tokens have no refresh token and cannot be auto-refreshed; they stop working when they expire and the account must be re-added.

Development

npm install
npm run build    # Build TypeScript
npm run start    # Run from dist/
npm run dev      # Run with ts-node
npm test         # Run tests
npm run lint     # Lint code
npm run format   # Format code

About

A CLI for managing multiple Claude Code accounts with OAuth authentication and usage tracking.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages