2 min read
How to use Claude Code with multiple accounts via the CLI
One installation, two profiles. How to keep a personal and a work Claude Code account apart with nothing more than an environment variable and two shell aliases.
If you use Claude Code for both personal and work projects, switching between accounts can quickly become annoying. You may want to use your personal Claude account for your own projects while using a company account or API key for work.
A simple solution is to create separate Claude Code configurations and switch between them using shell aliases.
For example:
claude-personal
for personal projects and:
claude-work
for work.
Each profile has its own configuration and authentication, while Claude Code itself only needs to be installed once.
Two separate profiles
Claude Code stores its configuration in a user-specific directory. By using the CLAUDE_CONFIG_DIR environment variable, we can tell Claude Code which configuration directory to use.
Instead of using one shared:
~/.claude
we create two separate directories:
~/.claude-personal
~/.claude-work
Each directory effectively becomes its own Claude Code profile.
Setting up the aliases
On macOS, which normally uses Zsh, aliases can be added to:
~/.zshrc
On Linux with Bash, use:
~/.bashrc
If you're using Zsh on Linux, use ~/.zshrc as well.
Add the following:
alias claude-personal='CLAUDE_CONFIG_DIR="$HOME/.claude-personal" claude'
alias claude-work='CLAUDE_CONFIG_DIR="$HOME/.claude-work" claude'
After saving the file, reload your shell configuration:
source ~/.zshrc
or with Bash:
source ~/.bashrc
You can now use:
claude-personal
claude-work
Personal account
The first time you run:
claude-personal
Claude Code will use:
~/.claude-personal
If the directory doesn't exist yet, Claude Code will create it. You can then complete the normal login process for your personal account.
Future launches will continue using the same configuration.
Work account
The work profile works the same way:
claude-work
It uses:
~/.claude-work
On the first launch, you can log in with your work account or configure a different authentication method.
The two profiles are now completely separate:
~/.claude-personal
└── personal configuration and authentication
~/.claude-work
└── work configuration and authentication
Using an API key
If your work environment uses the Anthropic API, you can provide the API key through ANTHROPIC_API_KEY.
For example:
alias claude-work='CLAUDE_CONFIG_DIR="$HOME/.claude-work" ANTHROPIC_API_KEY="$ANTHROPIC_WORK_API_KEY" claude'
Claude Code will then use the work configuration together with the API key stored in the environment variable.
I would not put the actual API key directly into .zshrc or .bashrc. If the file is synchronized or committed to a repository, the key could easily be exposed. A password manager, secrets manager, or another secure mechanism is a better place to store it, with the alias only referencing the variable.
Using the profiles in practice
Switching between profiles is then just a matter of running the appropriate alias.
Personal project:
cd ~/Projects/my-project
claude-personal
Work project:
cd ~/Work/company-project
claude-work
There's no need to log out or manually change the configuration. Each alias starts the same Claude Code installation with a different configuration.
Why this is useful
The main benefit is keeping your personal and work environments separate. You don't have to worry about which account is currently active or repeatedly log in and out.
Claude Code is still installed only once. The alias simply sets a different CLAUDE_CONFIG_DIR and, if needed, ANTHROPIC_API_KEY before starting Claude Code.
The result is essentially two independent profiles:
Claude Code
│
├── Personal
│ └── ~/.claude-personal
│
└── Work
└── ~/.claude-work
Switching between them takes a single command:
claude-personal
or:
claude-work
For anyone regularly using Claude Code with multiple accounts, this is a simple way to keep personal and work environments cleanly separated.