Running Claude Code multiple accounts on one machine comes down to a single environment variable: CLAUDE_CONFIG_DIR. Point it at a separate folder before launching Claude Code, and that session gets its own credentials, settings, and history — so logging into a second account never kicks the first one out. Two terminals, two accounts, no logout loop.
That is the part every tutorial covers. What almost none of them mention is what happens after the alias works: your second config directory starts empty. No plugins, no MCP servers, no skills, no memory, no session history. And if you copy your hooks across without reading them, the two accounts can quietly start writing to the same state file.
This guide covers the setup in five minutes, then the four things that actually break — with the exact commands to check each one.
Key Takeaways
CLAUDE_CONFIG_DIRgives each terminal its own config directory, letting two Claude accounts stay logged in simultaneously.- The variable is not documented on Anthropic's official environment variables or settings pages, despite being widely used — treat it as unsupported-but-working.
- Everything that makes your setup yours — plugins, MCP servers, skills, hooks, memory, session transcripts — lives in the config directory, not with the account. A second directory starts empty.
- Hooks that hard-code
~/.claudewill cross-contaminate both accounts silently. Rewrite them to readCLAUDE_CONFIG_DIR.- Separate config directories do not give you more quota. Usage is per-account: if the same account is logged into both directories, both terminals drain one pool.
Why Claude Code Logs You Out of the Other Terminal
Claude Code stores your OAuth token in a single file: <config dir>/.credentials.json. There is one config directory per user by default (~/.claude, or %USERPROFILE%\.claude on Windows), so logging in as a second account overwrites the first account's token — including for a session that is already running in another window.
Identity is spread across two files, and it helps to know which is which:
| File | Contains | Safe to copy? |
|---|---|---|
<config>/.credentials.json |
OAuth token for the logged-in account | No — copying it clones the account |
<config>/.claude.json |
oauthAccount, userID, machineID, per-project history |
No — it is an identity profile |
<config>/settings.json |
Model, theme, hooks, enabled plugins | Yes |
<config>/projects/<slug>/*.jsonl |
Session transcripts | Yes — not tied to any account |
That last row matters more than it looks. Session transcripts are stored by project path, not by account. Log out, log in as someone else, run claude --continue in the same folder, and you resume the exact conversation the other account left behind. There is no per-account lock on local history.
How to Set Up Claude Code Multiple Accounts with CLAUDE_CONFIG_DIR
Set CLAUDE_CONFIG_DIR to a different path before launching Claude Code, then wrap it in a shell function so you never type it again. The whole setup is three steps and takes about five minutes, including the second login.
Step 1 — Create the second config directory
mkdir -p ~/.claude-work
Step 2 — Add a function to your shell config
On macOS or Linux, add this to ~/.zshrc or ~/.bashrc:
claude2() {
CLAUDE_CONFIG_DIR="$HOME/.claude-work" command claude "$@"
}
The VAR=value command prefix scopes the variable to that single invocation, so plain claude in the same shell still uses your default account.
Windows PowerShell has no inline environment-variable prefix, so you have to set and restore it explicitly. Add this to your $PROFILE:
$Global:Claude2ConfigDir = Join-Path $env:USERPROFILE '.claude-work'
function claude2 {
$hadPrevious = Test-Path Env:\CLAUDE_CONFIG_DIR
$previous = $env:CLAUDE_CONFIG_DIR
$env:CLAUDE_CONFIG_DIR = $Global:Claude2ConfigDir
try {
claude @args
} finally {
if ($hadPrevious) { $env:CLAUDE_CONFIG_DIR = $previous }
else { Remove-Item Env:\CLAUDE_CONFIG_DIR -ErrorAction SilentlyContinue }
}
}
Two details are worth stealing here. The finally block guarantees the variable is cleared even if you kill the session with Ctrl+C — without it, that window silently stays on the second account for every later command. And restoring uses Remove-Item rather than assigning an empty string, because in Windows PowerShell 5.1 an empty assignment leaves the variable present-but-blank instead of unset.
Step 3 — Log in and verify
claude2 # first run prompts for login
Then confirm the two directories really hold different tokens:
md5sum ~/.claude/.credentials.json ~/.claude-work/.credentials.json
Different hashes mean the isolation is working. Inside a session, /status shows which account that window is actually using — the only reliable check, since the command name tells you nothing about the account.
One caveat before you rely on it
CLAUDE_CONFIG_DIR does not appear in Anthropic's official environment variables reference, and the settings documentation describes ~/.claude as a fixed location with no mention of multiple accounts or profiles. We checked both pages in July 2026.
It works, thousands of developers use it, and it has been stable across releases. But it is undocumented, which means it carries no compatibility promise. Keep your setup in one shell function so that if a future release changes the behavior, you have exactly one place to fix.
What Does Not Carry Over to the Second Account?
Nothing carries over. A new CLAUDE_CONFIG_DIR is a completely fresh Claude Code environment — plugins, MCP servers, skills, hooks, memory, and session history all live inside the config directory, not with your account. On a mature setup that is hundreds of megabytes of state your second account cannot see.
Here is what a real, well-used config directory looks like versus what the second one inherits:
| Component | Stored at | Carries over? |
|---|---|---|
| Plugins + marketplaces | <config>/plugins/ |
No — reinstall |
| MCP servers | <config>/.mcp.json, .claude.json |
No — reconfigure |
| User skills | <config>/skills/ |
No — copy manually |
| Hooks | <config>/settings.json + script files |
No — copy manually |
| Permission allowlist | <config>/settings.local.json |
No — copy manually |
| Project memory | <config>/projects/<slug>/memory/ |
No — copy manually |
| Session transcripts | <config>/projects/<slug>/*.jsonl |
No — copy manually |
| Global instructions | <config>/CLAUDE.md |
No — copy manually |
Project CLAUDE.md |
Your repo | Yes — it is in git |
When we migrated a working setup, the portable pieces — global CLAUDE.md, settings, a 153-entry permission allowlist, one custom skill, hooks, and 35 memory files — came to 46 files and 0.13 MB. Everything else in that directory (332 MB of transcripts, 8.5 MB of plugin cache across 824 files) either cannot or should not be copied.
Plugins are the one thing you must not copy. The installed_plugins.json manifest records absolute install paths pointing back into the original directory, so a copied plugin folder resolves to the wrong location. Install them properly instead — and note there is a CLI form, which means you can script it:
claude plugin install superpowers@claude-plugins-official
claude plugin install context7@claude-plugins-official
claude plugin list
Child processes inherit CLAUDE_CONFIG_DIR, so running this inside a claude2 session installs into the right directory automatically. The official Anthropic-managed marketplace is added for you on first login — check plugins/known_marketplaces.json and you will find it already pointing at your new directory. Anthropic's plugin discovery docs cover the rest.
MCP servers deserve a mention too. Each Claude Code instance spawns its own MCP server processes rather than sharing them — on our machine, three concurrent sessions produced three separate context7-mcp process pairs. Two accounts means double the memory footprint and per-directory configuration. New to how those servers plug in? Start with our explainer on what MCP actually is.
The Hook Trap: When Two Accounts Silently Share State
This is the failure mode no other guide warns about, and it only appears if you copy your setup across — which is exactly what you will do.
Hooks are configured in settings.json, but the scripts they call are ordinary shell files that reference paths themselves. A typical session-state hook looks like this:
$stateFile = "$env:USERPROFILE\.claude\task_state.json"
Copy that script into your second config directory and the path still points at the first directory. Both accounts now read and write one state file. A session summary saved by account B gets injected into account A's next session. Nothing errors. Nothing logs a warning. The hook reports success every time.
The fix is to derive the path from the environment instead of hard-coding it:
$configDir = if ($env:CLAUDE_CONFIG_DIR) { $env:CLAUDE_CONFIG_DIR } else { "$env:USERPROFILE\.claude" }
$stateFile = Join-Path $configDir 'task_state.json'
The fallback keeps your original account's behavior byte-for-byte identical while making the script relocatable. Audit every hook script and every helper tool you have written for a hard-coded ~/.claude. In our case that included a memory-sync script that would have kept syncing to the wrong account forever while printing "Done".
Does Running Two Accounts Double Your Usage Limit?
Only if the two directories hold two different accounts. CLAUDE_CONFIG_DIR isolates credentials, not quota. Limits are enforced per account, so logging the same account into both directories means both terminals drain a single pool — you get parallel windows, not extra capacity.
Anthropic enforces limits in two layers: a rolling 5-hour window for short bursts, and a weekly cap on active Claude Code hours. Per published limit breakdowns, the current shape looks like this:
| Plan | Per 5-hour window | Claude Code per week |
|---|---|---|
| Max 5x ($100/mo) | ~225 messages | 140–280 hours |
| Max 20x ($200/mo) | ~900 messages | 240–480 hours |
Two more facts change how you should think about this. Anthropic doubled the 5-hour limits for Pro, Max, Team and seat-based Enterprise plans on 6 May 2026, and removed the peak-hours reduction for Pro and Max. And Pro/Max usage is a shared pool across Claude chat and Claude Code — a heavy morning of chat leaves less for your agent in the same window.
The practical consequence: terminal count costs nothing. An idle terminal consumes zero. What burns quota is work volume. Splitting one task across two sessions is actually slightly more expensive than doing it in one, because each session reloads its own context and warms its own prompt cache. Running parallel agents is about wall-clock speed, not efficiency — the same trade-off we covered in our look at parallel AI coding agents.
Sequential Failover or Parallel Sessions: Which Do You Actually Need?
Most developers reaching for this setup want one of two very different things, and the right configuration differs.
| Sequential failover | True parallel sessions | |
|---|---|---|
| Goal | Keep working when one account hits its limit | Two workstreams at once |
| Config dirs | One is enough | One per terminal |
| Resume old session | Works — claude --continue |
Transcripts are not shared |
| Extra quota | Yes, you switch pools | Yes, if different accounts |
| Main risk | None | Two agents editing one repo |
If you only need failover, you may not need CLAUDE_CONFIG_DIR at all — /logout, /login, and claude --continue in the same directory resumes your session, because transcripts are account-agnostic. The catch is that this only works safely when no other session is using that same directory, since the login rewrites the shared credentials file.
If you want genuine parallelism, separate directories solve authentication and nothing else. Two agents pointed at one repository can still overwrite each other's edits, collide on git operations, and share the same database. Give each session its own git worktree and split work by area. Claude Code's position as the leading AI coding tool has made multi-session workflows common, but the isolation stops at the config directory.
Frequently Asked Questions
Can I use two Claude accounts on the same computer?
Yes. Set CLAUDE_CONFIG_DIR to a different directory for each terminal before launching Claude Code, and both accounts can stay logged in at the same time. Without it, the second login overwrites the first account's token because both share one credentials file.
Is CLAUDE_CONFIG_DIR officially supported by Anthropic? It is not documented. As of July 2026 the variable does not appear in Anthropic's official environment variables reference or its settings documentation, even though it works reliably and is widely used. Treat it as a stable community convention rather than a supported API, and keep your setup in one place so a future change is easy to patch.
Do plugins and MCP servers carry over between config directories?
No. Both are stored inside the config directory, so a new directory starts with none. Plugins in particular cannot be copied, because their manifest records absolute install paths — use claude plugin install <name>@<marketplace> instead. MCP servers must be reconfigured, and each running instance spawns its own server processes.
Does running two Claude Code accounts double my usage limit? Only if the two directories are logged into two different accounts. Limits are per account, so the same account in both directories shares one pool. Opening extra terminals costs nothing by itself — quota is consumed by work volume, not by window count.
How do I switch Claude Code accounts without losing my current session?
Run /logout then /login in the same terminal, then claude --continue in the same project folder. Session transcripts are stored per project path inside the config directory and are not tied to an account, so the new account resumes the previous conversation. Do this only when no other session is using that config directory.
Is it allowed to use two Claude accounts? Using two subscriptions you personally hold — for example a work account and a personal one — is a normal setup. Sharing a single subscription between people is a different matter and is governed by Anthropic's usage policies, so check those before rolling this out across a team.
The Verdict
CLAUDE_CONFIG_DIR is the correct answer to "how do I stop my two accounts fighting", and it takes five minutes. But treat the alias as step one of three. Step two is rebuilding the environment in the new directory — plugins via the CLI, then skills, hooks, permissions, and memory copied by hand, while leaving .credentials.json and .claude.json strictly alone. Step three is auditing every hook and helper script for a hard-coded ~/.claude, because that failure is silent.
Be honest about which problem you are solving. If you just want to keep working after hitting a limit, plain /logout and /login with claude --continue is simpler and loses nothing. Reach for separate config directories when you genuinely need two accounts alive at once — and remember that isolating credentials does nothing to isolate your files, your git history, or your database. Before committing to a second subscription, our breakdown of Claude Opus 5's benchmarks and pricing is worth a read.
Configure it once, script it, and stop thinking about logins.