AI TIP: Running Two Claude Code Accounts

How to use CLAUDE_CONFIG_DIR and bash aliases to run multiple Claude Code accounts simultaneously without logging out.

Running Two Claude Code Accounts on the Same Machine

If you have two Anthropic accounts, say, a personal one and a work one, you’ve probably hit the same wall I did: Claude Code only knows about one account at a time, stored in ~/.claude. Switching means logging out and back in every time you want to change contexts.

There’s a better way to do this.

The Solution: CLAUDE_CONFIG_DIR

Claude Code respects an environment variable called CLAUDE_CONFIG_DIR. When set, it tells the CLI to use that directory instead of the default ~/.claude for all its configuration and auth tokens.

That means you can keep two completely separate config directories, one per account, and switch between them instantly using aliases.

Setup

1. Your first account is already set up.

If you’ve used Claude Code before, your first account is already stored in ~/.claude. Nothing to change there.

2. Create a directory for your second account.

You can name it whatever you want, for this example, I’m using claude-account2.

mkdir ~/.claude-account2

3. Add aliases to your ~/.bashrc.

If you’re not using bash, you can do something similar for your shell of choice.

# Claude Code - multiple account isolation
alias claude1='CLAUDE_CONFIG_DIR=~/.claude claude'
alias claude2='CLAUDE_CONFIG_DIR=~/.claude-account2 claude'

4. Log in to your second account.

What I suggest here is to just use a simple claude2 command on your terminal. You’ll have the same setup that you probably did for your first account, choosing theme, type of account, etc. Or you can just log in directly.

claude2 auth login

This opens the browser login flow, the same as when you try to log in for the first time while installing Claude, but stores the resulting session in the new directory instead of the default one.

5. Reload your shell.

source ~/.bashrc

Using It

Open two terminal windows. In one, run claude1. In the other, run claude2. Each terminal will operate under its own account, with its own settings, projects, and auth, completely isolated.

No logging out. No switching. Just two terminals, two accounts, running side by side.

Why It Works

Claude Code stores everything that makes an account "yours", auth tokens, preferences, project history, inside its config directory. By pointing CLAUDE_CONFIG_DIR to a different path, you’re giving each alias its own isolated environment. The binary is the same; only the context changes.

You can extend this to as many accounts as you need. Just create a new directory, log in once with CLAUDE_CONFIG_DIR set to that path, and add an alias.

We want to work with you. Check out our Services page!