How to run two Claude accounts in parallel on the same machine

If you use Claude Code (the CLI) with multiple accounts — say, one for a personal project and another for a work project — you’ve probably run into the annoyance of having to log out and back in every time you switch. Here’s a quick way to run both accounts in parallel on the same machine using direnv.

Two Claude Code instances running side by side, each logged in to a different account

The problem

Claude Code stores its configuration (including your login session) in a single directory, ~/.claude, by default. This means you can only be logged in to one account at a time. If you work across two orgs or accounts, you’ll be constantly re-authenticating.

The solution

The CLAUDE_CONFIG_DIR environment variable lets you point Claude Code at a different config directory. Combined with direnv, which automatically loads environment variables when you cd into a directory, you get seamless per-project account switching.

Step 1: Install direnv

brew install direnv

Then add the hook to your shell. For zsh (the default on macOS), add this to your ~/.zshrc:

eval "$(direnv hook zsh)"

Step 2: Create a .envrc in your project

In the project folder where you want to use a different Claude account, run:

echo 'export CLAUDE_CONFIG_DIR=~/.claude-second-account' > .envrc

This tells Claude Code to use ~/.claude-second-account instead of the default ~/.claude for its configuration.

Step 3: Allow direnv

In that same folder, run:

direnv allow

This tells direnv to trust the .envrc file in that directory.

Step 4: Log in

The next time you start Claude Code in that folder, it will use the new config directory. Since it’s empty, you’ll be prompted to log in — just authenticate with your second account, and you’re done.

How it works

Every time you cd into the project folder, direnv automatically sets CLAUDE_CONFIG_DIR to your alternate config directory. When you cd out, it unsets it, and Claude Code goes back to using the default ~/.claude. No manual switching, no logging out, no friction.

You can repeat this pattern for as many accounts as you need — just use a different CLAUDE_CONFIG_DIR path for each project.