To use a work Claude account and a personal one on the same machine, give each account its own configuration directory with the CLAUDE_CONFIG_DIR environment variable. By default, Claude Code keeps everything in ~/.claude. When the variable is set, settings, session history, plugins and the login all live in the directory you name, so you stay signed in to both accounts at once. This is the method the official docs give for multiple accounts, and Claude Code has respected the variable everywhere since v1.0.6.
Each profile also gets its own user CLAUDE.md. If that file is new to you, start with what a CLAUDE.md file is.
What does each profile keep separate?
Everything that normally sits in ~/.claude moves into the profile’s directory. Files in the repository stay the same whichever account you use.
| Item | Location | Per profile |
|---|
User settings, CLAUDE.md and rules/ | <dir>/settings.json, <dir>/CLAUDE.md, <dir>/rules/ | Yes |
| Skills, agents, saved workflows | <dir>/skills/, agents/, workflows/ | Yes |
| Installed plugins | <dir>/plugins/ | Yes |
| Sessions and auto memory | <dir>/projects/<project>/ | Yes |
| Login | macOS Keychain, or <dir>/.credentials.json on Linux and Windows | Yes |
| Project files | The repo’s CLAUDE.md, .claude/ and .mcp.json | No |
| Managed settings | System directory, /Library/Application Support/ClaudeCode/ on macOS | No |
On macOS, Claude Code keys the Keychain entry to the configuration directory, so a session with a different CLAUDE_CONFIG_DIR reads a different entry. One exception from the docs is a Claude Console sign-in without an API key. Claude Code stores it outside the configuration directory, so two profiles don’t keep it apart.
Managed settings apply to both profiles. If your company sets forceLoginOrgUUID there, every claude.ai login has to belong to its organization, and your personal profile can’t sign in on that machine.
How do I switch with claude work and claude personal?
Add these two functions to your ~/.zshrc. This is the setup I use.
_claude_run() {
local profile="$1"; shift
case "$profile" in
work)
(
set -a; source ~/.config/claude/work.env; set +a # company LLM gateway
export CLAUDE_CONFIG_DIR="$HOME/.claude-work"
command claude "$@"
) ;;
personal)
(
unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY ANTHROPIC_MODEL
export CLAUDE_CONFIG_DIR="$HOME/.claude-personal"
command claude "$@"
) ;;
esac
}
claude() {
local profile
case "$1" in
work|personal) profile="$1"; shift ;;
*) PS3="Claude profile? "; select profile in personal work; do [[ -n "$profile" ]] && break; done ;;
esac
[[ -n "$profile" ]] && _claude_run "$profile" "$@"
}
Open a new terminal, then run claude work or claude personal. Anything after the profile name is passed through, so claude work -c continues the most recent work conversation in the current directory. Your personal sessions never show up there.
What does each part of the function do?
- The parentheses
( … ) start a subshell. Variables loaded or exported inside it are gone once Claude Code exits, so your terminal keeps nothing from the work profile.
command claude runs the real binary. Without command, the claude function would call itself.
set -a exports every variable defined while the file is sourced, and set +a turns that off again. The env file stays a plain list of NAME="value" lines.
select shows a numbered menu when the first argument is neither work nor personal. The rest of the line still goes through, so claude -c asks for a profile and then continues the conversation.
Why unset the ANTHROPIC_* variables in the personal profile?
Environment credentials win over your login. When several credentials are present, Claude Code picks ANTHROPIC_AUTH_TOKEN first, then ANTHROPIC_API_KEY, then an apiKeyHelper, and the subscription login from /login comes last. With a company token left in your shell, your personal requests would carry it, billed per token to your company instead of counting against your subscription.
ANTHROPIC_BASE_URL on its own doesn’t replace your login, but it still routes your requests through the company gateway. ANTHROPIC_MODEL is read before the model setting, so it would override the model you picked. If you also export CLAUDE_CODE_OAUTH_TOKEN, the long-lived token from claude setup-token, add it to the unset line, since it also ranks above /login.
Does your company give you a Team seat or a gateway?
The work branch depends on which. With a Claude for Teams or Enterprise seat, your work account is a claude.ai account like your personal one. A separate directory is all it needs, with no env file.
work)
(
unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_API_KEY ANTHROPIC_MODEL
export CLAUDE_CONFIG_DIR="$HOME/.claude-work"
command claude "$@"
) ;;
The first time you run claude work, Claude Code walks you through login and setup for the new directory. Pick the account your admin invited. Settings your company manages server-side only reach accounts signed in to its organization, which means this profile.
If your company goes through an LLM gateway or hands out an API key, keep the original branch and put the variables in a file outside any repository.
# ~/.config/claude/work.env
ANTHROPIC_BASE_URL="https://llm-gateway.example.com"
ANTHROPIC_AUTH_TOKEN="your-token"
ANTHROPIC_MODEL="model-your-company-provides"
Then lock it down with chmod 600 ~/.config/claude/work.env. ANTHROPIC_AUTH_TOKEN is for gateways that expect a Bearer token. If you were given an Anthropic API key, use ANTHROPIC_API_KEY instead.
How do I check which account is active?
Inside a session, /status shows the version, model, account and connectivity. When both a login and an API key are configured, it marks the one that isn’t in use.
The function passes subcommands through too, so you can check without opening a session.
claude work auth status --text
claude personal auth status
Without --text, the output is JSON with an authMethod field and, since v2.1.268, a configDirectory field naming the directory in use. To change the account inside a profile, run /login. /logout signs you out and resets that profile’s first-launch setup.
What about VS Code?
The extension starts the binary itself, so your zsh function doesn’t apply. In its settings, add CLAUDE_CONFIG_DIR to Environment Variables (claudeCode.environmentVariables) with an absolute path such as /Users/you/.claude-work. The extension doesn’t expand ~ and ignores a relative path. Since v2.1.284, it also passes the value to terminals that continue the chat.
How do I share instructions between profiles?
For guidance that holds in both accounts, write it in one shared file and put the same import line in ~/.claude-work/CLAUDE.md and ~/.claude-personal/CLAUDE.md.
@~/.config/claude/shared-instructions.md
Claude Code loads imports from a user CLAUDE.md without asking you to approve them.
Section 3.8 of module 3, Advanced configuration covers environment variables, and section 3.10 shows how to read /status when a setting doesn’t take effect. For the managed settings a company enforces on its machines, see section 10.9 of module 10, Team collaboration.