Setting Up Multiple Claude Code Accounts
A practical guide to running two (or more) Claude Code accounts on the same machine — for example, a personal Max subscription and a work Enterprise account — without constantly logging in and out.
Why this works
Claude Code reads its configuration from a directory (default: ~/.claude) and a companion file (~/.claude.json). The path to that directory can be overridden with the CLAUDE_CONFIG_DIR environment variable. Give each account its own directory, point to it with a shell alias, and you get clean account isolation with zero extra tooling.
Prerequisites
- Claude Code already installed
- Bash or Zsh (instructions use
~/.zshrc; swap for~/.bashrcif you’re on bash) - At least one existing Claude Code login (we’ll migrate it)
Step 1 — Back up your current setup
Before touching anything, make a safety copy of your existing config. If anything goes sideways, you can restore in one command.
cp -r ~/.claude ~/.claude.pre-migration-backup
cp ~/.claude.json ~/.claude.json.pre-migration-backup
Step 2 — Migrate your current account into a named profile
Your existing ~/.claude is already logged into an account (let’s assume it’s your personal one). Instead of logging in fresh, just move it into a named slot so you keep all your history, skills, MCP servers, and CLAUDE.md.
# Move the config directory
mv ~/.claude ~/.claude-personal
# Move the companion JSON file into the new directory
mv ~/.claude.json ~/.claude-personal/.claude.json
Create an empty directory for the second account:
mkdir -p ~/.claude-work
Step 3 — Add the aliases
Open your shell config:
# Zsh
nano ~/.zshrc
# Bash
nano ~/.bashrc
Add these lines at the bottom:
alias claude-personal='CLAUDE_CONFIG_DIR=$HOME/.claude-personal command claude'
alias claude-work='CLAUDE_CONFIG_DIR=$HOME/.claude-work command claude'
Why command: it tells the shell to call the real claude binary directly, ignoring any alias named claude. Saves you from typing the full path.
Reload your shell:
source ~/.zshrc # or ~/.bashrc
Step 4 — Verify the personal profile
Launch it:
claude-personal
Inside Claude Code, run:
/status
You should see the email of your personal account. Your history, skills, and MCP servers should all be intact.
Step 5 — Set up the work profile
Launch the work alias — this will be a clean slate and prompt you to log in:
claude-work
Follow the browser-based login flow with your work account (SSO if Enterprise). Verify with /status once inside.
Then set up any work-specific MCP servers, skills, or CLAUDE.md as needed. They’ll live only in ~/.claude-work and won’t leak into your personal profile.
Troubleshooting
“Claude configuration file not found at: ~/.claude-personal/.claude.json”
This means .claude.json didn’t make it into the new config directory. The error message will point to a backup file inside ~/.claude-personal/backups/. Either:
Option A — if ~/.claude.json is still in your home directory:
mv ~/.claude.json ~/.claude-personal/.claude.json
Option B — restore from the backup the error mentions:
cp ~/.claude-personal/backups/.claude.json.backup.<timestamp> ~/.claude-personal/.claude.json
Then relaunch claude-personal.
Verify the env variable is set
If a profile seems to load the wrong config, check the env var is actually being exported:
CLAUDE_CONFIG_DIR=$HOME/.claude-personal
echo $CLAUDE_CONFIG_DIR
Optional — project-specific defaults
If a given repo should always use one account, drop a .env file at its root:
CLAUDE_CONFIG_DIR=/home/yourname/.claude-work
Now cd-ing into that project auto-routes to the right account (assuming your shell loads .env, or you run it through a tool that does).
Optional — visual indicator on launch
Avoid the “wait, which account am I on” moment by tagging each launch:
alias claude-personal='CLAUDE_CONFIG_DIR=$HOME/.claude-personal command claude; echo "🏠 personal"'
alias claude-work='CLAUDE_CONFIG_DIR=$HOME/.claude-work command claude; echo "💼 work"'
Cleanup
Once you’ve used both profiles successfully and nothing’s broken, you can delete the safety backups:
rm -rf ~/.claude.pre-migration-backup
rm ~/.claude.json.pre-migration-backup
Also safe to remove stale files Claude Code leaves behind in ~/:
rm ~/.claude.json.backup 2>/dev/null
rm ~/.claude.json.tmp.* 2>/dev/null
Notes on Enterprise accounts
If one of your profiles is an Enterprise seat:
- Audit logs and data retention policies apply at the org level. Running personal projects under your work profile means your employer gets the logs. Running work code under your personal profile bypasses the controls your admin set up. Be disciplined about which alias you type.
- MCP servers should use matching auth. Work GitHub, work Linear, work Gmail → configure them inside
claude-workonly. - API keys are separate. If your admin sets a spending cap, it only covers usage flowing through the Enterprise seat (Claude Code authenticated with your work login). API keys used in other tools hit a separate Console billing track.
Scaling to more accounts
Same pattern — add another directory and another alias:
mkdir -p ~/.claude-client-acme
alias claude-acme='CLAUDE_CONFIG_DIR=$HOME/.claude-client-acme command claude'
Reload shell, run it, log in. Done.