pi-claude-accounts0.1.1
Pi extension: keep several Claude Pro/Max OAuth logins and switch between them with /account
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-claude-accounts
A Pi extension that lets you keep multiple Claude Pro/Max OAuth accounts for Pi's built-in /login and switch between them with a single /account command.
Pi stores exactly one anthropic credential. This extension saves additional logins next to it and swaps the active one on demand.
Install
# local checkout
pi install /absolute/path/to/pi-claude-accounts
# or from git
pi install git:github.com/<user>/pi-claude-accounts
Then run /reload (or restart Pi).
If you previously copied
claude-accounts.tsinto~/.pi/agent/extensions/, remove that copy. Otherwise the/accountcommand is registered twice.
Usage
| Command | What it does |
|---|---|
/account |
Pick an account from a list and switch to it |
/account <name> |
Switch to the saved account <name> |
/account save <name> |
Save the current /login under <name> |
/account list |
List saved accounts (● active, ○ inactive) |
/account remove <name> |
Forget a saved account (auth.json is not changed) |
/account help |
Show command help |
Aliases: add = save, ls = list, rm = remove, use/switch = switch.
The footer shows claude: <name> for the active saved account, or claude: unsaved login when the login in auth.json is not saved yet.
Logging in to a second account
/loginwith your first Claude account, then/account save work.Run
/loginagain. Pi reuses the browser's existing claude.ai session, so you would simply get the same account back. To avoid that, do one of:- open the login URL Pi prints in a private/incognito window, or
- use a different browser profile, or
- sign out of claude.ai first.
Copy the login URL Pi prints into the private window and sign in with the second account.
/account save personal.Run
/account listand check that the emails differ.
How it works
- Pi keeps a single
anthropicentry in~/.pi/agent/auth.json. Switching replaces that entry and leaves other providers untouched. - Saved logins live in
~/.pi/agent/claude-accounts.json(mode0600). - Writes happen under the same
auth.json.lockdirectory lock that Pi'sproper-lockfileuses, so Pi and the extension never write at the same time. - Refresh tokens rotate. When Pi refreshes the active token, the extension copies the new one back into the right slot on
session_start, after eachagent_end, and during every switch. - To tell whose token is whose, it asks
https://api.anthropic.com/api/oauth/profilefor the account id/email. If that lookup fails, it falls back gracefully (matching on the refresh token, or asking you when ownership is unclear).
Caveats
auth.jsonis shared: switching affects every running Pi session.- It relies on Pi internals (the
auth.jsonformat and its lock directory). Tested with Pi 0.99.2. - The Anthropic profile endpoint is unofficial and may change.
claude-accounts.jsoncontains refresh tokens. Keep it private and never commit it.
Development
npm install
npm run check # typecheck + tests
Layout:
src/index.ts the extension (loaded directly by Pi, no build step)
test/claude-accounts.test.mjs node:test suite (uses a temp PI_CODING_AGENT_DIR, no network)
License
MIT