How to use two Claude Code accounts on one Windows PC
You have a Claude subscription for work and one of your own. Signing out and in again every time you change projects gets old fast, and it is easy to start a long session on the wrong plan.
Claude Code has a documented answer: give each account its own configuration folder. This post sets that up on Windows, step by step, in PowerShell.
The short answer
Section titled “The short answer”Claude Code keeps everything for one account in one folder. By default that is %USERPROFILE%\.claude. The CLAUDE_CONFIG_DIR environment variable points it at another folder.
Anthropic’s authentication docs say: “To stay signed in to multiple accounts at once, such as work and personal accounts, give each account its own configuration directory.” Each directory “has its own settings, session history, and claude.ai login or API key”.
So the plan is:
- Keep your default account where it is.
- Make a second folder for the second account.
- Start
claudewithCLAUDE_CONFIG_DIRset to that folder when you want the second account.
Step 1: make a PowerShell function
Section titled “Step 1: make a PowerShell function”Anthropic’s example is a Bash alias. In PowerShell, “you cannot assign an alias to a command and its parameters”, and an alias cannot set a variable either, so use a small function. Open your profile:
if (-not (Test-Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force | Out-Null }notepad $PROFILEAdd this, then save:
function claude-work { $old = $env:CLAUDE_CONFIG_DIR $env:CLAUDE_CONFIG_DIR = "$HOME\.claude-work" try { claude @args } finally { $env:CLAUDE_CONFIG_DIR = $old }}What it does:
- Sets
CLAUDE_CONFIG_DIRonly whileclauderuns, then puts back whatever was there before. Plainclaudein the same window stays on your default account. - Passes every argument through with
@args, soclaude-work -p "hi"andclaude-work --resumework.
Open a new terminal so the profile loads. We tested this exact function shape in Windows PowerShell 5.1 and PowerShell 7: claude-work auth status reported the work folder, and the variable was gone again afterwards.
If PowerShell says running scripts is disabled, your execution policy blocks the profile. Microsoft’s about_Execution_Policies page explains the options. Changing it is your call.
Step 2: sign in to the second account
Section titled “Step 2: sign in to the second account”claude-work auth loginThis opens the normal sign-in flow, but saves the result in %USERPROFILE%\.claude-work. You can also just run claude-work. The docs say that the first time, “Claude Code walks you through login and setup for the new directory”.
claude auth login has a few useful options: --email fills in the address, --sso forces single sign-on, and --console signs in with an Anthropic Console account instead of a subscription.
Step 3: check who is who
Section titled “Step 3: check who is who”claude auth statusclaude-work auth statusThe output is JSON with loggedIn, email, orgName and configDirectory. The CLI reference says it “exits with code 0 if logged in, 1 if not”. Use --text for a human-readable version.
If both commands show the same email, you signed the second folder in to the same account. Sign out of it with claude-work auth logout and sign in again with the other account.
What the second account does not have yet
Section titled “What the second account does not have yet”The second folder starts empty. That means no:
- user
CLAUDE.md - personal skills, agents or slash commands
settings.json, hooks or permissions- plugins or MCP servers you added at user level
Project files are different. A repository’s own .claude\ folder, CLAUDE.md and .mcp.json live in the repository, so both accounts see them.
You can copy or link your setup into the second folder. Be careful with what you take: never copy .credentials.json or .claude.json, which hold the login and account state. The details, and what is safe to share, are in Share Claude Code skills between two accounts and CLAUDE_CONFIG_DIR explained.
Making it follow the folder
Section titled “Making it follow the folder”The function above is manual: you choose claude or claude-work. To pick the account by folder automatically, you need something that sets the variable for you:
- A PowerShell location hook. PowerShell 7 can run code each time you change folder. The open-source claude-acc tool works this way: it maps folders to accounts and sets
CLAUDE_CONFIG_DIRin your session when youcd. - A shim. A small program named
claude.exe, earlier on your PATH, that picks the folder and starts the real one.
A hook only runs in an interactive PowerShell session. AI agents, VS Code tasks and cmd.exe never see it. The trade-offs are in Shims or shell hooks?.
Things that can still pick the wrong account
Section titled “Things that can still pick the wrong account”- An API key in your environment. Claude Code uses
ANTHROPIC_API_KEY“instead of your Claude Pro, Max, Team, or Enterprise subscription even if you are logged in”. The docs list cloud provider credentials,ANTHROPIC_AUTH_TOKEN,ANTHROPIC_API_KEY,apiKeyHelperandCLAUDE_CODE_OAUTH_TOKENbefore the normal login. - Console sign-ins. The docs warn: “Separate directories don’t keep two Claude Console sign-ins without an API key apart, because Claude Code stores that kind of sign-in outside the configuration directory.”
- Editors and the desktop app. This method is for the
claudecommand in a terminal, including the VS Code terminal. The VS Code extension has aclaudeCode.environmentVariablessetting, and Claude Code 2.1.284 changed it soCLAUDE_CONFIG_DIRthere only applies when it is an absolute path. There is also an open report that the extension ignores the variable (#30538). Test it before you rely on it. The desktop app keeps its own login. - The same account twice. Each folder keeps its own copy of the login. There are open reports about logins being lost around token refresh with several config folders, for example #95822. One account per folder avoids the question.
How Devpit does the same thing
Section titled “How Devpit does the same thing”Devpit’s Accounts page does these steps with a preview and an undo. See Claude Code accounts.
- Open Accounts, then Claude Code, then + Sign in with another account…. Devpit runs Claude Code’s own
claude auth loginwith a new folder set, under%USERPROFILE%\.devpit\accounts\claude\<name>\, and shows each step live. You name the account at the end. If the email matches an account you already have, it warns you. - Choose where it applies: this folder, everywhere, just this once, or another folder. The preview says it in plain words, and the answer is already No.
- From then on, plain
claudepicks the right account by folder. Devpit adds a smallclaude.exeshim to a folder at the front of your user PATH. It only exists once a tool has a second account or a rule. On each call, it finds the nearest folder rule and starts the real Claude Code withCLAUDE_CONFIG_DIRset for that one process. Because it is a program, not a profile hook, it works for AI agents, VS Code tasks andcmd.exetoo. - For one command on another account,
devpit claude run <name> -- <command>does it once.
Devpit then asks one question about your setup: whether to share your skills, agents, commands and CLAUDE.md with the new account. Shared items are linked to your default ~/.claude, so they stay in one place.
What Devpit does not do: it stores no token (each login stays in its own account folder, where Claude Code put it), and its rules apply to claude in terminals, not inside editor extensions or the desktop app. A PowerShell function or alias called claude runs before any program on the PATH, Devpit’s shim included; Get-Command claude shows which one runs.
Checklist
Section titled “Checklist”- Leave
%USERPROFILE%\.claudealone. It is your default account. - Add the
claude-workfunction to your PowerShell profile. - Sign in with
claude-work auth login. - Check both with
claude auth statusandclaude-work auth status. - Make sure no
ANTHROPIC_API_KEYis set unless you want it. - Bring over your setup on purpose, never the login files.
Sources
Section titled “Sources”- Claude Code: Authentication (Log in with multiple accounts, credential storage, precedence)
- Claude Code: Environment variables (
CLAUDE_CONFIG_DIR,ANTHROPIC_API_KEY) - Claude Code: CLI reference (
claude auth) - Claude Code: The .claude directory
- Claude Code: VS Code
- Claude Code: Changelog (2.1.284)
- Claude Code issue #30538: VS Code extension ignores CLAUDE_CONFIG_DIR
- Claude Code issue #95822: short-lived commands and OAuth refresh
- Microsoft: about_Aliases
- Microsoft: about_Profiles
- Microsoft: about_Execution_Policies
Common questions
Can I sign the same Claude account in to two folders?
You can, but there is little reason to, and each folder then keeps its own copy of the login. There are open bug reports about logins being lost around token refresh when several config folders are in use, so use one folder per account.
Does this work in the VS Code extension or the desktop app?
The method is for the claude command in a terminal, including the VS Code terminal. The VS Code extension has its own claudeCode.environmentVariables setting, and there are open issues about the extension and CLAUDE_CONFIG_DIR. The desktop app keeps its own login.
Do I lose my chat history when I add a second account?
No. Your default account keeps its folder, %USERPROFILE%\.claude, untouched. The second account starts with an empty folder and its own history.
