Claude account switcher: save and switch a chat's Claude login in place

Saved accounts live under <CLAUDE_CONFIG_DIR>/pipelines-accounts/<slug>/
(0700 dir, 0600 files). Switching changes what /login changes: the
claudeAiOauth entry of .credentials.json and oauthAccount of .claude.json
(atomic temp+rename, mode and other keys kept) and the org caches /login
drops, under Claude Code's own refresh, storage and config locks, so
running CLIs continue on the new account without a restart. The active
login's rotated tokens are written back to its slot first.

Server: claude_accounts / claude_account_save / _use / _remove, chat-scoped
and Claude-only; a switch moves the home's open chats to the new account's
quota (usage.account.switched_at), clearing a reached limit.
CLI: pipelines claude-account list|save|use|remove [--dir].
App: Claude account in the chat menu, and Switch to <account> on the
usage-limit and usage-warning banners, with a confirmation snack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 15:10:08 +00:00
parent 1772100af2
commit c490f71042
33 changed files with 2958 additions and 4 deletions
+4
View File
@@ -250,6 +250,10 @@ type Message struct {
ChatModels []ChatModel `json:"chat_models,omitempty"`
// ChatCommands is the chat_commands reply: the session's slash commands.
ChatCommands []ChatCommand `json:"chat_commands,omitempty"`
// ClaudeAccount is the body of the claude_account* requests and
// ClaudeAccounts their reply (claude_accounts.go).
ClaudeAccount *ClaudeAccountRequest `json:"claude_account,omitempty"`
ClaudeAccounts *ClaudeAccountList `json:"claude_accounts,omitempty"`
// ModelRequest is the chat_model body and echoed selection.
ModelRequest *ChatModelRequest `json:"chat_model,omitempty"`
// ChatModes is the chat_modes reply: the permission modes the session's