# Claude Account Switcher > CLI that runs several Claude Code accounts on one machine and picks one per directory, by setting CLAUDE_CONFIG_DIR before launching `claude`. Unix-like (macOS tested, Linux, WSL). Key facts for an assistant helping a user: - A profile is a name for a Claude Code config dir with its own login, or an alias of another profile's login (`same_as`). The profile using `~/.claude` runs with CLAUDE_CONFIG_DIR unset. - `claude` (a shell function installed by the tool) resolves the profile of the current directory: nearest mapped ancestor wins; symlinks, letter case and git worktrees resolve to the same answer. Unmapped: a picker asks once and remembers it at the repository root. - A running session cannot change account. Change the mapping (`claude-switcher use `), then exit and run `claude --continue`. - Login is interactive (browser OAuth): a new account is `claude-switcher add ` (logs it in), an expired login is `claude-switcher login `; the user runs either in their own terminal, or `/login` inside a session of that profile. Never run login for them. - Read state with `claude-switcher status --json` and `claude-switcher list --json`. Diagnose with `claude-switcher doctor` (also reports a newer release). Update with `claude-switcher update` (latest stable). - With the optional Claude Code plugin, a note at session start says which profile the session runs as and whether the folder maps to another; `/account-switcher:switch` shows or changes the mapping. - Config: `~/.config/claude-switcher/config.toml` (profiles, default, map). New accounts: `~/.local/share/claude-switcher/profiles/`. Per-folder pin: a `.claude-switcher` file holding a profile name. ## Docs - [Site](https://switcher.diananerd.com): guide and reference - [llms-full.txt](https://switcher.diananerd.com/llms-full.txt): this summary plus every doc page (guide, reference, how it works, comparison) in one plain-text file - [README](https://github.com/diananerd/claude-account-switcher/blob/main/README.md): install, setup, daily use - [Reference](https://github.com/diananerd/claude-account-switcher/blob/main/docs/reference.md): every command, file, variable, exit code - [AGENTS.md](https://github.com/diananerd/claude-account-switcher/blob/main/AGENTS.md): code map and invariants for contributors ## Install - `curl -fsSL https://switcher.diananerd.com | sh`, then `claude-switcher setup`. The installer also adds `csw`, a short name for `claude-switcher` (so `csw status`, `csw setup`); a cargo build has only the full name. - Uninstall: `claude-switcher uninstall [--purge]` --- # Claude Account Switcher Keep your Claude Code accounts apart, for work, personal or a side project, and let each folder decide which one `claude` uses. Every account stays logged in; you never `/logout` and `/login` again. > Unix-like systems only (macOS, Linux; Windows through WSL). **Tested on macOS.** > > Docs: ## Install ```sh curl -fsSL https://switcher.diananerd.com | sh ``` It shows what it will change and asks first. It also adds **`csw`**, a short name for the `claude-switcher` command; the examples below use it. ## Set up ```sh csw setup ``` Short steps: name the account Claude Code is already logged in to, add your other accounts (each logs in once in the browser), pick the default, and map your folders, for example `~/work` to your work account. ## Use Run `claude` as always. It uses the account of the folder you are in: ```text ~/work -> work (your work account) ~/work/side-project -> personal (an override for one folder) ~/personal -> personal ~/other -> asks once, then remembers ``` In a folder with no account yet, it asks once and remembers the answer: ```text ? Claude Code account for ~/other/new-idea › ❯ personal you@example.com work you@company.com + Add an account ``` Enter takes the default; type to filter; **+ Add an account** adds one on the spot. | Command | Does | | --- | --- | | `csw` | switch this project's account (asks which) | | `csw use work` | use `work` for this project; add a folder to map that one instead | | `csw status` | which account applies here, and why | | `csw add client` | add an account and log it in | | `csw list` | your accounts and their logins | | `csw login client` | log an account in again, e.g. when its login expired | | `csw remove client` | remove an account (keeps its login unless `--purge`) | | `csw doctor` | check everything (`--fix` repairs) | | `csw update` | update to the latest release | Sessions with different accounts run side by side, each in its own terminal; `csw run work` starts one with a given account without changing the mapping. Switching the account of the folder a session runs in moves that session too: ask Claude to switch (`/account-switcher:switch`) or run `csw use ` from inside it, and when Claude's reply ends the session restarts under the new account and carries on with the same conversation. Sessions started before 0.2.0, or outside the shell integration, keep their account: exit and run `claude --continue`. Every command also works in scripts: pass everything as arguments, `-y` to accept confirmations, `--json` for machine-readable output. ## Update and uninstall ```sh csw update # latest release, accounts kept csw uninstall # removes the tool, keeps accounts csw uninstall --purge # also removes the accounts it added ``` When a new release is out, commands you run in a terminal end with a notice. Each command shows what it will do and asks first; `-y` skips the question. ## Claude Code plugin Tells Claude which account each session runs as, and when that is not the folder's, and lets Claude show or switch the project's account (`/account-switcher:switch`). Moving a running session to another account needs it (0.2.0 or later); everything else works without it. One install serves every account. ```text /plugin marketplace add diananerd/claude-account-switcher /plugin install account-switcher@claude-account-switcher ``` To update or remove it: ```text /plugin marketplace update claude-account-switcher /plugin update account-switcher@claude-account-switcher /plugin uninstall account-switcher@claude-account-switcher ``` Before 0.2.1 the plugin was called `claude-switcher`, a name Claude Code now reserves. Once the marketplace is updated, the old plugin no longer loads (no session-start note, no live switching) until the new one is installed: ```text /plugin marketplace update claude-account-switcher /plugin install account-switcher@claude-account-switcher /plugin uninstall claude-switcher@claude-account-switcher ``` ## Status line To show the active account in Claude Code's status line, add this to your status line script: ```sh account=$(echo "$input" | claude-switcher statusline) # "work" or "work (here: personal)" ``` ## Limitations - Only launches through your shell are routed. The desktop app and IDE extensions use `~/.claude` unless started from a shell with the integration. - Only sessions launched through the shell integration (0.2.0 or later) switch account live, and only between accounts that share the conversation history (every account `csw add` creates does). Any other session relaunches with `claude --continue`. - Logging in uses whatever claude.ai account your browser is signed in to; switch there (or use a private window) before `csw add` or `csw login`. ## More - [Reference](docs/reference.md): every command, file, variable and exit code. - [How it works](docs/how-it-works.md): profiles, which account applies, the installer, building from source. - [Comparison](docs/comparison.md): other tools, and when to pick them. ## Status Provided as-is. There is no commitment to regular maintenance and no contribution process: issues and pull requests may go unanswered. For changes or customisation, fork it; [AGENTS.md](AGENTS.md) maps the code, and ```sh cargo test # unit tests tests/acceptance.sh # end-to-end, in a throwaway HOME (needs expect, jq, git) ``` check that a fork still behaves. ## License [MIT](LICENSE) --- # Reference ## Commands Every command works in two modes. - **Interactive**: a terminal on stdin and stderr, and no `--no-input`. Only what was not passed is asked, with the likely answer preselected. Confirmations default to no when they destroy something, to yes when they build something. - **Headless**: no terminal, or `--no-input` (also `CLAUDE_SWITCHER_NO_INPUT=1`). Nothing is asked. A missing answer is a usage error (exit 2) naming the argument or flag to pass; confirmations need `-y`. Global flags: `--no-input`, `-y/--yes` (answer yes to confirmations), `--json` (machine-readable output where supported). | Command | Does | JSON | |---|---|---| | `claude-switcher` | Terminal: pick this project's profile (current preselected), or create one, or more actions. No terminal: same as `status`. | via `status` | | `setup [--name N] [--no-shell]` | Interactive: five steps (name the existing login, add accounts and log them in, pick the default, map folders, add the shell integration). Headless: `--name` adopts `~/.claude` under that name and adds the shell integration (unless `--no-shell`). Both end with the next steps. | | | `use [profile] [dir] [--local]` | Map `dir` (default: the current project root) to a profile. Asks for the profile when omitted and a terminal is present. `--local` writes `dir/.claude-switcher` instead. Says the profile it replaces and where that came from; a folder that already uses the profile is a no-op that says so; warns when a closer setting still wins (a machine mapping of the same folder over `--local`, or, without `dir`, a mapping between the project root and the folder you are in). Inside a session whose folder it changes, it moves the session live (see below); otherwise it applies to new sessions. `claude-switcher [dir]` is a shorthand. | | | `forget [dir] [--local]` | Remove the mapping (or the `.claude-switcher` file) of `dir`, which may no longer exist. Nothing to forget (it only inherits, or has no mapping) is a no-op that says what applies instead. | | | `status [dir]` | Profile that applies, where it comes from, and the running session's profile when it differs. | yes | | `resolve [dir]` | Only the profile name (empty when none applies). | yes | | `map` | All mappings; flags deleted and unreachable folders. | yes | | `prune [--all]` | Drop mappings to deleted folders, also when the folders above them were deleted too. Unreachable ones (maybe on a volume that is not mounted: the nearest folder that still exists is `/Volumes`, `/media`, `/run/media`, `/mnt`, `/net` or `/Network` itself, or `/media/`; or the folder cannot be read) are kept unless `--all`. A mount point anywhere else (sshfs in your home) looks like an empty folder while unmounted, so what was mapped below it counts as deleted. Interactive: lists them and confirms. | | | `list [--check]` | Profiles, their account and flags. `--check` asks `claude auth status` for each login (slower, exact). | yes | | `default [profile]` | Show or set the profile offered first in a folder with no profile. Interactive without a profile: a picker on the current one (Enter keeps it). The first profile created is the default until another is picked. | yes | | `add [name] [--same-as P \| --base \| --dir D] [--no-login] [--email E]` | Add an account. No flag: its own login, logged in right away (browser OAuth) and verified. `--email` goes to `claude auth login` and implies its own login. `--same-as`: another name for P's login. `--base`: adopt `~/.claude`. `--dir`: adopt an existing config dir. Asks for missing parts in a terminal. | | | `login [profile] [claude auth login args]` | Log an existing account in again (a login expired, or you want another account behind the name): hands the terminal to `claude auth login`, then verifies with `claude auth status`. A name that is not an account yet offers to add it in a terminal; without one it fails with the `add` command to run. Warns when two accounts end up on one login, and when there is no terminal to paste a code into. For an alias, logs in its owner. `claude auth login` or `/login` run in a mapped folder log in that folder's account too. | | | `logout [profile]` | `claude auth logout` for that profile (and every alias sharing it). | | | `rename [old] [new]` | Rename (asks for what is missing); mappings, aliases and the default follow. The config dir keeps its path. `.claude-switcher` files are not rewritten. | | | `remove [profile] [--force] [--purge]` | Unregister. Refuses while aliases use it. Interactive: picks the profile, asks before dropping its mappings and whether to purge, then confirms (default no). Headless: `--force` (or `-y`) drops its mappings. `--purge` logs it out and deletes its config dir, only for dirs this tool created (needs `--yes` without a terminal); if the logout fails nothing is deleted. An adopted dir such as `~/.claude` keeps its files and login. | | | `run [profile] [args]` | Run claude with that profile once (asks which when omitted); the map is untouched. Everything after the profile goes to claude. | | | `doctor [--fix]` | Checks claude, the config, each profile's dir, shared links and login, duplicate accounts, deleted or unreachable mappings, ignored pins, PATH, shell integration. `--fix` relinks and prunes; interactive, it offers to. Exit 1 on errors. | yes | | `init zsh\|bash\|fish` | Print the `claude` shell function. | | | `shell install [shell] [--path-dir D] [--dry-run]` | Add the marked block to the rc file (idempotent). Asks for the shell when `$SHELL` does not say. `--dry-run` only reports the file it would change. | | | `shell uninstall` | Remove the block from every rc file. | | | `shell status` | Where the block is installed. | yes | | `completions ` | Shell completions (bash, zsh, fish, elvish, powershell). | | | `statusline` | Status line segment; reads Claude Code's status line JSON on stdin. | | | `hook session-start` | SessionStart hook: tells Claude which profile (and account email) the session runs as, and when its folder resolves to another profile. Silent for a session that is not a profile. | | | `hook stop` | Stop hook: records the session id and transcript for its supervisor and, when `use` asked the session to move, tells the supervisor, which moves it once the turn is over. Silent; a no-op outside a supervised session. | | | `update [--version TAG]` | Runs the official installer into this binary's folder: latest stable release, or TAG. Interactive in a terminal, `-y` otherwise. A copy owned by Homebrew or cargo (or a development build) gets that tool's command instead. | | | `uninstall [--purge]` | Shows the plan and confirms (default no; `-y` headless). Removes the shell integration and the binary. `--purge`: also log out and delete the profiles it created and its config file (other files next to it stay); stops before changing anything if a logout fails. | | ## Updates When a newer stable release exists, commands run in a terminal end with a notice on stderr: `info:` for a patch release, `warning:` for a minor one, `danger:` for a major one, with the command to update. Not shown without a terminal, in CI, with `--json`, for `statusline`, `hook`, `init`, `completions`, `resolve`, `run` and `claude` itself. The latest version is asked of GitHub at most once a day by a detached background process and cached in `$XDG_CACHE_HOME/claude-switcher/update.json` (default `~/.cache/...`), so no command waits on the network. `doctor` checks it live. Only stable releases count: GitHub's latest release excludes pre-releases, and release tags with a suffix (`v0.2.0-rc.1`) are published as pre-releases. Exit codes: `0` success, `1` error, `2` usage error (also for a missing argument without a terminal to ask for it), `130` cancelled at a prompt. ## Resolution For a directory, the first match wins across these chains, each walked from the directory up to `/`: 1. the path as reached (symlinks kept), each ancestor canonicalised; 2. the canonical path (symlinks resolved, on-disk letter case); 3. the canonical path of the repository's main worktree, if the directory is in a git repository. At each folder, a mapping in `config.toml` beats a `.claude-switcher` file. A file naming a profile that does not exist on this machine is ignored, with a warning at launch and in `doctor`. If `config.toml` cannot be read, `claude` still starts, exactly as without this tool, after a warning; `claude-switcher doctor` shows what is wrong. With no profiles at all (just installed), `claude` runs untouched and prints a pointer to `claude-switcher setup`. When `claude` runs in a directory where nothing matches: with a terminal, the picker asks (its **+ Add an account** entry adds and logs in a new account on the spot) and remembers the answer at the project root (the main worktree, or the folder itself outside git; never `$HOME` or above); without one (or with `-p`, `--print`, `--help`, `--version`) the default profile is used and nothing is remembered. ## Files | Path | What | |---|---| | `$XDG_CONFIG_HOME/claude-switcher/config.toml` (default `~/.config/...`) | Profiles, default, mappings. Mode 0600. | | `$XDG_DATA_HOME/claude-switcher/profiles/` (default `~/.local/share/...`) | Config dirs created for new accounts. Mode 0700. | | `$XDG_DATA_HOME/claude-switcher/run/.session`, `.transcript`, `.switch`, `.plugin` | A supervised session's id, where its transcript was when the last reply ended, the profile it was asked to move to, and the claude-switcher plugin it loaded. Removed when the session ends. | | `/.claude-switcher` | Optional pin: first non-blank, non-`#` line is a profile name. | | rc files | A block between `# >>> claude-switcher >>>` and `# <<< claude-switcher <<<`, edited in place; removal restores the file byte for byte. A start marker without its end marker is never touched. An existing `alias claude=` is replaced by the function, and `` becomes the claude it runs. Fish: `conf.d/claude-switcher.fish`. | `config.toml`: ```toml version = 1 default = "personal" created_in_base = ["agents", "commands", "hooks", "plugins", "sessions"] [profiles.personal] config_dir = "/Users/you/.claude" [profiles.work] config_dir = "/Users/you/.local/share/claude-switcher/profiles/work" [profiles.writing] same_as = "personal" [map] "/Users/you/work" = "work" "/Users/you/work/side-project" = "personal" "/Users/you/personal" = "personal" ``` Each profile has exactly one of `config_dir` or `same_as`. Map keys are canonical paths. `created_in_base` lists the folders the tool created in `~/.claude` for accounts to share; `uninstall --purge` removes those that are still empty. Writes are atomic and locked, so concurrent launches do not lose changes. A new account's config dir links these from `~/.claude`: the user-level configuration Claude Code documents (`settings.json`, `CLAUDE.md`, `keybindings.json`, `agents/`, `commands/`, `skills/`, `output-styles/`, `plugins/`), `hooks/`, and what lets a conversation continue under another account (`projects/`, `history.jsonl`, `file-history/`, `plans/`), and `sessions/`, Claude Code's list of running sessions, so sessions of every account see and can message each other. An account dir from before 0.2.0 gets its `sessions/` merged and linked at its next launch (or by `doctor --fix`). Files your settings point to by absolute path (a status line script, hook scripts) work from every account without linking. Its `.claude.json` starts with onboarding state, user MCP servers and project trust copied once from `~/.claude.json`. Credentials are never read or copied. ## Environment | Variable | Effect | |---|---| | `CLAUDE_SWITCHER_PROFILE` | Set by `launch` for the session: the profile name. | | `CLAUDE_CONFIG_DIR` | Set by `launch` for non-base profiles. If already set to a dir that is no profile's, `launch` leaves it alone. | | `CLAUDE_SWITCHER_CONFIG` | Use another config file. | | `CLAUDE_SWITCHER_BASE_DIR` | Dir whose settings new accounts share and that `--base` adopts (default `~/.claude`). Only `~/.claude` itself runs with `CLAUDE_CONFIG_DIR` unset. | | `CLAUDE_SWITCHER_SUPERVISOR` | Set by `launch` for a supervised session: the supervisor's pid. `use` and `hook stop` talk to it. Other launches remove it. It is believed only by a process the supervisor is an ancestor of, with at most one Claude Code session (as listed in `sessions/`) in between, so a claude started from inside the session (an agent's `claude -p`), which inherits it anyway, is ignored. | | `CLAUDE_SWITCHER_NO_SUPERVISE` | `1`: exec claude directly, as before 0.2.0; the session cannot switch live. | | `CLAUDE_SWITCHER_CLAUDE` | Path of the real claude binary (default: `claude` on PATH). | | `CLAUDE_SWITCHER_NO_INPUT` | Never prompt. | | `CLAUDE_SWITCHER_NO_UPDATE_CHECK` | No update notice, no update check in `doctor`. | | `CLAUDE_SWITCHER_UPDATE_URL`, `CLAUDE_SWITCHER_INSTALLER_URL` | Where the latest release and the installer are fetched from (mirrors, tests). | | `XDG_CONFIG_HOME`, `XDG_DATA_HOME`, `XDG_CACHE_HOME` | Standard locations. | Installer: interactive when a terminal is available (answers are read from `/dev/tty`, so `curl | sh` works): it downloads and verifies, shows the plan, offers Proceed / Customize (folder, rc file) / Cancel, and ends with the next steps, offering `setup` on a fresh install. Headless with `-y`, without a terminal, or with `CI` set. Flags: `-y`, `--bin-dir`, `--version`, `--no-modify-rc`, `--alias NAME` / `--no-alias`, `--uninstall`, `--purge`. The installer also adds a short command, `csw` by default: a relative symlink to `claude-switcher` in the same folder. It is never created over an existing file or over a command of that name elsewhere on PATH (the installer says so and suggests `--alias`). `uninstall` removes every link in the binary's folder that points to it, whatever its name, and nothing else. Variables: `CLAUDE_SWITCHER_BIN_DIR`, `CLAUDE_SWITCHER_VERSION`, `CLAUDE_SWITCHER_DOWNLOAD_URL` (mirror of the release assets). `NO_COLOR` turns colour off, here and in the binary. The installer's guarantees, each covered by the acceptance suite: - It shows what it found first: system and target, Claude Code, the installed version, another copy earlier on PATH, shell, PATH. - It checks all dependencies at once and names every missing one with how to install it; `wget` stands in for `curl`, `sha256sum` or `openssl` for `shasum`. - It refuses `sudo` (it would install into root's home), macOS older than 11, unsupported systems (Windows: use WSL) and folders it cannot write to, before touching anything. - Nothing changes until the binary is downloaded, matches its SHA-256 and runs. Errors say what happened, what to do, and "Nothing was changed" or how to finish. - Running it again converges: identical files, leftovers of an interrupted run cleared, one shell block. Release assets: `claude-switcher-.tar.gz` and `.sha256` for `aarch64-apple-darwin`, `x86_64-apple-darwin`, `x86_64-unknown-linux-musl`, `aarch64-unknown-linux-musl`. --- # How it works For the curious. You do not need any of this to use it. ## Accounts are config dirs Claude Code keeps its login and settings in a config dir, `~/.claude` by default, and uses another one when `CLAUDE_CONFIG_DIR` points to it. The login belongs to that dir (on macOS, the Keychain entry is keyed to it), so each dir is an independent account, and all of them stay logged in at once. - A **profile** is a name for a config dir: its own login, or another name for an existing profile's login (`--same-as`). - The login already in `~/.claude` becomes a profile as it is; nothing moves. That profile runs with `CLAUDE_CONFIG_DIR` unset, exactly as before. - Accounts you add live in `~/.local/share/claude-switcher/profiles/`. They hold their own login and link to your local setup in `~/.claude` (see below) instead of starting empty. - Each `claude` process gets its account's config dir in its own environment; there is no global login to swap. Sessions with different accounts therefore run in parallel without affecting each other. - The shell integration (a marked block in your rc file) defines a `claude` function. It finds the profile for the current folder and runs the real `claude` with that profile's config dir. ## What belongs where - **Your Claude account**, on Anthropic's side: the login, organization, plan, usage and claude.ai connectors. Each account keeps its own; nothing mixes them. - **The project**: its `.claude/` folder and `CLAUDE.md`, in the repository. They always belong to the project, whichever account runs it. - **Your local setup on this machine**: `settings.json`, your global `CLAUDE.md`, skills, agents, commands, hooks, plugins, and the conversation history kept per folder. It is not tied to any account: every account uses the same one, the way it would if you logged in and out. That is why a conversation carries on after you switch a project's account. ## Switching a running session Claude Code reads its account once, at start. So an interactive session runs as a child of `claude-switcher` instead of replacing it, and `claude-switcher use` run from inside that session (by you or by the plugin's skill) moves it: once Claude's reply ends, the plugin's Stop hook tells `claude-switcher`, which ends claude, puts the terminal back the way it was and resumes the same session (`--resume `, with the options it was started with, minus the prompt) under the new account. Switching back before the reply ends cancels the move. Claude Code runs Stop hooks in parallel, so `claude-switcher` does not end claude when its own hook fires: it waits until the transcript records that the turn is over, which Claude Code writes after every Stop hook has finished and not while a hook keeps Claude working. Your other Stop hooks always complete. The move needs the plugin at 0.2.0 or later, whose Stop hook says when the reply ends. With an older plugin, or none, `use` says so and the session keeps its account until you relaunch it. The plugin is installed once for every account (they share `plugins/`); update it in Claude Code with `/plugin marketplace update claude-account-switcher`, then `/plugin update account-switcher@claude-account-switcher` (before 0.2.1 it was called `claude-switcher`, which stops loading once the marketplace is updated: install `account-switcher@claude-account-switcher` and uninstall the old one). Ctrl-Z, signals and the exit status pass through unchanged. Print mode, background sessions and claude's own subcommands are not supervised; nor is anything launched with `CLAUDE_SWITCHER_NO_SUPERVISE=1`. ## Which account applies The nearest mapped folder wins, so a folder inherits its parent's account and can override it: ```sh csw use work ~/work # everything under ~/work csw use personal ~/work/side-project # except this folder ``` A folder resolves the same way however you reach it: through symlinks, in any letter case on case-insensitive disks, and from git worktrees that live outside their repository (they follow their repository). The exact rules are in the [reference](reference.md#resolution). A `.claude-switcher` file containing a profile name pins a folder too, and can be committed (`csw use --local`). The machine mapping wins over a file in the same folder, and a file naming a profile you do not have is ignored with a warning. ## The installer `curl -fsSL https://switcher.diananerd.com | sh` runs `install.sh` from the repository's main branch. - It shows what it found (system, Claude Code, any installed copy, shell, PATH) and checks every dependency before changing anything. - Nothing changes until the download matches its SHA-256 and runs. Every error says what happened, what to do, and whether anything changed. - Running it again is safe: it upgrades, reinstalls, downgrades on request, or finishes an interrupted install, and leaves the same files every time. - Options, after `sh -s --`: `-y` for no questions, `--version TAG`, `--bin-dir DIR`, `--no-modify-rc`, `--alias NAME` or `--no-alias` for the short command, `--uninstall [--purge]`. See `sh -s -- --help`. ## Building from source With Rust 1.88 or newer: ```sh cargo install --locked --tag vX.Y.Z \ --git https://github.com/diananerd/claude-account-switcher claude-switcher shell install && claude-switcher setup ``` A build installed this way has no `csw`; add one with `ln -s claude-switcher ~/.cargo/bin/csw`, or use the full name. --- # Comparison Several tools help you use more than one Claude Code account on one machine. They solve different problems. This page says which problem each one solves, so you can pick the right one, including when it is not this one. ## Who this tool is for People who keep separate Claude accounts **for separate purposes**: work, personal, a client, a side project. Each project always belongs to one of them, so the account should follow the project, fixed and without thinking about it. - **Per project, fixed.** Each folder maps to one account; subfolders inherit and can override. The same folder always gets the same account. - **Deterministic.** The nearest mapped folder wins, resolved the same way through symlinks, letter case and git worktrees. No state that depends on which account you used last. - **Good defaults.** In a folder with no account yet, `claude` asks once and remembers. Every login stays live, and every account uses your one local setup, so switching projects never means logging in or configuring again. It is **not** built for pooling several accounts to stretch rate limits, rotating accounts inside one project, or tracking usage and cost. If that is what you need, the tools below that focus on it will serve you better. ## Approaches | Approach | How the account is chosen | Examples | | --- | --- | --- | | Swap the global login | One login at a time; switching replaces it for the whole machine, running sessions included | claude-swap, cc-account-switcher, CCSwitcher, ClaudeCodeMultiAccounts | | Rotate for limits | Moves to another account when one hits its limit, often with usage dashboards | claude-swap, clauth, the fairy-pitta fork of cc-account-switcher | | Profile per launch | A config dir per profile; you pick it with an alias, a flag or a command each time | shell aliases, ccprofile, claude-account-switch (ftery0) | | Profile per folder | A config dir per profile, chosen by the folder you are in | claude-switcher, claude-code-profiles, cpm | ## Tools As of September 2026, from each project's own documentation. | Tool | Mechanism | Granularity | Focus | | --- | --- | --- | --- | | [claude-switcher](https://github.com/diananerd/claude-account-switcher) | One `CLAUDE_CONFIG_DIR` per account; the `claude` shell function picks it | Per folder, central mapping (plus optional pin files); asks once where unmapped | Separate accounts by purpose | | [claude-code-profiles](https://github.com/pegasusheavy/claude-code-profiles) | One `CLAUDE_CONFIG_DIR` per profile, set by a wrapper | Global, per shell, or per folder through a `.claude-profile` file and a cd hook | Separate accounts by purpose | | [cpm](https://github.com/JakubKontra/claude-profile-manager) | One `CLAUDE_CONFIG_DIR` per profile, a wrapper per profile | Per command, or per folder through a `.claude-profile` file and a cd hook | Separate accounts by purpose | | [claude-account-switch](https://github.com/ftery0/claude-account-switch) | One `CLAUDE_CONFIG_DIR` per profile | Per shell | Separate accounts by purpose | | [ccprofile](https://github.com/stebennett/claude-code-profiles) | Sets `CLAUDE_CONFIG_DIR` at launch | Chosen at each launch | Separate accounts by purpose | | [claude-swap](https://github.com/realiti4/claude-swap) | Swaps the default login (Keychain or credentials file); can run one session per account | Global, or per terminal | Rotation at rate limits, usage dashboard | | [clauth](https://github.com/uwuclxdy/clauth) | Swaps tokens, or runs a session in its own config dir | Global or per session | Rotation, usage and cost | | [cc-account-switcher](https://github.com/ming86/cc-account-switcher) | Swaps the Keychain login | Global | Switching (archived) | | [CCSwitcher](https://github.com/XueshiQiao/CCSwitcher) | Swaps the Keychain login and `~/.claude.json` | Global | Switching, usage and cost (macOS app) | ## How the per-folder tools differ claude-code-profiles and cpm share the idea of choosing the account by folder. The differences that matter day to day: - **Where the mapping lives.** They read a `.claude-profile` file in the project. claude-switcher keeps one central mapping, so nothing is added to your repositories; a pin file is optional, for teams that want it committed. - **A folder with no account yet.** claude-switcher asks once, with the default preselected, and remembers the answer for the whole repository. - **Resolution.** claude-switcher resolves a folder identically however you reach it: through symlinks, in any letter case on case-insensitive disks, and from git worktrees outside their repository. - **What each account uses.** With claude-switcher every account uses your one local setup (settings, skills, agents, commands, hooks, plugins, conversation history); only the login differs. Your accounts' own data, on Anthropic's side, is never mixed. - **Operations.** An installer that shows its plan and converges when run again, `doctor`, `update`, and every command usable both interactively and in scripts. ## Without a tool Claude Code already supports this through `CLAUDE_CONFIG_DIR`, which moves its config dir, login included. Two common recipes: - **An alias per account**, such as `alias claude-work='CLAUDE_CONFIG_DIR=~/.claude-work claude'`. You pick the account by hand each time, and each account starts from an empty setup. - **direnv**, with an `.envrc` exporting `CLAUDE_CONFIG_DIR` in each project. It switches when you cd, but every project needs its own file and a `direnv allow`, and folders without one get nothing. `CLAUDE_CODE_OAUTH_TOKEN` (from `claude setup-token`) and `ANTHROPIC_PROFILE` are aimed at scripts and at Console or API logins, not at keeping several Pro or Max accounts side by side.