@event4u/agent-switch

中文文档
2.14.3发布于 2026/11/13MITES Module零依赖构建来源已验证近 30 天下载 4772

Claude Code, Codex and Antigravity accounts signed in side by side; each session starts on the one with the most left.

原始使用文档
文档目录14 节
  1. Sound familiar?
  2. Quick start — 60 seconds
  3. What you get
  4. Never log in twice
  5. Never waste a paid limit
  6. See everything, move anything
  7. How it fits together
  8. Your logins stay yours
  9. What works where
  10. Everyday commands
  11. Documentation
  12. Update and uninstall
  13. Contributing
  14. License

Agent Switch — one tool for all your AI accounts: Claude, Codex and Antigravity signed in side by side, every session on the account with the most left

Agent Switch

All your AI coding accounts, signed in side by side —
and every session on the one with the most left.

npm downloads CI Documentation License: MIT

Claude Code · Codex · Antigravity — macOS, Linux and Windows

Sound familiar?

  • "I keep logging out and back in to switch accounts." Every account stays signed in, side by side. Switching never logs anyone out.
  • "One account hits its limit mid-task while the other resets unused." Each new session starts on the account that would otherwise waste the most of its quota at its next reset.
  • "I never know which account has what left." The menu-bar app shows every account's 5-hour and weekly limit, live.
  • "Client work ends up on my personal account." Pin a folder to an account once, and every session started there uses it.

Quick start — 60 seconds

1. Install (Node 20 or newer):

npm install -g @event4u/agent-switch

2. Add each account once. Each one opens the provider's normal sign-in in your browser:

agent-switch add work
agent-switch add personal

3. Turn it on. This adds the shell wrapper and the background service that keeps usage numbers fresh:

agent-switch shellenv install
agent-switch service install

Open a new terminal and run claude as always. It starts on the account with the most to give. Want to see it? Run agent-switch: the desktop app opens, with no installer needed.

Terminal demo: two signed-in accounts; a new session goes to the account whose quota would expire first, and a client folder is pinned to the work account

Codex: add --provider codex to add. Already signed in to Claude Code? See keeping your current login.

What you get

Never log in twice

Each account gets its own folder with its own login, the way the provider intended. agent-switch only decides which folder the next session uses. It never copies, swaps or rotates a login. Nothing goes stale when you switch, and running sessions are never touched. With the background service, idle Claude logins are kept fresh without spending any quota.

Never waste a paid limit

With no folder rule, a new session is balanced across your accounts. It goes to the one that would lose the most of what is left at its next reset, so every plan gets used before it resets. An account at its limit is skipped. Folder rules pin a project to one account or to a group of accounts. Ask agent-switch dir --json for any folder, and it tells you which account it would pick and why.

See everything, move anything

Agent Switch desktop app: what needs you, what is running, and what every account has left

The desktop app and its menu-bar popover show every account's limits, every running session with its context %, and the one thing that needs you next. Move a session to another account and continue it there (takeover). On macOS you can even switch the account of a session that is still running (rebind), right now or when its current turn ends.

With agent-config installed, your agent asks you in the session before a limit, and the app asks the same question. Answer once, in either place; Agent Switch moves the work. It also asks earlier when your accounts run at different paces — one would run out well before its reset while another would let room expire — so the limits last the whole run. See Working with agent-config.

How it fits together

How Agent Switch fits together: Claude, Codex and Antigravity accounts feed one orchestrator with usage monitor, limit guard, session keep-alive and live rebind; it routes each task from the CLI, IDE or desktop app to the account with free capacity, runs it, monitors it and suggests a switch

Your logins stay yours

agent-switch is not a proxy and has no server, no account and no telemetry. Logins stay where the provider put them. Over the internet it only talks to:

  • the provider's own usage endpoint, with your own login;
  • GitHub, for releases and the desktop app download;
  • npm, for update checks of agent-switch's tools (the desktop app checks the claude and codex CLIs).

It switches a running session only when you confirm. What agent-switch reads, stores and sends →

What works where

Claude CodeCodexAntigravity
Several accounts signed in at once✅✅✅
Usage meters and balanced starts✅✅➖
Pin folders to accounts✅✅✅
Move a session to another account✅✅➖
Switch a running session's account✅ macOS➖➖
Logins kept fresh in the background✅➖➖

Antigravity accounts work with --provider antigravity. The desktop app shows Claude Code and Codex by default; show Antigravity there with agent-switch providers enable --provider antigravity. The core works on macOS, Linux and Windows, in zsh, bash, fish and PowerShell. The platform matrix lists every exception.

Everyday commands

asw                        # list your accounts (* = the one you prefer)
asw work                   # prefer "work" when the accounts are level
agent-switch run personal  # one session on "personal", whatever the balance says
agent-switch map work ~/code/client-a   # this folder always uses "work"
agent-switch status        # every account's limits
agent-switch doctor        # check the setup

The CLI reference lists every command.

Documentation

Update and uninstall

agent-switch update installs the latest version through npm. The desktop app updates itself. What changed in each version is in the release notes. agent-switch uninstall removes its profiles, their stored logins, the background service and the app launchers. Your default Claude Code, Codex and Antigravity installs are untouched. Remove the shellenv line from your shell's startup file yourself. Details →

Contributing

Issues and pull requests are welcome. To build from source:

npm ci && npm run build && npm link
npm test

The desktop app lives in gui/ (Tauri + React). The docs site lives in starlight/.

If agent-switch saves you a login or a wasted limit, a ⭐ on GitHub helps others find it.

License

MIT © event4u

版本与发布记录

@event4u/agent-switch 共发布 43 个版本,首次发布于 2026/07/21;过去 12 个月发布了 43 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.14.3latest2026/11/13今天
2.14.22026/11/13今天
2.14.12026/11/13今天
2.14.02026/11/121 天前
2.13.22026/11/077 天前
2.13.12026/11/067 天前

关于 @event4u/agent-switch 的常见问题

@event4u/agent-switch 是什么?

Claude Code, Codex and Antigravity accounts signed in side by side; each session starts on the one with the most left.

如何安装 @event4u/agent-switch?

在项目目录运行 npm install @event4u/agent-switch,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 agent-switch,可以用 npx agent-switch 直接运行。

@event4u/agent-switch 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/event4u__agent-switch 是否存在。

@event4u/agent-switch 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@event4u/agent-switch 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@event4u/agent-switch 可以商用吗?

@event4u/agent-switch 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@event4u/agent-switch 的下载量有多少?

根据 npm 官方下载统计,@event4u/agent-switch 在 2026/10/14 – 2026/11/12 这 30 天内被下载 4,772 次,日均约 159 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@event4u/agent-switch 还在维护吗?

最新版本 2.14.3 发布于 2026/11/13(今天);至今共发布 43 个版本,其中过去 12 个月发布了 43 个;首次发布于 2026/07/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。