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. Add these aliases to ~/.zshrc
alias claude-personal='CLAUDE_CONFIG_DIR=~/.claude-personal claude'
alias claude-office='CLAUDE_CONFIG_DIR=~/.claude-office claude'
# 3. Reload your shell
source ~/.zshrcIf you only want to eyeball the zsh version, here's the canonical shape:
# create separate config dirs
mkdir -p ~/.claude-personal ~/.claude-office
# add to ~/.zshrc
alias claude-personal='CLAUDE_CONFIG_DIR=~/.claude-personal claude'
alias claude-office='CLAUDE_CONFIG_DIR=~/.claude-office claude'
source ~/.zshrc
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. The behaviour is identical; only the syntax differs.
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.
React Server Components in Depth — What They Are and When to Use Them
React Server Components fundamentally change how we think about rendering. This guide breaks down how they work, how they differ from Client Components, and the patterns that will make your Next.js apps faster.