How to use multiple Claude Code accounts without logging out and back in?
Claude Code has no built-in command to store several accounts and switch between them, so users with work and personal plans must log out and log back in through the browser each time. Is there a way to keep two accounts signed in at once, and does it work on macOS, Linux/WSL2, and in the VS Code extension?
Originally asked on GitHub: https://github.com/anthropics/claude-code/issues/30031
4 answers
Status: open. Native account switching (like
gh auth switch) is not implemented. The thread describes a workaround that uses theCLAUDE_CONFIG_DIRenvironment variable.On macOS, a commenter reported that Claude Code keys credentials per config directory in the Keychain, using separate items such as
Claude Code-credentials-<8 hex>. To set up a second account:bashCLAUDE_CONFIG_DIR=~/.claude-work claude -p "hi"The fresh directory reports "Not logged in", so run
/loginonce inside it. After that, the default account and the work account both keep working, including in parallel terminals. This was verified on CLI 2.1.220. A shell alias makes it convenient:bashalias claude-work='CLAUDE_CONFIG_DIR=~/.claude-work claude'Limitations reported in the thread:
- On Linux/WSL2 there is no Keychain, and one user found that the second config directory's
.credentials.jsonwas not picked up, so isolation did not work for them. - Claude Desktop ignores
CLAUDE_CONFIG_DIR. - The VS Code extension also ignores it, which causes account leakage in some setups.
General advice: check which account each config directory actually resolves to before relying on it, since logging into the wrong account can happen silently.
Did this work for you?- On Linux/WSL2 there is no Keychain, and one user found that the second config directory's
What @diranged tried on GitHub (Worked)
Set CLAUDE_CONFIG_DIR per profile so each config directory gets its own Keychain entry, then launched Claude Code with the desired profile. The commenter wrapped this in a CLI tool called claude-profile.
Source: https://github.com/anthropics/claude-code/issues/30031#issuecomment-4195583878 (opens external site)
Did this work for you?What @Samic333 tried on GitHub (Worked)
Ran
CLAUDE_CONFIG_DIR=~/.claude-work claude -p "hi"on a fresh directory, logged in once with /login, then confirmed the default account still answered on CLI 2.1.220 on macOS.Source: https://github.com/anthropics/claude-code/issues/30031#issuecomment-5227127606 (opens external site)
Did this work for you?What @zeroarst tried on GitHub (Didn't work)
On Linux/WSL2, relied on CLAUDE_CONFIG_DIR with a credentials file in the second config directory, but Claude Code kept using ~/.claude/.credentials.json.
Source: https://github.com/anthropics/claude-code/issues/30031#issuecomment-4234023419 (opens external site)
Did this work for you?