This is a feature request for the Claude Code CLI tool, asking for the ability to log in and switch between multiple Claude.ai accounts, similar to GitHub CLI's `gh auth switch`. It addresses the pain point of users needing to log out and log back in to use different accounts for personal and professional work, which can lead to data leakage and policy violations.
A starter prompt for Claude Code, what you'll need, and how to reach them.
You are an expert Go developer and CLI tool specialist. I need to implement a feature for the `anthropics/claude-code` CLI tool that allows users to manage and switch between multiple Claude.ai accounts, similar to `gh auth switch`. The core problem is that users cannot easily switch contexts (personal, Company A, Company B) and risk using the wrong account for confidential work. Your task is to provide the core Go code and necessary structural changes for the `anthropics/claude-code` CLI (assume a standard Go CLI architecture) to: 1. **Securely store multiple Claude API keys or session tokens locally.** Suggest a robust method, potentially using OS-specific keychains or encrypted files, and detail the encryption/decryption process. Focus on a simple, cross-platform default first (e.g., encrypted JSON file). 2. **Implement a `claude auth add` command** to prompt the user for new credentials (e.g., API key, optional account name/alias) and store them. 3. **Implement a `claude auth switch` command** that lists stored accounts and allows the user to select one, setting it as the active context for subsequent `claude` commands. 4. **Implement a `claude auth status` command** that displays the currently active account. 5. **Modify the existing Claude client initialization logic** to load credentials for the currently active account. Assume the existing codebase uses Go and standard CLI libraries (e.g., Cobra, Viper). Focus on the core logic and data structures for account management. Provide clear comments and explain any security considerations. Prioritize functionality for an MVP: secure local storage (e.g., encrypted JSON file), `add`, `switch`, `status`, and integration with the client. The build/verify gate is to successfully add two accounts, switch between them, and confirm the `status` command reflects the correct active account, and that subsequent API calls use the selected account's credentials.
Reach out to developers using Claude Code who are juggling multiple accounts and offer insights or tools from 'ai-usage-monitor' for tracking spend, or 'agent-eval-lab' for those building and testing agents across accounts.
## Feature Request: Multiple Account Support / Account Switching ### Problem Users who work across multiple contexts (e.g., personal, Company A, Company B) with separate Claude.ai accounts cannot quickly switch between them. There is no way to see which account is currently active at a glance, and no fast switching mechanism exists. This creates real risks: - Accidentally using a personal account for confidential company work - Using a company account for personal projects (policy violation) - No visual indicator of the currently active account in the workflow Currently, switching requires a full logout → login cycle with browser authentication every time, making it impractical to switch frequently. ### Expected Behavior Similar to `gh auth switch` in GitHub CLI: - Store credentials for multiple accounts locally - Switch accounts with a single command: `claude auth switch` - Show the currently active account clearly (e.g., `claude auth status`) ### Example Workflow ```bash $ claude auth switch ? Select account: > personal@gmail.com (Personal - Pro) alice@company-a.com (Company A - Teams) alice@company-b.com (Company B - Teams) ``` ### Current Workaround ```bash claude aut
Standard for dev work
Familiar with Go for CLI tools
Standard for Go CLI apps
New: best practices for local credential encryption/storage - ~0.5 day
Learn it: Search getting-started ↗
Get set up: Create the account/instance, generate the API key or credentials, and add them to your project's environment variables.
Comment on the GitHub issue #30031 in the `anthropics/claude-code` repository.
“I've started working on a prototype for multiple account login and switching for the Claude Code CLI, directly addressing issue #30031. I have a clear plan for secure credential storage and `auth add/switch/status` commands, and I'd be happy to share my progress or collaborate on a PR.”
Open the original ↗