Switch between Claude Code accounts the same way you switch Python envs or Node versions — a shell function that feels like a native command.
Modeled after nvm / venv / jenv. macOS-first; see open issues for the WSL/Windows roadmap.
(includes SHA256 integrity check):
curl:
curl -o- https://github.com/1shooperman/claude-env/releases/download/v0.1.2/install.sh | shFrom a local clone:
git clone git@github.com:1shooperman/claude-env.git
sh claude-env/install.shNote: Piped installs (curl/wget) are non-interactive and skip shell profile wiring. The installer prints the two lines to add manually — follow those instructions, then reload your shell. Local installs (
sh install.sh) prompt you before writing to your profile.
After wiring your profile, reload your shell:
source ~/.zshrc # or ~/.bashrcoh-my-zsh users: oh-my-zsh automatically sources any .zsh files in ~/.oh-my-zsh/custom/. You can symlink claudenv there so it loads as part of the normal oh-my-zsh startup — no manual source line in .zshrc required:
ln -s "$HOME/.claudenv/claudenv.sh" "$HOME/.oh-my-zsh/custom/claudenv.zsh"If you previously ran a local install and answered yes to the profile prompt, remove the # claudenv block from ~/.zshrc to avoid double-sourcing.
install.sh downloads claudenv.sh to ~/.claudenv/ and sources it from your shell profile. Because it runs as a shell function (not a subprocess), it can export environment variables and modify your prompt directly — the same trick nvm uses.
Each env is a directory under ~/.claudenv/envs/<name>/. Activating an env sets CLAUDE_CONFIG_DIR to that directory, which tells Claude Code to read config and credentials from there instead of the default ~/.claude.
| Command | Description |
|---|---|
claudenv |
Interactive env picker |
claudenv <name> |
Activate a named env |
claudenv deactivate |
Deactivate the current env |
claudenv config [name] |
Create a new env |
claudenv list |
List all envs (* marks the active one) |
claudenv remove <name> |
Delete an env |
claudenv upgrade <ver> |
Upgrade to a release (e.g. v1.2.3 or latest) |
claudenv uninstall |
Remove claudenv and clean up shell profile |
claudenv help |
Show command reference |
Place a .claudenvrc file containing an env name in any directory:
echo "work" > .claudenvrcclaudenv will activate that env automatically when you cd into the directory and deactivate it when you leave (if it was auto-activated).
When an env is active, your prompt is prefixed with the env name:
(work) ~ $
oh-my-zsh: claudenv registers a precmd hook via add-zsh-hook so the prefix survives theme redraws. Works with any theme that sets PROMPT in a precmd hook (robbyrussell, agnoster, etc.).
Note: Powerlevel10k uses its own async rendering pipeline. See #3 for p10k support.
- No auth flow —
claudenv configcreates the env directory but does not log you in. You must authenticate separately. See #1. - WSL / Windows — not yet supported. See #2.
- Powerlevel10k — the
precmdhook approach does not integrate with p10k's async prompt segments. See #3. - Fish shell — Fish uses a different config syntax; contributions welcome.
PRs welcome. The entire tool is plain shell (claudenv.sh) — no build step, no dependencies. See CONTRIBUTING.md.
If claudenv saves you time, consider buying me a coffee. ☕