{"id":48139365,"url":"https://github.com/rzkmak/claude-switch","last_synced_at":"2026-04-04T16:50:27.752Z","repository":{"id":333232971,"uuid":"1136628270","full_name":"rzkmak/claude-switch","owner":"rzkmak","description":"or `csw`, Switch between Claude CLI accounts in seconds (whether api key, byok, or oauth) - perfect for managing multiple subscriptions across platform (z.ai, Anthropic, ollama etc.)","archived":false,"fork":false,"pushed_at":"2026-03-29T01:04:21.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-29T04:08:36.118Z","etag":null,"topics":["claude-code"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rzkmak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-18T03:14:29.000Z","updated_at":"2026-03-29T01:05:23.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rzkmak/claude-switch","commit_stats":null,"previous_names":["rzkmak/claude-account-switch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rzkmak/claude-switch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzkmak%2Fclaude-switch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzkmak%2Fclaude-switch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzkmak%2Fclaude-switch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzkmak%2Fclaude-switch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rzkmak","download_url":"https://codeload.github.com/rzkmak/claude-switch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rzkmak%2Fclaude-switch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31406302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["claude-code"],"created_at":"2026-04-04T16:50:16.985Z","updated_at":"2026-04-04T16:50:27.739Z","avatar_url":"https://github.com/rzkmak.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Claude Account Switcher\n\n**Easily switch between multiple Claude CLI subscription accounts (e.g., z.ai and Anthropic)**\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\u003e **⚠️ Platform Compatibility**: This tool is currently tested on macOS only. The keychain integration feature (for OAuth credential management) is macOS-specific and may not work on Windows or Linux. We welcome contributions from the community to add support for other platforms!\n\n---\n\n## ✨ Features\n\n- 🔒 **Safe \u0026 Secure** - Automatic backup of original config\n- 🚀 **One-Line Install** - Install with a single curl command\n- 🔄 **Easy Switching** - Switch between accounts in seconds\n- 🔗 **Auto-Sync** - Profiles utilize symlinks so tokens stay fresh automatically\n- 📦 **Profile Management** - Save unlimited account profiles\n- 🎨 **Beautiful CLI** - Color-coded output for better UX\n\n---\n\n## 🚀 Quick Start\n\n### Installation\n\nInstall with a single command:\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/rzkmak/claude-switch/main/install.sh | bash\n```\n\nThis will install `claude-switch` to `~/.local/bin/` and make it available system-wide.\n\n\u003e **💡 Tip**: To upgrade to the latest version, simply run the same command again!\n\n### Setup Your Accounts\n\nThe easiest way to set up profiles is using the interactive `new` command:\n\n```bash\n# 1. Create your first profile (e.g., Anthropic)\ncsw new\n# Follow the interactive prompts to log in\n\n# 2. Create your second profile (e.g., z.ai)\ncsw new\n# Follow the interactive prompts to set your API key\n```\n\n### Switch Between Accounts\n\n```bash\ncsw use anthropic     # Use Anthropic\ncsw use z.ai          # Use z.ai\ncsw current           # Check active account\ncsw list              # List all accounts\n```\n\n---\n\n## 📋 Commands\n\n| Command | Description | Example |\n|---------|-------------|---------|\n| `new` | Create a new profile interactively | `csw new` |\n| `save \u003cname\u003e` | Save current config as profile | `csw save anthropic` |\n| `use \u003cname\u003e` | Use a different profile | `csw use z.ai` |\n| `list` | List all profiles | `csw list` |\n| `current` | Show active profile | `csw current` |\n| `delete \u003cname\u003e` | Delete a profile | `csw delete old-account` |\n| `help` | Show help message | `csw help` |\n\n---\n\n## 📖 Detailed Setup Guide\n\n### First-Time Setup\n\nWhen you run the script for the first time, it will:\n1. Automatically back up your current authentication to `~/.claude/backups/original-auth.json`\n2. Automatically back up your environment settings to `~/.claude/backups/original-settings.json` (if exists)\n3. Ask if you want to save it as a profile\n4. Create the necessary directories\n\n**Your original configuration is always safe and never overwritten!**\n\n\u003e **Note**: The script handles both:\n\u003e - `~/.claude.json` - Authentication tokens (from `claude` -\u003e `/login`)\n\u003e - `~/.claude/settings.json` - Environment variables and model settings\n\n### Configuring Multiple Accounts\n\nUse the `new` command for a guided setup:\n\n#### Example: Anthropic Account\n\n```bash\ncsw new\n```\n\nSelect \"OAuth\" when prompted, then follow the instructions to:\n1. Run `claude` to open the interface\n2. Use the `/login` command\n3. Enter a profile name (e.g., \"anthropic\")\n4. Save the profile\n\n#### Example: z.ai Account\n\n```bash\ncsw new\n```\n\nSelect \"API Key\" when prompted, then follow the instructions to:\n1. Get your API key\n2. Create `~/.claude/settings.json`\n3. Enter a profile name (e.g., \"z.ai\")\n4. Save the profile\n\n### Complete Workflow Example\n\n```bash\n# Create profiles interactively\ncsw new\ncsw new\n\n# Switch between accounts anytime\ncsw use anthropic\ncsw use z.ai\n\n# Check which account is active\ncsw current\n\n# List all your accounts\ncsw list\n```\n\n---\n\n## 🔧 Installation Options\n\n### Quick Install (Recommended)\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/rzkmak/claude-switch/main/install.sh | bash\n```\n\n### Custom Installation Directory\n\n```bash\nINSTALL_DIR=/usr/local/bin curl -fsSL https://raw.githubusercontent.com/rzkmak/claude-switch/main/install.sh | bash\n```\n\n### Manual Installation\n\n```bash\n# Clone the repository\ngit clone https://github.com/rzkmak/claude-switch.git\ncd claude-switch\n\n# Make executable\nchmod +x claude-switch.sh\n\n# Copy to PATH\ncp claude-switch.sh ~/.local/bin/claude-switch\n```\n\n### Download Single File\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/rzkmak/claude-switch/main/claude-switch.sh -o claude-switch\nchmod +x claude-switch\nmv claude-switch ~/.local/bin/\n```\n\n---\n\n## 🔒 Safety Features\n\n### Automatic Backups\n\n✅ **Original Backup** - First run creates:\n  - `~/.claude/backups/original-auth.json` (authentication)\n  - `~/.claude/backups/original-settings.json` (environment settings, if exists)\n\n\n\n✅ **Confirmation Prompts** - Asks before overwriting or deleting profiles  \n✅ **Separate Storage** - Profiles stored in `~/.claude/profiles/\u003cprofile-name\u003e/`  \n\n### File Locations\n\n- **Active Auth**: `~/.claude.json` (symlink to active profile)\n- **Active Settings**: `~/.claude/settings.json` (symlink or missing)\n- **Profiles**: `~/.claude/profiles/\u003cprofile-name\u003e/`\n  - `auth.json` - Authentication tokens\n  - `settings.json` - Environment variables (optional)\n- **Backups**: `~/.claude/backups/`\n\n### Restore Original Configuration\n\n```bash\n# Restore authentication\ncp ~/.claude/backups/original-auth.json ~/.claude.json\n\n# Restore settings (if exists)\ncp ~/.claude/backups/original-settings.json ~/.claude/settings.json\n```\n\n---\n\n## 💡 Pro Tips\n\n### Create an Alias\n\nFor even quicker access:\n\nThe installer automatically adds the `csw` alias:\n\n```bash\n# Added automatically to your shell config:\nalias csw=\"claude-switch\"\n\n# Now you can use:\ncsw use z.ai\ncsw list\ncsw current\n```\n\n### Install jq for Better Output\n\n```bash\nbrew install jq\n```\n\nWith jq installed, the output will be prettier and more readable.\n\n### Integration with Shell Prompt\n\nShow current Claude account in your prompt:\n\n```bash\n# Add to ~/.zshrc\nclaude_account() {\n  local profile=$(claude-switch current 2\u003e/dev/null | grep \"Current profile:\" | cut -d: -f2 | xargs)\n  if [[ -n \"$profile\" \u0026\u0026 \"$profile\" != \"unknown\" ]]; then\n    echo \"[$profile]\"\n  fi\n}\n\n# Add to your PROMPT\nPROMPT='$(claude_account) %~ %# '\n```\n\n---\n\n## 🐛 Troubleshooting\n\n### \"claude-switch: command not found\"\n\nYour `~/.local/bin` might not be in your PATH. Add it:\n\n```bash\n# For zsh (macOS default)\necho 'export PATH=\"$PATH:$HOME/.local/bin\"' \u003e\u003e ~/.zshrc\nsource ~/.zshrc\n\n# For bash\necho 'export PATH=\"$PATH:$HOME/.local/bin\"' \u003e\u003e ~/.bashrc\nsource ~/.bashrc\n```\n\nOr create an alias:\n\n```bash\necho 'alias csw=\"~/.local/bin/claude-switch\"' \u003e\u003e ~/.zshrc\nsource ~/.zshrc\n```\n\n### \"Claude CLI not found\"\n\nInstall Claude CLI first:\n- Visit: https://claude.ai/download\n- Or use: `npm install -g @anthropic-ai/claude-cli`\n\n### Permission Denied\n\nMake sure the script is executable:\n\n```bash\nchmod +x ~/.local/bin/claude-switch\n```\n\n### Profile Not Switching\n\nVerify file permissions:\n\n```bash\nls -la ~/.claude/settings.json\n# Should show: -rw-r--r--\n```\n\n### Still Being Asked to Login After Switching to API Key Profile\n\nIf you're still being prompted to log in after switching to an API key profile (like z.ai):\n\n1. **Delete and recreate the profile** - This ensures a clean setup:\n   ```bash\n   csw delete z.ai\n   csw new\n   ```\n\n2. **Verify the profile is active**:\n   ```bash\n   csw current\n   # Should show your API key profile\n   ```\n\n3. **Check settings.json is symlinked correctly**:\n   ```bash\n   ls -la ~/.claude/settings.json\n   # Should show a symlink to the profile's settings.json\n   ```\n\nThe script now automatically creates a minimal `auth.json` for API key profiles to prevent Claude CLI from attempting OAuth authentication.\n\n---\n\n## 📦 Requirements\n\n- **Claude CLI** - Must be installed and configured\n- **bash** 4.0 or higher\n- **curl** - For installation\n- **jq** - Optional, for prettier output\n\n---\n\n## 🗑️ Uninstallation\n\n### Quick Uninstall\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/rzkmak/claude-switch/main/uninstall.sh | bash\n```\n\nThis will:\n- Remove the `claude-switch` script\n- Ask if you want to keep or remove profiles and backups\n- Never touch your active Claude configuration (`~/.claude.json`)\n\n### Manual Uninstallation\n\n```bash\n# Remove the script\nrm ~/.local/bin/claude-switch\n\n# Optionally remove profiles and backups\nrm -rf ~/.claude/profiles\nrm -rf ~/.claude/backups\n```\n\n### Non-Interactive Uninstall\n\n```bash\n# Keep profiles and backups (default)\ncurl -fsSL https://raw.githubusercontent.com/rzkmak/claude-switch/main/uninstall.sh | bash\n\n# Remove everything including profiles and backups\ncurl -fsSL https://raw.githubusercontent.com/rzkmak/claude-switch/main/uninstall.sh | KEEP_DATA=false bash\n```\n\nYour active Claude configuration at `~/.claude.json` and `~/.claude/settings.json` remains untouched.\n\n---\n\n## 🎯 Use Cases\n\nPerfect for:\n- Developers with multiple Claude subscriptions\n- Teams sharing different Claude accounts\n- Testing between different API endpoints\n- Switching between production and development configs\n- Managing personal and work accounts\n\n---\n\n## 🧪 Testing\n\nThe project includes a comprehensive unit test suite to ensure the script works correctly.\n\n### Running Tests\n\nRun all tests from the project root:\n\n```bash\n./tests/run_tests.sh\n```\n\n### Test Coverage\n\nThe test suite covers:\n- **Profile Creation** - Testing save profile functionality\n- **Profile Switching** - Testing profile switching and symlink creation\n- **Profile Listing** - Testing profile listing commands\n- **Profile Deletion** - Testing profile deletion\n- **Current Profile Detection** - Testing detection of active profile\n- **First-Time Setup** - Testing initial backup and setup\n- **OAuth/API Key Detection** - Testing authentication type detection\n- **Auth Token Clearing** - Testing OAuth token removal for API key profiles\n\n### Test Isolation\n\nAll tests run in a sandboxed environment using temporary directories. Your actual Claude configuration files are never touched during testing.\n\n---\n\n## 🤝 Contributing\n\nIssues and pull requests are welcome!\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n---\n\n## 📄 License\n\nMIT License - See [LICENSE](LICENSE) for details\n\n---\n\n## 🙏 Support\n\nIf you find this useful, please ⭐ star the repo!\n\n---\n\n**Made with ❤️ for the Claude community**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frzkmak%2Fclaude-switch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frzkmak%2Fclaude-switch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frzkmak%2Fclaude-switch/lists"}