A macOS shell script for managing multiple Claude personal accounts using the macOS Keychain system. This tool allows you to seamlessly switch between different Claude Code accounts without having to log in and out manually each time.
- Multiple Account Management: Add, switch between, and delete multiple Claude accounts
- Interactive & Command Line Interface: Supports both interactive menu mode and direct command execution
- Account Status Tracking: View current login status and account information
- Safe Account Switching: Preserves all credential files when switching accounts
- macOS (this script is designed specifically for macOS)
- Claude Code CLI installed and configured
securitycommand (built into macOS)jq(optional but recommended for better JSON processing)
- Clone or download this repository
- Make the script executable:
chmod +x claude-account-manager-en.sh
- (Optional) Install jq for better JSON handling:
brew install jq
You can quickly try the script without downloading using curl:
# Run directly in interactive mode
curl -s https://raw.githubusercontent.com/kzheart/claude-code-switcher/master/claude-account-manager-en.sh | bash -s - < /dev/tty
# Or download and run locally
curl -o claude-account-manager-en.sh https://raw.githubusercontent.com/kzheart/claude-code-switcher/master/claude-account-manager-en.sh && chmod +x claude-account-manager-en.sh && ./claude-account-manager-en.shRun the script without arguments to enter interactive mode:
./claude-account-manager-en.shThis will present a menu with the following options:
- Add account
- Login account
- Logout
- Account list
- Delete account
- Show status
- Exit
You can also use the script with direct commands:
# Interactive mode
./claude-account-manager-en.sh add
# With account name
./claude-account-manager-en.sh add work
# With account name and description
./claude-account-manager-en.sh add work "Work Account"# Interactive selection
./claude-account-manager-en.sh login
# Login to specific account
./claude-account-manager-en.sh login work./claude-account-manager-en.sh list./claude-account-manager-en.sh status./claude-account-manager-en.sh logout# Interactive deletion
./claude-account-manager-en.sh delete
# Delete specific account (requires confirmation)
./claude-account-manager-en.sh delete work./claude-account-manager-en.sh help- Account Addition: When you add an account, the script captures your current Claude Code credentials from the macOS Keychain and saves them to a secure file
- Account Switching: When you switch accounts, the script replaces the current credentials in the Keychain with those from the selected account
- Secure Storage: All credentials are stored in
~/.claude-accounts/with secure file permissions (600/700) - Configuration Management: Account metadata is stored in JSON format for easy management
~/.claude-accounts/
├── config.json # Account metadata and configuration
├── current.txt # Currently active account name
└── accounts/
├── work.creds # Credential files for each account
├── personal.creds
└── ...
- All credential files are stored with secure permissions (600)
- The account management directory has restricted access (700)
- Credentials are stored locally on your machine only
- The script uses macOS Keychain, which is encrypted and secure
This script is designed specifically for macOS and uses macOS-specific commands like security.
The security command should be built into macOS. If it's missing, your macOS installation may be incomplete.
While not required, jq provides better JSON processing. Install it with: brew install jq
Make sure you're logged into Claude Code before adding an account. Run claude-code auth login first.
After switching accounts, you need to restart Claude Code for the changes to take effect.
- Restart Required: You must restart Claude Code after switching accounts for changes to take effect
- Account Names: Account names can only contain letters, numbers, underscores, and hyphens
- Backup: Consider backing up your
~/.claude-accounts/directory for account recovery - Single Machine: This tool manages accounts locally on a single machine only
Feel free to submit issues, feature requests, or pull requests to improve this tool.