Skip to content

jalvarez-tech/claude-code-account-switcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Account Switcher for Claude Code

A simple tool to manage and switch between multiple Claude Code accounts on macOS, Linux, and WSL.

Features

  • Multi-account management: Add, remove, and list Claude Code accounts
  • Quick switching: Switch between accounts with simple commands
  • Cross-platform: Works on macOS, Linux, and WSL
  • Secure storage: Uses system keychain (macOS) or protected files (Linux/WSL)
  • Settings preservation: Only switches authentication - your themes, settings, and preferences remain unchanged
  • Auto-wait: Automatically waits for Claude Code to close before switching — no need to close it manually

Installation

Download the script directly:

curl -O https://raw.githubusercontent.com/jalvarez-tech/claude-code-account-switcher/main/ccswitcher.sh
chmod +x ccswitcher.sh

Usage

Basic Commands

# Add current account to managed accounts
./ccswitcher.sh --add-account

# List all managed accounts
./ccswitcher.sh --list

# Switch to next account in sequence
./ccswitcher.sh --switch

# Switch to specific account by number or email
./ccswitcher.sh --switch-to 2
./ccswitcher.sh --switch-to user2@example.com

# Remove an account
./ccswitcher.sh --remove-account user2@example.com

# Show help
./ccswitcher.sh --help

First Time Setup

  1. Log into Claude Code with your first account (make sure you're actively logged in)
  2. Run ./ccswitcher.sh --add-account to add it to managed accounts
  3. Log out and log into Claude Code with your second account
  4. Run ./ccswitcher.sh --add-account again
  5. Now you can switch between accounts with ./ccswitcher.sh --switch
  6. Important: After each switch, restart Claude Code to use the new authentication

Tip: Running ./ccswitcher.sh --list for the first time will also offer to add your current account interactively if no accounts are managed yet.

What gets switched: Only your authentication credentials change. Your themes, settings, preferences, and chat history remain exactly the same.

Switching behavior

  • If you run --switch and your current account is not in the managed list, it will be automatically added before switching. Run --switch again to continue to the next account.
  • If you run --switch-to targeting the account you're already on, the script will let you know and exit without making any changes.

Requirements

  • Bash 4.4+
  • jq (JSON processor)

Installing Dependencies

macOS:

brew install jq

Ubuntu/Debian:

sudo apt install jq

How It Works

The switcher stores account authentication data separately:

  • macOS: Credentials in Keychain, config in ~/.claude-switch-backup/configs/
  • Linux/WSL: Credentials and config both in ~/.claude-switch-backup/ with restricted permissions

The backup directory structure:

~/.claude-switch-backup/
├── sequence.json        # active account, order, and account index
├── configs/             # per-account backup of ~/.claude/.claude.json
└── credentials/         # per-account backup of credentials (Linux/WSL only)

When switching accounts, it:

  1. Waits for Claude Code to close (if running)
  2. Backs up the current account's authentication data
  3. Restores the target account's authentication data
  4. Updates Claude Code's authentication files

Troubleshooting

If a switch fails

  • Check that you have accounts added: ./ccswitcher.sh --list
  • The script waits for Claude Code to close automatically — if it seems stuck, close Claude manually
  • Try switching back to your original account

If you can't add an account

  • Make sure you're logged into Claude Code first
  • Check that you have jq installed
  • Verify you have write permissions to your home directory

If Claude Code doesn't recognize the new account

  • Make sure you restarted Claude Code after switching
  • Check the current account: ./ccswitcher.sh --list (look for "(active)")

Cleanup/Uninstall

To stop using this tool and remove all data:

  1. Note your current active account: ./ccswitcher.sh --list
  2. Remove the backup directory: rm -rf ~/.claude-switch-backup
  3. Delete the script: rm ccswitcher.sh

Your current Claude Code login will remain active.

Security Notes

  • Credentials stored in macOS Keychain or files with 600 permissions
  • Authentication files and backup directory are stored with restricted permissions (600/700)
  • The script automatically waits for Claude Code to close before applying any changes

License

MIT License - see LICENSE file for details

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages