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
~/.claudebecomes a profile as it is; nothing moves. That profile runs withCLAUDE_CONFIG_DIRunset, exactly as before. - New profiles live in
~/.local/share/claude-account/profiles/<name>. They share your settings, skills, agents, commands, hooks, plugins, memory and conversation history with~/.claudethrough symlinks; only the login is separate. That is whyclaude --continuecan resume a conversation under another account. - The shell integration (a marked block in your rc file) defines a
claudefunction. It finds the profile for the current folder and runs the realclaudewith that profile's config dir.
Which account applies
The nearest mapped folder wins, so a folder inherits its parent's account and can override it:
csw use work ~/work # everything under ~/work
csw use personal ~/work/side-project # except this folderA 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.
A .claude-account file containing a profile name pins a folder too, and can be committed (csw use <profile> --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 --:-yfor no questions,--version TAG,--bin-dir DIR,--no-modify-rc,--alias NAMEor--no-aliasfor the short command,--uninstall [--purge]. Seesh -s -- --help.
Building from source
With Rust 1.88 or newer:
cargo install --locked --tag vX.Y.Z \
--git https://github.com/diananerd/claude-account-switcher
claude-account shell install && claude-account setupA build installed this way has no csw; add one with ln -s claude-account ~/.cargo/bin/csw, or use the full name.