{"slug": "run-two-claude-code-accounts-side-by-side-without-logging-out-mac-windows-vs", "title": "Run two Claude Code accounts side by side without logging out (Mac, Windows, VS Code)", "summary": "A developer published a guide showing how to run multiple Claude Code accounts simultaneously on macOS, Linux and Windows by pointing the CLAUDE_CONFIG_DIR environment variable at separate config folders, avoiding repeated /logout and /login cycles. The approach uses shell aliases, PowerShell functions, tmux or terminal splits, and direnv so each project folder selects its own account, with `claude auth status` confirming which login is active. The author notes a macOS caveat (issue #92252) where setting the variable to the default path breaks Keychain lookup, and discloses a paid app, Claude Sessions Pro, that packages the same setup.", "body_md": "*Disclosure: I make [Claude Sessions Pro](https://doubleclaude.com/), a paid Mac and Windows app for running several Claude accounts at once. Everything below works without it. The app gets one section near the end, clearly marked.*\n\nYou have a work Claude account and a personal one. Maybe one per client. Claude Code signs in to one of them, and switching means `/logout`, `/login`, a browser tab, and losing your place. An hour later you do it again in the other direction.\n\nYou don't need to. Claude Code keeps everything about an account (the login, settings, history, MCP servers) in one folder, and you can point it at a different folder whenever you start it. Two folders, two accounts, both open at the same time in two terminals.\n\nThis guide covers the setup on macOS, Linux and Windows (PowerShell, cmd and Windows Terminal), how to run both side by side, how to let each project folder pick its own account, VS Code, CI, and the handful of things that quietly put both terminals on the same login. I checked the core of it (the alias, the PowerShell functions, the Windows Terminal profile, the tmux split, `auth status` and where MCP servers end up) on macOS and Windows 11.\n\n| You want | Do this | \n|---|---|\n| A second account in the terminal | `alias claude-work='CLAUDE_CONFIG_DIR=~/.claude-work claude'` , then run`claude-work` and sign in once | \n| The same on Windows | A small PowerShell function that sets `$env:CLAUDE_CONFIG_DIR` for one call (below) | \n| Both accounts on screen at once | tmux, an iTerm2 or Terminal split, or a Windows Terminal split pane | \n| Each project to use the right account | direnv, or a shell function keyed on the folder | \n| To check which account you're on | `claude auth status` | \n| To never confuse them | A status line or terminal badge that says WORK | \n| No terminal setup at all | [Claude Sessions Pro](https://doubleclaude.com/) , one app or window per account | \n\nWhen Claude Code starts, it looks at one environment variable, `CLAUDE_CONFIG_DIR`. If it isn't set, it uses `~/.claude`. That folder is the account, for practical purposes:\n\n`.credentials.json` file inside the folder.`settings.json`.`~/.claude.json`, which sits `~/.claude`, not inside it. When `CLAUDE_CONFIG_DIR` is set, Claude Code writes them to `.claude.json` `CLAUDE.md`, `skills/`, `agents/`, `commands/`.` projects/`, which is what `--resume` and `--continue` read.\nSo \"a second account\" is just \"a second folder\". Nothing is copied or patched, and your default setup isn't touched.\n\nPick a name. I'll use `~/.claude-work` throughout; one folder per extra account works the same way (`~/.claude-clientA`, `~/.claude-personal`).\n\nAdd this to `~/.zshrc` (or `~/.bashrc`):\n\n```\n# Default account: plain `claude`, ~/.claude\n# Work account: `claude-work`, ~/.claude-work\nalias claude-work='CLAUDE_CONFIG_DIR=\"$HOME/.claude-work\" claude'\n```\n\nOpen a new terminal and run it:\n\n```\nclaude-work\n```\n\nClaude Code doesn't find a login in the new folder, so it walks you through first-run setup and opens the browser. Sign in with the *other* account. That's the only time you'll do it. From now on `claude` is one account and `claude-work` is the other, and you can have both running at once.\n\nCheck that it worked:\n\n```\nclaude auth status\nclaude-work auth status\n```\n\nEach prints a small JSON block. Look at `email` and `configDirectory`: the first should show your default account and `~/.claude`, the second your work account and `~/.claude-work`. (` auth status` needs a recent Claude Code; run `claude update` if it isn't recognised.)\n\nIt's tempting to make things symmetrical with a second alias, `claude-personal='CLAUDE_CONFIG_DIR=~/.claude claude'`. Don't. On macOS, setting the variable *at all*, even to the default path, makes Claude Code look for a different Keychain entry, so your personal account suddenly appears signed out. It's tracked as [issue #92252](https://github.com/anthropics/claude-code/issues/92252). Leave your main account on plain `claude` with the variable unset, and give every *extra* account its own new folder.\n\nThe idea is the same, but PowerShell has no `VAR=value command` shorthand. If you just run `$env:CLAUDE_CONFIG_DIR = ...` and then `claude`, the variable stays set for every later command in that window, and the next plain `claude` is your work account too.\n\nThis function sets the variable for one call and puts it back afterwards, even if Claude Code exits with an error:\n\n``` php\nfunction claude-work {\n  $prev = $env:CLAUDE_CONFIG_DIR\n  $env:CLAUDE_CONFIG_DIR = Join-Path $HOME '.claude-work'\n  try { claude @args } finally { $env:CLAUDE_CONFIG_DIR = $prev }\n}\n```\n\nPut it in your profile so it's always there. `notepad $PROFILE` opens the file (create it if Notepad asks). Open a new PowerShell window, run `claude-work`, sign in with the second account, and check both with `claude auth status` and `claude-work auth status` as above. `@args` passes everything through, so `claude-work --resume` and `claude-work mcp list` work as you'd expect.\n\n**cmd.exe:** quote the whole assignment, or cmd keeps the space before `&&` as part of the folder name:\n\n```\nset \"CLAUDE_CONFIG_DIR=%USERPROFILE%\\.claude-work\" && claude\n```\n\nThis one does stay set for the rest of that cmd window, so use a dedicated window for it.\n\n**Windows Terminal profile.** If you'd rather have a \"Claude (work)\" entry in the new-tab menu, open Settings, then *Open JSON file*, and add a profile to `profiles.list`:\n\n```\n{\n  \"name\": \"Claude (work)\",\n  \"commandline\": \"powershell.exe -NoExit -Command \\\"$env:CLAUDE_CONFIG_DIR = Join-Path $HOME '.claude-work'; claude\\\"\",\n  \"startingDirectory\": \"%USERPROFILE%\",\n  \"tabTitle\": \"WORK\"\n}\n```\n\nThe variable only exists inside that tab, so every other tab is untouched. `-NoExit` keeps the window open when you quit Claude Code, so you can start it again with the same account by typing `claude`.\n\nOnce the folders exist, \"side by side\" is just two terminals.\n\n**tmux** (macOS and Linux). One command, two panes, one account each:\n\n```\ntmux new-session -s claude 'claude' \\; split-window -h 'CLAUDE_CONFIG_DIR=\"$HOME/.claude-work\" claude'\n```\n\nLeft pane: default account. Right pane: work. Each pane closes when you quit Claude Code in it.\n\n**iTerm2.** Settings, Profiles, duplicate your profile and name it \"Claude work\". Under General, set *Send text at start* to `export CLAUDE_CONFIG_DIR=\"$HOME/.claude-work\"`, and put `WORK` in *Badge*, which draws a large faint label behind the text. Now split a pane with that profile (right-click a pane, *Split Pane with Profile*).\n\n**macOS Terminal.** Settings, Profiles, duplicate a profile and name it \"Claude work\". On the Shell tab, tick *Run command* and *Run inside shell*, and enter `CLAUDE_CONFIG_DIR=\"$HOME/.claude-work\" claude`. A new window with that profile opens straight into Claude Code on the work account. Give the profile a different background colour while you're there.\n\n**Windows Terminal.** Hold **Alt** and click \"Claude (work)\" in the new-tab dropdown: it opens as a split pane next to the current one instead of a new tab. `Alt+Shift+-` and `Alt+Shift+Plus` split the current pane if you'd rather start from a plain shell.\n\nThe alias works, but you still have to remember which one to type. If your work repos all live under one folder, let the folder decide.\n\n**direnv** (macOS, Linux, WSL). Install it ([direnv.net](https://direnv.net/)), hook it into your shell, then in the root of your work folder:\n\n```\n# ~/work/.envrc\nexport CLAUDE_CONFIG_DIR=\"$HOME/.claude-work\"\n```\n\nRun `direnv allow` once. Now `cd ~/work/anything` sets the variable and leaving unsets it, so plain `claude` uses the right account in every repo below that folder. Add `.envrc` to your global gitignore if your repos are shared.\n\n**No direnv?** A shell function does the same check every time you start Claude Code:\n\n```\n# ~/.zshrc or ~/.bashrc\nclaude() {\n  case \"$PWD/\" in\n    \"$HOME/work/\"*) CLAUDE_CONFIG_DIR=\"$HOME/.claude-work\" command claude \"$@\" ;;\n    *)              command claude \"$@\" ;;\n  esac\n}\n```\n\n`command claude` calls the real binary rather than the function again. Add one line per client folder if you have more than two accounts.\n\n**PowerShell** can do the same inside the function from earlier:\n\n``` php\nfunction claude {\n  $prev = $env:CLAUDE_CONFIG_DIR\n  if ($PWD.Path -like (Join-Path $HOME 'work\\*')) {\n    $env:CLAUDE_CONFIG_DIR = Join-Path $HOME '.claude-work'\n  }\n  try { claude.exe @args } finally { $env:CLAUDE_CONFIG_DIR = $prev }\n}\n```\n\nIf `claude.exe` isn't found, check what `Get-Command claude -All` lists and call that name instead (npm installs a `claude.cmd`, so it's `claude.cmd @args` in that case).\n\nThe Claude Code extension has a setting for environment variables, `claudeCode.environmentVariables`, and it would be the obvious place for `CLAUDE_CONFIG_DIR`. The catch: it's a *machine-scoped* setting. VS Code ignores it in a workspace's `.vscode/settings.json`, so you can't give one project the work account and another the personal one this way. Set it in your user settings and it applies to every window. If you do set it there, use an absolute path; `~` isn't expanded.\n\nWhat does work per project is the integrated terminal. In the work project's `.vscode/settings.json`:\n\n```\n{\n  \"terminal.integrated.env.osx\": { \"CLAUDE_CONFIG_DIR\": \"/Users/you/.claude-work\" },\n  \"terminal.integrated.env.linux\": { \"CLAUDE_CONFIG_DIR\": \"/home/you/.claude-work\" },\n  \"terminal.integrated.env.windows\": { \"CLAUDE_CONFIG_DIR\": \"C:\\\\Users\\\\you\\\\.claude-work\" }\n}\n```\n\nNew terminals in that window get the variable, and `claude` run there uses the work account. VS Code asks you to trust the workspace before it applies terminal environment settings. Cursor and Windsurf read the same keys. JetBrains IDEs have the same idea under Settings, Tools, Terminal, *Environment variables*.\n\nTwo identical terminals with different accounts is a recipe for running the client job on your personal plan. Give the work folder a status line that says so. Create `~/.claude-work/statusline.sh`:\n\n``` bash\n#!/bin/sh\n# Claude Code pipes session info as JSON on stdin; we only need a label.\ncat > /dev/null\nprintf '\\033[44;97m WORK \\033[0m %s' \"$(basename \"$PWD\")\"\n```\n\nMake it executable (`chmod +x ~/.claude-work/statusline.sh`) and point the work folder's `~/.claude-work/settings.json` at it:\n\n```\n{\n  \"statusLine\": {\n    \"type\": \"command\",\n    \"command\": \"~/.claude-work/statusline.sh\"\n  }\n}\n```\n\nThe default account keeps its own `settings.json`, so only the work sessions show the blue WORK tag. Combined with a coloured terminal profile or an iTerm2 badge, you can tell them apart from across the room. And when in doubt, `/status` inside a session shows the account it's signed in to.\n\nA new folder starts empty: no `CLAUDE.md`, no skills, no agents. You probably want those to be the same everywhere. Symlink them:\n\n```\nln -s ~/.claude/CLAUDE.md ~/.claude-work/CLAUDE.md\nln -s ~/.claude/skills    ~/.claude-work/skills\nln -s ~/.claude/agents    ~/.claude-work/agents\nln -s ~/.claude/commands  ~/.claude-work/commands\n```\n\n(On Windows, `New-Item -ItemType SymbolicLink` does the same, but needs Developer Mode or an admin prompt. Copying the files is fine too.)\n\n**Never share or symlink** `.credentials.json`, `.claude.json` or the whole folder. Those hold the login and per-account state. Sharing them is how you end up with one account in both terminals, or each terminal signing the other one out.\n\n**MCP servers don't come along.** User-scope servers live in the account's own `.claude.json` (see the diagram), so the work account starts with none. Add them again through the work alias:\n\n```\nclaude-work mcp add --scope user --transport http notion https://mcp.notion.com/mcp\nclaude-work mcp list\n```\n\nProject-scope servers (a `.mcp.json` checked into the repo) are read from the repo, so they work for both accounts without doing anything.\n\n**Settings** can be shared by symlinking `settings.json`, but most people want the work one to differ, at least for the status line above.\n\nIf both `auth status` calls show the same email, one of these is almost always why.\n\n`ANTHROPIC_API_KEY` is exported in `~/.zshrc` or your Windows user environment, and you've approved it in Claude Code, it's used ahead of the subscription login in `claude setup-token` prints an OAuth token for CI. If you export it as `CLAUDE_CODE_OAUTH_TOKEN` globally, it also wins over `/login` in every folder. Same fix.`.claude/settings.json` or `settings.local.json` is ignored, because Claude Code has already chosen the folder by the time it reads them. It has to come from the environment: the alias, direnv, the terminal profile.`forceLoginOrgUUID`, which only allows sign-ins to the company's organisation, in any folder. If your personal login is refused on the work machine, that's policy, not a bug. Ask IT rather than working around it.`/logout` only signs out the folder you're in.\nSame idea in a pipeline: one token per account. On your machine, run `setup-token` with each account's folder:\n\n```\nclaude setup-token          # default account\nclaude-work setup-token     # work account\n```\n\nStore each token as a separate secret (`CLAUDE_CODE_OAUTH_TOKEN_PERSONAL`, `CLAUDE_CODE_OAUTH_TOKEN_WORK`) and map the right one to `CLAUDE_CODE_OAUTH_TOKEN` in each job. The runner never needs a config folder or a browser login.\n\nNone of this applies to the Claude Desktop app. It ignores `CLAUDE_CONFIG_DIR` and signs in to one account at a time, including in its Code tab. To use two accounts there, you're back to signing out and in, or running a second copy of the app with its own profile, which is fiddly to set up by hand. That's the gap the next section is about.\n\n*This is the product section mentioned at the top.*\n\nI built [Claude Sessions Pro](https://doubleclaude.com/) because I wanted my accounts side by side in the desktop app as well as the terminal, without maintaining aliases and profiles on two operating systems.\n\n`claude` with that profile's own config folder, and It's for accounts you already have, not a way to get more usage: each account keeps its own limits, and Anthropic's terms apply to each one. It runs on macOS 14 or later and Windows 10 and 11, costs **$15 once** for two computers, and has a free one-hour preview and a 14-day refund. It's an independent app, not made by or affiliated with Anthropic.\n\n[Try Claude Sessions Pro free for an hour →](https://doubleclaude.com/)\n\n| Symptom | Likely cause | Fix | \n|---|---|---|\n| `command not found: claude-work` | The alias or function isn't in the profile this shell reads | Check you added it to the right file ( `~/.zshrc` vs`~/.bashrc` , or`$PROFILE` ), then open a new terminal | \n| `claude-work` asks you to sign in again | The folder path changed (a typo, or a relative path that depends on where you are) | Use `$HOME/...` or a full path, and compare`configDirectory` in`claude-work auth status` | \n| Your main account looks signed out after setup | `CLAUDE_CONFIG_DIR` set to`~/.claude` (macOS) | Unset it; keep the main account on plain `claude` | \n| Both terminals show the same email | `ANTHROPIC_API_KEY` or`CLAUDE_CODE_OAUTH_TOKEN` exported | Remove it from your shell profile or user environment | \n| MCP tools missing in the work account | User-scope servers are per folder | Re-add with `claude-work mcp add --scope user ...` | \n| Work account has no `CLAUDE.md` or skills | New folder starts empty | Symlink or copy them from `~/.claude` | \n| PowerShell: every later `claude` is the work account | Variable set directly, not inside the function | Use the function with `try/finally` , or open a fresh window | \n| VS Code workspace setting has no effect | `claudeCode.environmentVariables` is machine-scoped | Use `terminal.integrated.env.*` per workspace, or user settings | \n| `--resume` doesn't show yesterday's session | It was started under the other account | Resume from the account (folder) you started it in | \n\n**Is running two accounts like this allowed?**\n\nYou're signing in to two accounts you already have, one per folder, instead of signing out and back in. Each account is still bound by Anthropic's terms and its own plan limits. Don't use extra accounts to get around a limit.\n\n**Do the usage limits combine?**\n\nNo. Each account has its own limits and its own usage, exactly as if you'd switched with `/logout`.\n\n**Can I run three or more?**\n\nYes. One folder and one alias (or one direnv folder) per account.\n\n**Does it work in WSL?**\n\nYes, the Linux instructions apply inside WSL. Note that WSL and Windows keep separate folders, so an account signed in on the Windows side isn't signed in inside WSL, and vice versa.\n\n**Will a Claude Code update break it?**\n\n`CLAUDE_CONFIG_DIR` is a documented setting, so it's been stable across updates. If something changes, `claude auth status` is the quickest way to see which folder a session is really using.\n\n**Can I move my existing history to the new account?**\n\nSession history is per folder. You can copy a project's folder from `~/.claude/projects/` to `~/.claude-work/projects/` to make it resumable there. Only do it when the conversation belongs with that account, for example work code moving to the work account.\n\nThe whole trick is one environment variable: a folder per account, and a way to start Claude Code with the right one. An alias on macOS and Linux, a small function on Windows, direnv if you want it automatic, a status line so you never guess. The rest of this post is the edge cases that bite after the first day.\n\nIf you'd rather have it done for you, in the terminal and in Claude Desktop, [Claude Sessions Pro](https://doubleclaude.com/) is $15 once, with a free hour to try it. There are longer write-ups on [running two Claude Code accounts in the terminal](https://doubleclaude.com/two-claude-code-accounts-terminal/) and [switching Claude Code accounts](https://doubleclaude.com/switch-claude-code-account/) on the site.\n\nIf you've hit a gotcha that isn't here, tell me in the comments and I'll add it.", "url": "https://wpnews.pro/news/run-two-claude-code-accounts-side-by-side-without-logging-out-mac-windows-vs", "canonical_source": "https://dev.to/sebastian_balog_c88dc2913/run-two-claude-code-accounts-side-by-side-without-logging-out-mac-windows-vs-code-56md", "published_at": "2026-10-24 20:06:22+00:00", "updated_at": "2026-10-24 20:13:12.383194+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents"], "entities": ["Claude Code", "Anthropic", "Claude Sessions Pro", "VS Code", "tmux", "direnv", "Windows Terminal"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/run-two-claude-code-accounts-side-by-side-without-logging-out-mac-windows-vs", "markdown": "https://wpnews.pro/news/run-two-claude-code-accounts-side-by-side-without-logging-out-mac-windows-vs.md", "text": "https://wpnews.pro/news/run-two-claude-code-accounts-side-by-side-without-logging-out-mac-windows-vs.txt", "jsonld": "https://wpnews.pro/news/run-two-claude-code-accounts-side-by-side-without-logging-out-mac-windows-vs.jsonld"}}