Claude Code has no built-in account switcher. If you have a personal subscription and an office one, the default flow is a tedious /logout then /login dance every time you change context. There's an open feature request for a proper switcher, but you don't have to wait for it.
Claude Code stores every credential, session, and setting under ~/.claude. Point it somewhere else with one environment variable and you get a second, fully isolated install. Two accounts, both logged in, side by side.
The one variable that does it
CLAUDE_CONFIG_DIR tells Claude Code which directory to read and write its state from. Override it and nothing touches your default ~/.claude.
The plan is simple:
- Give each account its own config directory.
- Wrap each one in a shell alias so you never type the variable by hand.
- Log in once per account. They both stay logged in indefinitely.
Generate your setup
Type your two account names, pick your shell, and copy the result straight into your shell config. The names become both the directory suffix and the command you'll run (claude-personal, claude-office, and so on).
# 1. Create a separate config dir per account
mkdir -p ~/.claude-personal ~/.claude-office
# 2. Append the aliases to ~/.zshrc so they survive new terminals (run once)
cat >> ~/.zshrc <<'EOF'
alias claude-personal='CLAUDE_CONFIG_DIR=~/.claude-personal claude'
alias claude-office='CLAUDE_CONFIG_DIR=~/.claude-office claude'
EOF
# 3. Load them into the current terminal
source ~/.zshrcIf you only want to eyeball the zsh version, here's the canonical shape. The whole block is safe to paste into your terminal in one go:
# 1. create separate config dirs
mkdir -p ~/.claude-personal ~/.claude-office
# 2. append the aliases to ~/.zshrc (run this once)
cat >> ~/.zshrc <<'EOF'
alias claude-personal='CLAUDE_CONFIG_DIR=~/.claude-personal claude'
alias claude-office='CLAUDE_CONFIG_DIR=~/.claude-office claude'
EOF
# 3. load them into the current terminal
source ~/.zshrc
The cat >> ~/.zshrc step is the one that matters. It writes the aliases into your shell config file, which is what makes them survive new tabs, new windows, and restarts. Typing an alias line directly into a terminal only defines it for that one session, and it dies when the terminal closes.
Log in once per account
Run each alias a single time and authenticate in the browser when prompted:
claude-personal # opens browser, log in with your personal account
Then, in a separate terminal tab:
claude-office # opens browser, log in with your office account
That's it. From now on, claude-personal and claude-office each open Claude Code with their own credentials, conversation history, and settings. No repeated logins.
Note
Because fish doesn't support inline VAR=value command syntax, the generator wraps the fish version in env. It also uses alias --save, which persists the alias as a fish function the moment you run it, so there's no config file to edit and nothing to reload.
Aliases gone after a restart?
This is the most common way the setup "breaks", and nothing is actually broken. The symptom: claude-personal worked right after setup, then a new terminal or a reboot greets you with command not found: claude-personal.
It means the alias lines were pasted into the terminal but never written to your shell config. Check with:
grep "claude-" ~/.zshrc
If nothing prints, the aliases were never saved. Re-run step 2 from the block above, then open a new terminal.
The good part: your logins are untouched. Credentials live in the config directories, not in the aliases, so as soon as the aliases are back both accounts work immediately. No need to log in again.
Note
Bash on macOS has an extra trap: Terminal opens login shells, which read ~/.bash_profile rather than ~/.bashrc. If your bash aliases vanish in new windows, append them to ~/.bash_profile instead, or have ~/.bash_profile source ~/.bashrc.
What's isolated, and what isn't
Each config directory is a complete, separate world. That's the upside and the catch.
| State | Shared between accounts? |
|---|---|
| Login / credentials | No, fully separate |
| Conversation history | No, per directory |
| Settings and preferences | No, per directory |
| MCP servers and connectors | No, set up per directory |
| Custom slash commands | No, per directory |
The practical consequence: anything you configure in one account, an MCP connector, a custom command, a tweaked setting, won't appear in the other. If you want the same MCP setup in both, copy the relevant files from one config directory into the other.
Warning
If your office account lives on a managed or company laptop, check whether IT policy allows a personal Claude account on the same machine. Nothing here stops you technically, but some endpoint policies restrict it.
Auto-switching per project (optional)
Two aliases are enough for most people. But if your work repos should always use the office account, you can stop thinking about which command to type and let the directory decide.
direnv sets environment variables automatically when you cd into a folder. Drop a .envrc in your work directory:
# ~/work/.envrc
export CLAUDE_CONFIG_DIR=~/.claude-office
Run direnv allow once, and every plain claude invocation inside that tree uses your office login. Step out of the folder and you're back to the default. It's a nice touch for monorepos where you never want to mix accounts by accident.
Tip
Keep a scratch file of which directory maps to which account and what you've configured in each. When the two setups drift, this saves you from debugging a "missing" MCP server that simply lives in the other config dir. A quick Online Notepad tab works for this.
When the switcher ships
Anthropic will likely add a native account switcher eventually, and when it does, this approach still won't hurt: separate config directories remain the cleanest way to keep two genuinely independent environments. Until then, one variable and two aliases get you there.
Set it up once. Forget about logging in again.
Tools in this post
Related Tool
Online Notepad
A free online rich text editor with file upload, download, and line numbering features. Edit text documents directly in your browser.
Try it freeWritten by
DebuggerMe TeamThe DebuggerMe team builds developer tools, writes technical content, and helps teams ship better software.
Related Articles
All articles →10 VS Code Extensions That Actually Make You a Better Developer
Skip the bloated extension packs. These 10 VS Code extensions have earned a permanent spot in my setup, each one solves a real problem, ships no junk, and earns its memory footprint.
The Honest State of AI Code Generation in 2026
Copilot, Claude, Cursor: AI code generation is genuinely useful now. But it's also genuinely overhyped in ways that set developers up for frustration. Here's an honest assessment after 18 months of daily use.
GPT-5.6: What Sol, Terra, and Luna Actually Mean for Developers
OpenAI shipped GPT-5.6 as a three-tier family: Sol, Terra, and Luna. Here's the pricing, the new caching rules, and which tier your workload actually needs.