Skip to content

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.

  1. Install Agent Switch.

    Terminal window
    npm install -g @event4u/agent-switch
  2. 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 work
    agent-switch add personal

    Already signed in to Claude Code or Codex? See Keep the login you already have.

  3. Turn it on. The shell wrapper makes claude and codex start 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 install
    agent-switch service install

    Open 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:

Terminal window
agent-switch dir --json

Prefer a window? Run agent-switch. The desktop app downloads on first use, with no installer, and starts. See The desktop app.

Terminal window
agent-switch status # every account, who it is signed in as, and its limits
agent-switch doctor # the CLI, the shell wrapper, every login, API keys that override one
agent-switch service status # the background service and when it last checked usage

doctor names anything that is wrong and the command that fixes it.

import turns the login of your existing install into an account, with no new sign-in:

Terminal window
agent-switch import personal

That 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:

Terminal window
agent-switch login personal

shellenv install detects your shell and adds one line to its startup file. To add it yourself:

Add to ~/.zshrc:

Terminal window
eval "$(agent-switch shellenv)"

The 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.