If you have a Claude account through work and your own personal subscription, you've probably hit the annoying part: Claude Code stores one login at a time. Switching means logging out of one account and back into the other, which also throws away that account's history, project memory, and settings. Do it twice a day and it gets old fast.
There's a clean fix that needs no extra tooling. Claude Code keeps each account's state (login, history, project data, and settings) tied to a single config directory, and you can change which directory it uses with the CLAUDE_CONFIG_DIR environment variable. Give each account its own directory and the two installs stop knowing about each other entirely.
The mechanism
By default Claude Code keeps everything under ~/.claude. Set CLAUDE_CONFIG_DIR to a different path and it reads and writes there instead:
- separate credentials, so each account stays logged in independently
- separate
history.jsonl, so your work and personal conversations don't mix - separate
projects/,sessions/,settings.json, and plugins
Two directories, two fully isolated accounts, one machine.
One nuance on storage: on macOS the login itself lives in the encrypted Keychain rather than inside the config directory, while on Linux and Windows it sits in a .credentials.json file within the directory. Either way, each CLAUDE_CONFIG_DIR keeps its own login, so the accounts stay isolated.
The setup
Add two aliases to your shell config. On zsh that's ~/.zshrc:
alias claude-personal="CLAUDE_CONFIG_DIR=~/.claude-personal claude"
alias claude-work="CLAUDE_CONFIG_DIR=~/.claude-work claude"On bash, put the same two lines in ~/.bashrc. Reload your shell (source ~/.zshrc) and the commands are ready.
The config directories don't need to exist beforehand; Claude Code creates them on first run. The first time you launch each alias, run /login and sign in with the matching account:
claude-work # then /login with your work account
claude-personal # then /login with your personal accountAfter that, each alias remembers its own login.
On Windows
The syntax above is zsh/bash, so it works as-is in Git Bash or WSL. In native PowerShell, use functions instead and add them to your profile ($PROFILE):
function claude-personal { $env:CLAUDE_CONFIG_DIR = "$HOME\.claude-personal"; claude @args }
function claude-work { $env:CLAUDE_CONFIG_DIR = "$HOME\.claude-work"; claude @args }Reload with . $PROFILE, then run /login once per command, just like above.
Daily use
Use the alias that matches the repo you're in:
cd ~/work/some-service && claude-work
cd ~/projects/side-thing && claude-personalEach keeps its own authentication, history, and project memory, so context never leaks across the boundary. If you want it automatic, you can even wrap these in a directory-aware shell function, but the two aliases cover the common case.
Further reading
- Claude Code: Credential management, Anthropic's docs on where credentials live and how
CLAUDE_CONFIG_DIRrelocates them.
That's the whole technique: one environment variable, two aliases, two accounts that never step on each other.