自動切換帳號
本頁由英文版機器翻譯而成,歡迎協助修正。 在 GitHub 上編輯這一頁
設定 auto_switch = true(Linux 和 macOS)後,Claude Code 因用量限制而停止工作階段時,ccam 會自行把工作階段移到另一個帳號,不需要你下任何指令,對話就會在那裡繼續。這項功能預設關閉,屬於實驗性功能,開啟後可能違反你所用方案的條款(見下文)。沒有開啟時,請自己用 ccam next --continue 或 /ccam:switch 切換(達到限制時繼續工作)。
ccam: personal hit its 5-hour limit; continuing this conversation as side
→ personal → side
continuing "Fix the flaky tests" (about 182k tokens); prompt caches are not shared between organizations, so the first reply reads it all again; side does not share personal's history, so Claude Code copies it into sideTeam 和 Enterprise 席位。 在 Team 和 Enterprise 席位上,auto_switch 會把你的工作移到同一個組織的另一個席位,這可能違反 Anthropic 的條款。依賴這項功能之前,請先閱讀常見問題,並向你所屬的組織和 Anthropic 確認。
開啟方式
在每個帳號中開啟 ccam 外掛,並使用 Claude Code 2.1.214 或更新版本;這些版本會把自己的行程 ID 傳給外掛的 hook(
CLAUDE_PID)。在
config.toml的最上方、第一個[[group]]、[[profile]]或[[folder]]之前加入這項設定:# ~/.config/ccam/config.toml auto_switch = true # Linux and macOS; turns the relay on too透過 ccam 啟動新的工作階段:
ccam <name>、快捷指令或儀表板。auto_switch會開啟接力,讓 ccam 在每個互動式工作階段旁持續執行,而不是以 Claude Code 取代自己。這樣每個工作階段都要多一個等待中的 ccam 行程。執行
ccam doctor。開啟auto_switch期間,它會對沒有 ccam 外掛的帳號和早於 2.1.214 的 Claude Code 版本發出警告;如果有席位,還會重述 Anthropic 的席位規定(檢查項目)。
在 Windows 上,ccam 會忽略這項設定,ccam doctor 也會說明這一點。不過在 Windows 上設定 relay = true 時,仍然可以用 /ccam:switch 和 /exit 把對話移到另一個帳號。
達到限制時會發生什麼事
- Claude Code 因用量限制而停止某一輪。外掛的 hook 會挑出另一個還有額度的帳號,並結束 Claude Code。
- 在工作階段旁執行的 ccam 會在支援的終端機中顯示桌面通知,例如
ccam: personal hit its 5-hour limit (resets 3:29am). Moving this conversation to side (12% of its 5 hours used, the least). - ccam 印出上方範例的第一行,並以選中的帳號為這個工作階段執行
ccam next --continue。後者會印出另外兩行,再像接力一樣,沿用工作階段的選項、權限模式、推理強度和代理啟動 Claude Code。 - 新的工作階段會以一則固定訊息開頭,這也是移動時唯一代替你送出的訊息(在
/ccam:switch之後的移動則不會送出任何訊息):
Your usage limit was reached and ccam moved this conversation to another account. Continue the task you were working on when the limit was reached; do not repeat work that is already complete.如果達到限制的是子代理,訊息會改為下面這則,因為子代理、工作流程和背景指令已經隨著舊的工作階段一起停止:
A subagent hit your usage limit and ccam moved this conversation to another account. The subagents, workflows and background commands that were running then have stopped, and their results may be missing: run again what the task still needs, then continue it; do not repeat work that is already complete.如果新帳號也達到限制,同樣的事會在那裡再發生一次。有了上限記錄,這一連串的移動不會在重設之前回到先前的帳號,所以所有帳號都用滿時,工作階段會留在最後一個帳號。
若要中止已經開始的移動,請在 Claude Code 關閉時按 Ctrl+C:ccam: switch cancelled. Run `ccam next --continue` later to continue the conversation.
ccam 何時會移動工作階段
只有在以下條件全部成立時,ccam 才會移動工作階段:
- 工作階段是 ccam 在終端機中啟動的,而且 ccam 在它旁邊持續執行。開啟
auto_switch之後啟動的互動式工作階段都符合這一點。在那之前、或在較舊版 ccam 下啟動的工作階段,收到的通知會以This session started before auto_switch was on or under an older ccam, so ccam cannot move it: type /exit, then run `ccam next --continue`.結尾。無人看管的工作階段(-p執行和背景工作階段)、claude remote-control,以及不是透過 ccam 啟動的 Claude Code,ccam 都絕不會移動。 - 帳號已開啟 ccam 外掛,並執行 Claude Code 2.1.214 或更新版本。
- Claude Code 已把被拒絕的請求連同重設時間寫入對話,而且這次限制是該帳號的 5 小時、每週、Opus、Sonnet 或 Fable 限制。
- Fable 模型用完每週額度時,Claude Code 會顯示
You've hit your Fable limit或You're out of usage credits,而被拒絕的請求會指明 Fable 的每週區間。這就是 Fable 限制,下一個帳號必須在它自己的 Fable 每週區間中還有額度。 - 支出上限、其他請求的用量點數用完、組織設定的停用、伺服器節流,以及 API 金鑰的速率限制,都絕不會讓工作階段移動。
- 子代理或工作流程代理達到的限制也算在內,即使主對話只是在等它。如果那是每週的 Opus、Sonnet 或 Fable 限制,只有當對話本身也使用該模型時,工作階段才會移動。
- Fable 模型用完每週額度時,Claude Code 會顯示
- ccam 知道帳號的方案(取自帳號的
.claude.json或ccam login的記錄)。如果不知道,通知會以ccam does not know personal's plan, so auto_switch leaves this session.結尾。 - 工作階段沒有連接到 Remote Control。換成另一個帳號後,它不會重新連回你用來操作它的應用程式,所以工作階段會留在原處,通知也會說明這一點。
- 距離限制重設還有 15 分鐘以上。等待時間更短時,ccam 會把工作階段留給 Claude Code 處理:
ccam: personal hit its 5-hour limit, which resets in 9m; ccam leaves this session to wait for it. - 達到限制之後,你還沒有輸入任何提示詞。
- 另一個帳號還有額度(見下文)。
會移到哪個帳號
ccam 的選擇方式和 ccam next --auto 相同,會考慮 auto_max_usage、auto_strategy 和對話所用的模型,而且只在和你要離開的帳號同類的帳號之間選擇:同一個 Team 或 Enterprise 組織的另一個席位,或另一個個人方案(Pro 或 Max)。cross_org 和 --cross-org 在這裡不適用。此外,這個帳號必須以 Claude Code 能更新的登入資訊登入、有 ccam 知道的方案、沒有開啟用量點數、已在 Claude Code 中信任這個資料夾;如果對話以某個代理執行,還必須共用那個代理。完整的條件請參閱 ccam 如何選擇帳號。
有上限記錄的區間算作已滿;過去 2 分鐘內已有其他工作階段移入的帳號,則排在其他帳號之後。
不會移動的情況
沒有其他帳號還有額度時,什麼都不會移動:Claude Code 會照常處理限制,在工作階段中等待,或提供它自己的選項。通知會說明哪個帳號最先恢復額度,例如 ccam: personal hit its 5-hour limit (resets 3:29am). None of your other personal plans has room now; side frees up first, at 12:30am. Claude Code waits for personal here; /ccam:switch side after 12:30am moves it sooner. 如果是席位,則會顯示 None of your other accounts in Acme has room now。
如果上一節列出的後幾項帳號條件把所有還有額度的帳號都排除了,通知會指出是哪個帳號,以及原因:
side has not trusted this folder yet, so the conversation was not moved there. Open the folder once as side to allow it.side has room but its usage credits are on, so auto_switch did not move the conversation there; /ccam:switch side moves it.This conversation runs as agent "reviewer", and side does not share personal's agents, plugins and settings, so auto_switch did not move it there.
hook 會從兩個地方得知對話以某個代理執行:agent 設定,或指明代理的那筆資料列(Claude Code 會不時把它寫入對話,工作階段結束時也會寫入)。如果到目前為止只有工作階段的 --agent 指明了代理,而選中的帳號沒有共用這些代理,ccam next --continue 就不會啟動任何東西,並保留交接記錄,第二則桌面通知會顯示 ccam: this conversation runs as agent "reviewer", and side does not share personal's agents, plugins and settings, so ccam did not move it there. 標準錯誤中的錯誤訊息還會加上:Its note stays: `ccam next --continue` continues it later, and `ccam personal --resume <session id>` continues it as personal after the reset。
移動的代價
- Claude Code 會重新啟動,需要幾秒鐘。
- Claude 啟動的背景 shell、開發伺服器和代理,會隨著舊的工作階段一起停止。
- 和
ccam next --continue一樣,新帳號第一次回覆時會把整段對話重新讀一遍,ccam 也會告訴你對話有多大。移動時絕不會使用--brief。
絕不會做的事
auto_switch 絕不會在 Claude Code 回報限制之前切換,絕不會在背景監看你的用量,也絕不會複製、更新或轉交登入資訊。
Anthropic 的條款
在 Team 和 Enterprise 席位上,auto_switch 會把你的工作移到同一個組織的另一個席位。Anthropic 說明中心的 Team 方案文章寫道:「Each seat on a Team plan is assigned to one named individual, and only that person may use it」(Team 方案的每個席位都指派給一位具名的個人,只有這個人可以使用),以及「Users can't route their work through another user's account to use that user's remaining usage」(使用者不得經由其他使用者的帳號處理自己的工作,藉此使用對方剩餘的用量);Enterprise 方案的文章也有同樣的規定。
至於個人方案(Pro、Max),Anthropic 的條款並沒有說明你自己的帳號能不能在達到限制時自動互相接手。消費者條款禁止「through automated or non-human means, whether through a bot, script, or otherwise」(透過自動化或非人為的方式,無論是藉由機器人、腳本或其他方式)存取服務,除非 Anthropic 明確允許;而每次移動都會代替你送出上面其中一則固定訊息。自 2026 年 11 月 12 日起生效的使用政策,把「Intentionally bypass or interfere with capabilities, restrictions, or guardrails established within our products」(故意規避或干擾我們產品中設定的功能、限制或防護措施)列為禁止事項之一。
ccam 並不主張 auto_switch 符合這些條款。要不要開啟由你決定,風險也由你承擔:Anthropic 認為條款遭到違反時,可能會停用帳號,或停用 Team 或 Enterprise 組織的存取權。