For those who have a Claude (Anthropic) account and a GLM Coding Plan (Z.ai) account and want to use Claude Code for both.
On macOS, Claude Code stores access credentials in the Keychain (macOS Keychain is a secure database that the operating system provides to applications for storing secrets). This makes the setup more secure but less programmatically configurable.
This script blocks access to the Keychain for this instance of Claude Code execution, forcing it to write account settings to configuration files.
Additionally, it creates and uses a separate directory for Claude Code configuration when using the GLM Coding Plan account.
TL;DR: It creates complete isolation for running claude. So your normal instances of claude don't see anything about Z.ai and vice versa.
Copy this script to your Mac, insert your API Key (line 26), and grant execution permissions to the script.
For example, I saved my version to ~/Scripts/glm-claude.sh, then ran chmod +x ~/Scripts/glm-claude.sh to grant the execution permission.
Additionally, I recommend adding an alias.
Add alias glm="~/Scripts/glm-claude.sh" to the end of your .zshrc and restart the shell.
alias glm "~/Scripts/glm-claude.sh" and funcsave glm
Now you can use claude to run your untouched Claude Code with your Anthropic API or Claude Plan account. Or use glm for an isolated Claude Code.
Your claude user configuration gets stored in ~/.claude and your glm user configuration gets stored in ~/.glm.
The project specific configuration (.claude directory inside projects) is shared between claude and glm
You can even use arguments like glm mcp add ...
This text/script is provided for academic purposes only. I am not associated with either company. Consult a lawyer to understand the legality of this process in your jurisdiction.