Use Multiple Claude Code Accounts with CLAUDE_CONFIG_DIR

6 min read.
Tags: AIShellLocal configClaude Code

Multiple Claude Code accounts are easier to manage if each account has its own CLAUDE_CONFIG_DIR. That keeps login state, hooks, skills, MCP servers, settings, and CLAUDE.md files apart instead of mixing everything under the default ~/.claude.

Quick answer

Create one config folder per account:

mkdir -p ~/.claude-personal
mkdir -p ~/.claude-work

Add aliases to your shell config:

alias claude-personal='CLAUDE_CONFIG_DIR=$HOME/.claude-personal command claude'
alias claude-work='CLAUDE_CONFIG_DIR=$HOME/.claude-work command claude'

Reload your shell:

source ~/.zshrc

Then open each profile and log in once:

claude-personal
claude-work

After that, use claude-personal for your personal account and claude-work for your work account.

When separate Claude Code profiles are worth it

Use separate config folders when the accounts need different state:

  • personal and work accounts
  • client-specific setups
  • a clean test profile
  • different hooks, skills, MCP servers, or settings

Do not use this to work around account or subscription rules. If you have more than one Anthropic account, make sure that setup is allowed for your situation.

The practical benefit is simple: one profile can change without leaking into the other. Work can have work MCP servers. Personal can have experiments. A broken hook in one folder does not break every Claude Code session on the machine.

How CLAUDE_CONFIG_DIR separates multiple Claude Code accounts

By default, Claude Code uses ~/.claude for global user config.

That folder can include:

  • CLAUDE.md
  • settings.json
  • hooks
  • skills
  • agents
  • commands
  • plugins
  • local app data

When you start Claude Code with that variable set, Claude Code uses that folder instead of ~/.claude.

This:

CLAUDE_CONFIG_DIR=$HOME/.claude-work command claude

starts Claude Code with this config folder:

~/.claude-work

It does not install a second Claude binary. It only changes where that Claude process reads and writes its config.

Create the config folders

Use names you will still understand later:

mkdir -p ~/.claude-personal
mkdir -p ~/.claude-work
mkdir -p ~/.claude-client-a

Names like ~/.claude-account1 work, but they are easy to mix up. ~/.claude-work is harder to misread when you come back to it months later.

Start with empty folders unless you have a reason to copy old config. Copying the whole default folder into every profile can drag stale MCP servers, old hooks, and unrelated memory into places they do not belong.

Add aliases for zsh or Bash

For zsh, edit ~/.zshrc:

nano ~/.zshrc

Add:

alias claude-personal='CLAUDE_CONFIG_DIR=$HOME/.claude-personal command claude'
alias claude-work='CLAUDE_CONFIG_DIR=$HOME/.claude-work command claude'

Reload it:

source ~/.zshrc

For Bash, put the same aliases in ~/.bashrc:

nano ~/.bashrc
source ~/.bashrc

I prefer $HOME in the alias because it behaves predictably inside quotes. A tilde often works, but $HOME is clearer here.

Why the alias uses command claude

Use this:

alias claude-work='CLAUDE_CONFIG_DIR=$HOME/.claude-work command claude'

instead of this:

alias claude-work='CLAUDE_CONFIG_DIR=$HOME/.claude-work claude'

command claude tells the shell to run the actual Claude Code executable instead of another alias named claude.

That matters if you later add a guard alias:

alias claude="echo 'Use claude-personal or claude-work'"

With that prefix, the profile aliases keep working.

Log in to each account

Run the personal profile:

claude-personal

Log in with the personal account.

Then run the work profile:

claude-work

Log in with the work account.

Each one should store its auth and config under the folder from the alias. After that, the same alias should open the same account again.

Verify the active config folder

Because the alias sets the variable only for the Claude process, do the check from inside that Claude Code session. Ask Claude Code to run:

echo $CLAUDE_CONFIG_DIR

For the work profile, you should see something like:

/Users/you/.claude-work

You can also compare MCP config through the aliases:

claude-personal mcp list
claude-work mcp list

If the two profiles have different MCP servers, the output should differ.

If claude-work is not found, reload your shell or open a new terminal tab. That is usually what happened after editing your shell config.

Watch out for the default ~/.claude folder

You can launch a session with claude-work, but when you ask Claude Code to edit its own support files, a vague prompt may still send it toward the default folder.

These prompts are too loose:

Add this hook to my Claude config.
Create a new Claude Code skill for this workflow.
Update CLAUDE.md with this instruction.

They do not say which Claude config folder should change. The assistant may assume ~/.claude, especially because many examples use that default path.

When the task touches hooks, skills, settings, MCP config, or the global CLAUDE.md, name the folder:

Add this hook to my Claude Code work profile.
Use this config directory:
~/.claude-work

Do not modify ~/.claude.

For a skill, give the full path:

Create this skill under:
~/.claude-work/skills/my-skill/SKILL.md

Do not create it under ~/.claude/skills.

For a global profile instruction file:

Update the global CLAUDE.md for this Claude Code profile:
~/.claude-work/CLAUDE.md

Do not modify ~/.claude/CLAUDE.md.

For a project CLAUDE.md, use the repository path:

Update the project CLAUDE.md at:
/Users/you/dev/my-repo/CLAUDE.md

Do not update any global Claude Code config file.

It feels repetitive, but it saves time. The worst version of this bug is when Claude edits a real file successfully, just not the file your active profile reads.

When another tool launches Claude Code

Aliases only exist in your interactive shell. Tools that start Claude Code as a subprocess, like the Multica agent daemon, never load your shell config, so the alias means nothing to them. Set CLAUDE_CONFIG_DIR in that tool's own environment config instead.

I did exactly that on Multica, and both agents still ran on the same account. The variable was fine. The login was in the wrong place.

On macOS, Claude Code keeps credentials in Keychain, not in the config folder. The Keychain entry name ends with the first 8 characters of the SHA-256 hash of the config folder path:

no CLAUDE_CONFIG_DIR            -> Claude Code-credentials
CLAUDE_CONFIG_DIR=<full path>   -> Claude Code-credentials-<first 8 hex chars of sha256(path)>

So if you log out and back in with plain claude, the new login goes into the default entry. The entry for your profile folder still holds the old account, and every tool that launches Claude Code with that folder keeps using it.

Log in with the same variable the tool uses:

CLAUDE_CONFIG_DIR="$HOME/.claude-work" claude auth logout
CLAUDE_CONFIG_DIR="$HOME/.claude-work" claude auth login

Check which account that folder is on now:

CLAUDE_CONFIG_DIR="$HOME/.claude-work" claude auth status --text

And check that the Keychain entry exists for that exact path:

dir="$HOME/.claude-work"
name="Claude Code-credentials-$(printf '%s' "$dir" | shasum -a 256 | cut -c1-8)"
security find-generic-password -s "$name" >/dev/null && echo "found: $name"

The security command without -w or -g only checks that the entry exists. It doesn't print the token.

Keep profile files separate by default

I would keep these per profile:

  • credentials and auth state
  • settings.json
  • hooks
  • MCP server config
  • skills
  • account-specific memory

Copy individual files only when they belong in both profiles. A small utility skill might be fine in personal and work. A client-specific MCP server probably is not.

Common mistakes

Installing MCP servers into the wrong profile

This command uses whatever plain claude points to:

claude mcp add context7 -- npx -y @upstash/context7-mcp

For the work profile, run it through the work alias:

claude-work mcp add context7 -- npx -y @upstash/context7-mcp

Then check:

claude-work mcp list

Editing the wrong CLAUDE.md

There are usually two files people mean when they say CLAUDE.md:

  • project instructions: /path/to/repo/CLAUDE.md
  • global profile instructions: ~/.claude-work/CLAUDE.md

Tell Claude Code which one you want.

Forgetting to reload the shell

After editing ~/.zshrc, run:

source ~/.zshrc

or open a new terminal tab.

If claude-work returns "command not found", the alias is not loaded in that shell.

References

Final check

Use CLAUDE_CONFIG_DIR when you need multiple Claude Code accounts on the same machine. Make one folder per profile, launch Claude through aliases, verify the folder from inside the session, log in with claude auth login under the same variable any other tool uses, and name the exact config folder whenever Claude edits hooks, skills, settings, MCP config, or CLAUDE.md.