Switch between multiple Anthropic OAuth accounts in pi. Personal, enterprise, work, side-project -- name them whatever you want, add as many as you need, and swap between them mid-conversation.
Directional fallback chains keep your accounts isolated: enterprise can fall back to personal on rate-limit, but personal never touches enterprise. You control which direction requests flow.
flowchart TD
subgraph pi["pi session"]
User(["You send a message"])
MCC["multi-claude-code provider"]
Base["Built-in anthropic-messages provider"]
end
subgraph accounts["Account Pool"]
A1["personal"]
A2["enterprise"]
A3["side-project"]
end
User --> MCC
MCC -->|"1. Pick active account"| accounts
MCC -->|"2. Inject OAuth token"| Base
Base -->|"3. Stream response"| Anthropic["Anthropic API"]
subgraph fallback["On 429 Rate Limit"]
direction LR
RL["Rate-limited account"] -->|"follows fallback chain"| Next["Next allowed account"]
Next -->|"retry"| Base2["Retry request"]
end
Anthropic -.->|"429"| fallback
flowchart LR
subgraph chain["Example: fallback chains"]
direction LR
E["enterprise"] -->|"can fall back to"| P["personal"]
E -->|"can fall back to"| S["side-project"]
P -.-x|"no fallback"| E
S -.-x|"no fallback"| E
end
style P fill:#2d4a3e,stroke:#4a7a62
style E fill:#4a3a2d,stroke:#7a6a52
style S fill:#2d3a4a,stroke:#527a8a
The extension registers a provider called multi-claude-code that mirrors every Anthropic model. On each request, it:
- Picks the active account (your manual selection, or the last used)
- Refreshes the OAuth token if it's about to expire
- Passes the token to the built-in
anthropic-messagesprovider - If the API returns a 429 before any tokens stream, follows the account's fallback chain and retries (up to 5 hops)
Tokens are injected per-request, not configured globally. That's why /mcc-use works instantly, even mid-session.
pi install npm:pi-multi-claude-codeOr load directly from a local checkout:
pi -e ./index.tsRestart pi after installing.
Labels are freeform. Call them whatever makes sense to you.
/mcc-login personal
Your browser opens to Anthropic's OAuth page. Log in, authorize, paste the code back into pi. Repeat for each account:
/mcc-login enterprise
/mcc-login side-project
By default, every account has no fallback. If it gets rate-limited, the request fails. This is the safe default.
You opt in to fallback per account. The syntax is /mcc-fallback <source> <target1> <target2> ...:
/mcc-fallback enterprise personal side-project
This means: if enterprise hits a rate limit, try personal first, then side-project. Order matters.
Your personal account has no fallback configured, so personal work never lands on enterprise. That's the whole point.
To see what's configured:
/mcc-fallback
To clear a fallback (back to fail-on-limit):
/mcc-fallback enterprise
Open the model picker with /model and choose any model under the multi-claude-code provider. These are the same Anthropic models you already use, just routed through the extension.
Interactive picker:
/mcc-use
Or switch directly:
/mcc-use personal
Or press Ctrl+Shift+A to cycle through accounts without leaving the editor -- same feel as Ctrl+P for models.
The status bar updates immediately to reflect the active account. If a fallback fires mid-session, it updates there too.
| Command | Description |
|---|---|
/mcc-login <label> |
Add an account. Opens Anthropic OAuth in your browser. |
/mcc-use [label] |
Switch accounts. No label opens an interactive picker. |
/mcc-fallback [source targets...] |
Set or view fallback chains. No args shows all chains. |
/mcc-status |
All accounts with token expiry, rate-limit cooldowns, and fallback config. |
/mcc-remove <label> |
Delete an account from the pool. |
| Shortcut | Action |
|---|---|
Ctrl+Shift+A |
Cycle to the next account in order |
Account credentials are stored in ~/.pi/agent/multi-claude-code.json. This file contains OAuth refresh tokens. Treat it like a password file.
When the Anthropic API returns a 429 (or similar overload error) before any tokens have streamed:
- The current account gets a 1-hour cooldown
- The extension checks the account's
fallbackTolist - If a fallback account is available and not also rate-limited, it retries the request
- If no fallback is configured or all fallbacks are exhausted, the error surfaces to you
- Cooldowns clear automatically.
/mcc-statusshows remaining time.
If tokens have already started streaming when an error occurs, the extension does not retry (it would lose partial output). The error passes through as-is.
npm install
npm run tsgo # type-check
npm run test # run testsLoad the extension from source for development:
pi -e ./index.tsMIT