Created
April 27, 2026 18:49
-
-
Save LeZuse/e92877e2e647eff253076d7aa10931a2 to your computer and use it in GitHub Desktop.
Claude Code Multiple Plan Subscriptions Switch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Switch Claude Code keychain credentials and launch | |
| # Usage: cc-switch <profile> [claude args...] | |
| # cc-switch team → launch with Team plan | |
| # cc-switch max → launch with Max plan | |
| # cc-switch which → show current active profile | |
| KEYCHAIN_SVC="Claude Code-credentials" | |
| TEAM_SVC="Claude Code-credentials-backup-team" | |
| MAX_SVC="Claude Code-credentials-backup-extra" | |
| ACCT="zuse" | |
| profile="$1" | |
| shift 2>/dev/null | |
| case "$profile" in | |
| team) | |
| SOURCE_SVC="$TEAM_SVC" | |
| ;; | |
| max) | |
| SOURCE_SVC="$MAX_SVC" | |
| ;; | |
| which) | |
| CREDS=$(security find-generic-password -s "$KEYCHAIN_SVC" -a "$ACCT" -w 2>/dev/null) | |
| if [ -z "$CREDS" ]; then | |
| echo "No active credentials" | |
| else | |
| TYPE=$(echo "$CREDS" | python3 -c "import sys,json; print(json.load(sys.stdin).get('claudeAiOauth',{}).get('subscriptionType','unknown'))" 2>/dev/null) | |
| echo "Active: $TYPE" | |
| fi | |
| exit 0 | |
| ;; | |
| *) | |
| echo "Usage: cc-switch <team|max|which> [claude args...]" | |
| exit 1 | |
| ;; | |
| esac | |
| # Read source credentials | |
| CREDS=$(security find-generic-password -s "$SOURCE_SVC" -a "$ACCT" -w 2>/dev/null) | |
| if [ -z "$CREDS" ]; then | |
| echo "Error: No credentials found for $profile ($SOURCE_SVC)" | |
| exit 1 | |
| fi | |
| # Remove current active entry if it exists | |
| security delete-generic-password -s "$KEYCHAIN_SVC" -a "$ACCT" >/dev/null 2>&1 | |
| # Write the selected credentials as active | |
| security add-generic-password -s "$KEYCHAIN_SVC" -a "$ACCT" -l "$KEYCHAIN_SVC" -w "$CREDS" >/dev/null 2>&1 | |
| echo "Switched to: $profile" | |
| # Launch Claude Code (unset OAUTH token so keychain takes effect) | |
| unset CLAUDE_CODE_OAUTH_TOKEN | |
| exec claude --dangerously-skip-permissions "$@" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cc-switch: Multiple Claude Code Accounts
Switch between Claude Code subscriptions (e.g. Team + Max) via macOS Keychain.
Setup
1. Login and backup each account
Login with your first account:
Backup the credentials (check the subscription type first):
Save it under a backup name:
Delete the active entry and repeat for your second account:
2. Install cc-switch
Put the
cc-switchscript in your PATH (e.g.~/bin/cc-switch), make it executable. Update theTEAM_SVCandMAX_SVCvariables to match your backup names.3. Add aliases
Usage
How it works
Claude Code stores OAuth credentials in macOS Keychain under
Claude Code-credentials. The script swaps the active entry with a backup before launching. Each running session caches credentials in memory, so swapping doesn't affect already-running sessions.Important: Unset
CLAUDE_CODE_OAUTH_TOKENif set — it takes precedence over the keychain.