Claude Code Account Switch
Use different Claude Code accounts in different folders: a default account for every window, plus folder rules that force an account in a given folder. The status bar shows the account of the current window and the usage limits of all your accounts.
macOS only. On other platforms the extension does nothing.
Setup
Each account is a Claude Code config folder (CLAUDE_CONFIG_DIR profile):
~/.claude: the default profile;
~/.claude-<name>: one more folder per extra account. Log in once with CLAUDE_CONFIG_DIR=~/.claude-<name> claude, then /login.
The extension detects every ~/.claude* folder that holds a login.
Usage
Click the account in the status bar:
- Compte par défaut: the account used in every folder without a rule.
- Ce dossier: forces an account for the current folder and its subfolders, or removes that rule.
- Modifier les règles…: opens the rules file, for example to add a rule on a parent folder that holds many projects.
A change applies to Claude sessions started afterwards, and never touches other windows. Reload the window to restart the sessions already running in it.
The status bar shows a lock icon when a folder rule applies. The tooltip lists each account's 5-hour, 7-day and Opus usage, with reset times.
Rules file
~/.config/claude-account-switch/rules.tsv, one tab-separated line per rule:
default /Users/me/.claude-work
/Users/me/Documents/personal default
/Users/me/Documents/personal/client-x /Users/me/.claude-work
- The
default key sets the default account.
- The value
default means ~/.claude.
- A rule covers its folder and every subfolder. The longest matching folder wins.
Terminal
To make claude in the terminal follow the same rules, add this to ~/.zshrc:
claude() {
local wrapper="$HOME/.config/claude-account-switch/claude-wrapper.sh"
if [[ -x "$wrapper" ]]; then
"$wrapper" "$(whence -p claude)" "$@"
else
command claude "$@"
fi
}
What the extension changes
- It installs
~/.config/claude-account-switch/claude-wrapper.sh and sets it as claudeCode.claudeProcessWrapper. Claude Code then starts every session through it, and the wrapper picks CLAUDE_CONFIG_DIR from the rules.
- If
claudeCode.claudeProcessWrapper already points to another program, the extension leaves it alone. The rules then do not apply, and the status bar shows a warning.
- With a wrapper set, Claude Code does not track the process it starts, uses the
default permission mode when none is saved, and skips its update check.
- Versions up to 0.3.0 wrote
CLAUDE_CONFIG_DIR into claudeCode.environmentVariables, which applies to every window. 0.4.0 moves that value into the rules file as the default account and removes it from the setting.
- Usage is read with the OAuth token stored in the macOS Keychain for each profile. When a token has expired, the extension refreshes it and writes the new tokens back, so Claude Code stays logged in. No other server is involved.
Uninstalling
Clear claudeCode.claudeProcessWrapper in your user settings, then uninstall the extension. Until you clear it, the wrapper keeps applying the rules. Deleting ~/.config/claude-account-switch while the setting still points to it stops Claude Code from starting.
Settings
claudeAccountSwitch.extraProfileDirs: additional config folders to offer as accounts, besides the auto-detected ~/.claude* (~ is expanded).
Limits
- In a multi-root workspace, Claude Code runs in the first folder, so that folder's rule applies.
- The usage figures come from an undocumented endpoint and may stop working without notice.