Developers juggling multiple Claude Code accounts, say a team subscription and a personal z.ai gateway, typically end up swapping config files or storing credentials globally where they can leak across sessions. There is a cleaner way.
The approach uses a single Claude Code installation with a provider-neutral global config in ~/.claude/settings.json (no API keys stored there), plus two thin wrapper scripts that set the right environment variables before launching Claude:
claude-teamclears all provider-specific env vars (ANTHROPIC_BASE_URL,ANTHROPIC_AUTH_TOKEN, etc.) and launches the standard Claude binary. This ensures no gateway overrides bleed in.claude-zaipulls the z.ai token from a secure source (thepasspassword manager, a local file, or an env var) and sets the base URL tohttps://api.z.ai/api/anthropicalong with model mappings.
The critical security rule: never put third-party tokens in settings.json. That file is too easy to accidentally commit or share. Keep credentials in pass, a local secrets file, or scoped environment variables.
You can verify each path works by running claude-team auth status (should show no gateway) and claude-zai auth status (should show the z.ai endpoint). The same pattern extends to any alternative Anthropic-compatible provider, not just z.ai.
This is a niche setup, but for developers billing against multiple orgs or testing against different backends, it removes the friction of context-switching without any security compromises.