Quick start
Three steps, about a minute: install, add your accounts, turn it on. You need Node.js 20 or newer. It works on macOS, Linux and Windows.
-
Install Agent Switch.
Terminal window npm install -g @event4u/agent-switch -
Add each account once. Each command opens the provider’s own sign-in in your browser. Pick any names you like.
Terminal window agent-switch add workagent-switch add personalTerminal window agent-switch add work --provider codexagent-switch add personal --provider codexAlready signed in to Claude Code or Codex? See Keep the login you already have.
-
Turn it on. The shell wrapper makes
claudeandcodexstart on the right account. The background service keeps every account’s usage fresh, which is what lets Agent Switch balance your sessions.Terminal window agent-switch shellenv installagent-switch service installOpen a new terminal afterwards.
That’s it. Run claude or codex as always. Each start goes to the account
with the most to give, and you can ask why at any time:
agent-switch dir --jsonPrefer a window? Run agent-switch. The desktop app downloads on first use,
with no installer, and starts. See The desktop app.
Check that it worked
Section titled “Check that it worked”agent-switch status # every account, who it is signed in as, and its limitsagent-switch doctor # the CLI, the shell wrapper, every login, API keys that override oneagent-switch service status # the background service and when it last checked usagedoctor names anything that is wrong and the command that fixes it.
Keep the login you already have
Section titled “Keep the login you already have”import turns the login of your existing install into an account, with no new
sign-in:
agent-switch import personalThat account still shares its login with your default install. If both used it, whichever refreshed first would sign the other one out, so Agent Switch never picks a shared account for a balanced start and never refreshes it. Give it its own login once, and it takes part like every other account:
agent-switch login personalYour shell, by hand
Section titled “Your shell, by hand”shellenv install detects your shell and adds one line to its startup file. To
add it yourself:
Add to ~/.zshrc:
eval "$(agent-switch shellenv)"Add to ~/.bashrc (on macOS: ~/.bash_profile):
eval "$(agent-switch shellenv)"Add to ~/.config/fish/config.fish:
agent-switch shellenv --shell fish | sourceAdd to $PROFILE:
agent-switch shellenv --shell powershell | Out-String | Invoke-Expressioncmd.exe has no wrapper. Start a session on an account explicitly:
agent-switch run workThe line defines claude, codex and agy wrappers and the asw shortcut.
If Agent Switch is ever missing or broken, the wrappers fall straight through to
the real binary, so your tools keep working.