Categories
AI Anthropic Tutorials

Use Multiple Claude Accounts in Claude Code

A complete work + personal setup guide for Claude Code.

If you use Claude for both your job and your own projects, you have probably hit the same wall everyone does: Claude Code only keeps one account logged in at a time. Running /logout and /login every time you switch is tedious — and worse, your chat history, sessions, settings and plugins from both accounts end up mixed together in one place.

The good news: there is a clean, officially supported way to run multiple Claude accounts on the same machine, with each one keeping its own login, history, sessions, settings and plugins. This guide explains how it works, walks through the setup step by step, and — if you’d rather not do any of it by hand — gives you the exact prompt to make Claude Code set it all up for you.

In this guide

  1. How it works: the CLAUDE_CONFIG_DIR environment variable
  2. Step-by-step setup (work + personal)
  3. The easy way: let Claude Code set it up for you
  4. Frequently asked questions

How it works: the CLAUDE_CONFIG_DIR environment variable

Claude Code stores everything about your identity and usage in a single config directory — by default ~/.claude (on Windows, %USERPROFILE%\.claude). That directory contains:

  • Credentials — the OAuth token that keeps you logged in (.credentials.json; on Windows this is a file, not the Credential Manager)
  • Account and project state — .claude.json (which projects you’ve trusted, personal MCP servers, onboarding state)
  • History — every prompt you’ve typed (history.jsonl)
  • Sessions — full conversation transcripts per project (projects/), which is what claude --resume reads
  • Settings, plugins, skills and agents

The key insight is the CLAUDE_CONFIG_DIR environment variable. When it is set, Claude Code uses that directory instead of ~/.claude — for all of the above. So the whole trick is:

One directory per account. Give each Claude account its own config directory (e.g. .claude-work and .claude-personal) and point CLAUDE_CONFIG_DIR at the right one before launching. Each account stays logged in independently, and nothing — history, sessions, settings or plugins — ever mixes.

Because credentials live inside the directory, you log in to each profile once, and from then on switching accounts is just launching Claude Code with a different directory. No /logout, no re-authentication.

Step-by-step setup (work + personal)

The examples below are for Windows with PowerShell. The same approach works on macOS and Linux — the shell-profile equivalents are shown at the end of this section.

Step 1 — Create one config directory per account

If you are already logged in with one account (say, work), copy your existing config so that account keeps its login and history. Copying rather than moving leaves the original untouched as a safety net.

# Existing account (already logged in) keeps its data
robocopy "$HOME\.claude" "$HOME\.claude-work" /E

# Also copy the legacy state file into the new directory
Copy-Item "$HOME\.claude.json" "$HOME\.claude-work\.claude.json"

# Second account starts fresh
New-Item -ItemType Directory "$HOME\.claude-personal"

Step 2 — Add switching functions to your PowerShell profile

Open your profile file (create it if it doesn’t exist — check the path with $PROFILE) and add two functions. Each one sets CLAUDE_CONFIG_DIR only for that launch, so it never leaks into the rest of your terminal session:

function claude-work {
    $prev = $env:CLAUDE_CONFIG_DIR
    $env:CLAUDE_CONFIG_DIR = "$env:USERPROFILE\.claude-work"
    try { claude @args } finally { $env:CLAUDE_CONFIG_DIR = $prev }
}

function claude-personal {
    $prev = $env:CLAUDE_CONFIG_DIR
    $env:CLAUDE_CONFIG_DIR = "$env:USERPROFILE\.claude-personal"
    try { claude @args } finally { $env:CLAUDE_CONFIG_DIR = $prev }
}

Both functions pass arguments straight through, so claude-personal --resume or claude-work -c work exactly like the plain claude command.

Step 3 — Set a machine default (optional but recommended)

Anything that launches Claude Code without going through your functions — a bare claude command, or the VS Code extension — would otherwise fall back to the old ~/.claude. Set a persistent user environment variable so the default is your primary account:

[Environment]::SetEnvironmentVariable('CLAUDE_CONFIG_DIR',
    "$env:USERPROFILE\.claude-work", 'User')

Restart your terminal (and VS Code) for this to take effect.

Step 4 — Log in once per profile

  1. Open a new terminal and run claude-work — it should already be logged in (the credentials came over with the copy). Confirm with /status.
  2. Run claude-personal and complete /login with your second account. Done — it stays logged in from now on.

Step 5 — Verify the isolation

  • /status in each profile shows a different account email.
  • claude-work --resume and claude-personal --resume list different session histories.
  • Both accounts survive a reboot without asking you to log in again.

macOS / Linux equivalent

Same idea, in ~/.bashrc or ~/.zshrc. Setting the variable inline scopes it to the single launch:

cp -r ~/.claude ~/.claude-work        # keep the logged-in account's data
cp ~/.claude.json ~/.claude-work/.claude.json
mkdir -p ~/.claude-personal

claude-work()     { CLAUDE_CONFIG_DIR="$HOME/.claude-work"     claude "$@"; }
claude-personal() { CLAUDE_CONFIG_DIR="$HOME/.claude-personal" claude "$@"; }

Note for Mac users: macOS stores credentials in the Keychain rather than a file, so after copying the directory you may still need one /login in each profile.

The easy way: let Claude Code set it up for you

Here’s the part most guides miss: you don’t have to do any of this manually. Claude Code can inspect your machine, create the directories, migrate your existing data, write the shell functions and verify the result — you just describe what you want.

Open Claude Code and paste a prompt like this:

I want to use multiple Claude accounts on my machine. I have 2 accounts:
one for work and one personal. For work projects I want to use the work
account, for personal projects the personal account.

Please set this up using CLAUDE_CONFIG_DIR so that each account has:
- separate credentials (each stays logged in independently)
- separate history and sessions (the two accounts never mix)
- separate settings and plugins

My WORK account is the one currently logged in — keep its existing
history and settings. Create shell commands called claude-work and
claude-personal to switch between them, and make the work account the
default for anything that launches Claude Code directly.

Walk me through anything I need to do myself (like logging in to the
personal account) when you're done.

A few tips for getting the best result:

  • Say which account is currently logged in and whether its history should be kept — that decides which profile inherits your existing ~/.claude data.
  • Name the commands you want (claude-work / claude-personal, or whatever suits you). You can also ask for auto-switching based on the folder you’re in.
  • Ask for a plan first. Start Claude Code in plan mode (press Shift+Tab to cycle modes) so it presents the full approach for approval before touching anything.
  • You can go further. For example: “claude-work should have access to Project X only — move everything else to the personal profile”. Claude can split existing session history between the profiles, too.

Frequently asked questions

Can I be logged into two Claude accounts at the same time?

Yes. Each config directory holds its own credentials, so every profile stays logged in independently. You can even run both in different terminals simultaneously.

Doesn’t /login already support switching accounts?

/login and /logout switch a single profile between accounts, but everything else — history, sessions, settings, plugins — stays shared, and you re-authenticate on every switch. CLAUDE_CONFIG_DIR is the approach for genuine, persistent isolation.

What stays separate, and what is shared?

Separate per accountShared (lives with the project)
Login credentials, prompt history, session transcripts (--resume), settings.json, plugins, skills, agents, project trust decisionsCLAUDE.md, the project’s .claude/ folder, .mcp.json — these belong to the repository, not the account

Does this work with the VS Code extension?

Set CLAUDE_CONFIG_DIR as a persistent user environment variable (Step 3) and restart VS Code so the extension picks it up. To use the other account in the IDE, launch VS Code from a terminal where the variable points at the other directory.

Is this against Claude’s terms?

Using your own work and personal accounts on one machine is a normal, supported scenario — CLAUDE_CONFIG_DIR is a documented Claude Code environment variable. This is about keeping contexts separate, not sharing accounts.

Can I remove the old ~/.claude directory afterwards?

Yes — once you’ve confirmed both profiles work for a few days, the original ~/.claude (and ~/.claude.json) can be deleted. Until then it’s a free backup.