claude-code-profiles
v0.1.4
Published
Manage Claude Code auth profiles from the command line.
Downloads
463
Readme
claude-code-profiles
Small CLI for switching Claude Code auth profiles by managing ~/.claude.json as a symlink.
On macOS, it also saves and restores Claude Code's Keychain credential so account switching actually changes the active login.
Commands
npx claude-code-profiles init default
npx claude-code-profiles save work
npx claude-code-profiles use work
npx claude-code-profiles current
npx claude-code-profiles list
npx claude-code-profiles whoami
npx claude-code-profiles verifyHow it works
- Managed profiles live under
~/.claude-code-profiles/profiles/<name>/.claude.json - The active Claude auth file stays at
~/.claude.json - Claude's real OAuth token lives in secure storage, not just
~/.claude.json - On macOS, the live secure-storage entry is the same keychain item Claude Code uses internally
useswitches the active file by updating that path to a symlink- If the active auth file is unmanaged,
usefirst backs it up under~/.claude-code-profiles/backups/ currentreports the active profile from the symlink target, not a separate state flag- Existing
~/.claude-profilesdirectories are still detected so older saved profiles keep working
Important
- Versions before
0.1.3only switched~/.claude.json, not the Keychain credential. - If you saved profiles with an older version, re-auth into each account once and run
save <name>again to capture its Keychain credential. claude auth statusis not sufficient to prove which OAuth token is live. Claude Code reads account metadata from~/.claude.json, but live requests use the OAuth token from secure storage.- Use
claude-code-profiles verify [name]to ask Claude's/api/oauth/profileendpoint which account a saved or live token actually belongs to.
Notes
- This tool only manages Claude Code auth state, not chat history or other
~/.claudedata. - Saved profile files contain sensitive auth state and are written with
0600permissions. - Profile names are limited to letters, numbers,
.,_, and-.
Local development
npm test
node ./bin/claude-code-profiles.js help