How to Manage Multiple Claude Accounts on One Machine#
If you use Claude Code for both work and personal projects — or across multiple clients — you've probably hit the wall where logging in with one account logs you out of the other. Here's the clean fix I use every day.
The Problem#
Claude Code stores your login session, preferences, and config in a single directory: ~/.claude. That's fine when you only have one account. But if you're like me — with a work subscription through your company and a personal Pro account — swapping between them means constantly re-authenticating.
It's exactly the same frustration as juggling two AWS profiles or two GitHub accounts. The tool doesn't know which "you" you are right now.
The good news is there's a simple, clean solution that takes less than five minutes to set up.
The Fix: Isolated Config Directories#
Claude Code respects an environment variable called CLAUDE_CONFIG_DIR. When you set it, Claude uses that path instead of the default ~/.claude. So each account gets its own home.
Step 1: Create the directories#
mkdir -p ~/.claude-work
mkdir -p ~/.claude-personal
Name them whatever makes sense for your setup. I use work and personal, but you could do client-acme and client-beta if you're a consultant.
Step 2: Create shell aliases#
Open your ~/.zshrc (or ~/.bashrc if you're on bash) and add these:
alias claude-work='CLAUDE_CONFIG_DIR=~/.claude-work path/to/lib/claude'
alias claude-personal='CLAUDE_CONFIG_DIR=~/.claude-personal path/to/lib/claude'
alias claude="echo 'Use specific commands: claude-work or claude-personal'"
The last line is a safety net — it overrides the bare claude command so you never accidentally run in the wrong context. Instead of silently using whichever account was last logged in, it reminds you to be explicit.
Step 3: Reload your shell#
source ~/.zshrc
Step 4: Log into each account#
claude-work # logs you in with your work email
claude-personal # logs you in with your personal email
Each directory keeps its own session token, conversation history, and settings completely separate.
Verifying It Works#
Run type -a claude to see all the aliases and binaries registered under that name:
claude is an alias for echo 'Use specific commands: claude-work or claude-personal'
claude is path/to/lib/claude
If you see the alias listed first, you're good. The shell will hit the alias before it ever reaches the binary, so the safety net is actually working.
Why This Beats Logging In and Out#
A few reasons this approach is better than the naive alternative:
It's instant. No re-auth dance, no waiting for OAuth redirects. You pick the alias and you're in the right account.
Sessions stay warm. Each directory keeps its own credentials. Both accounts stay logged in simultaneously.
Settings are isolated. Work account gets work-specific MCP servers, memory, preferences. Personal account stays clean. No bleed.
It scales. Adding a third account is just another mkdir and another alias.
Adapting for Your Setup#
The binary path (path/to/lib/claude) will be different on your machine. Find yours with:
which claude
Use that output in your aliases instead of my path.
If you're on a team where everyone uses Claude Code, this same pattern works for shared machines — just have each person point CLAUDE_CONFIG_DIR to a path under their home directory.
That's It#
Honestly the hardest part of this setup is just remembering to use claude-work instead of claude. The override alias helps — muscle memory builds fast when the bare command talks back at you.
If you've been manually logging in and out every time you switch contexts, this will save you a surprising amount of friction over the course of a week.