Automatic Claude Code account switching based on your project directory.
Switch between work and personal Claude accounts without running claude logout / claude login every time. Just cd into your project and type claude — the right account is used automatically.
~/personal/project $ claude → uses personal account
~/work/project $ claude → uses work account (automatically!)
Each profile gets its own isolated Claude config directory (~/.claude-profiles/<name>/). When you run claude-profile init in a project, it creates a .envrc file that tells direnv to set CLAUDE_CONFIG_DIR when you enter that directory. Claude Code reads this variable and uses the corresponding credentials.
Both accounts can run simultaneously in different terminals with no conflicts.
brew tap carsonyong/claude-profile
brew install claude-profilegit clone https://github.com/carsonyong/claude-profile.git
cd claude-profile
make install- Claude Code CLI
- direnv —
brew install direnv - Python 3 (ships with macOS)
# ~/.zshrc (or ~/.bashrc)
eval "$(direnv hook zsh)"claude-profile add personal # opens browser → log in with personal account
claude-profile add work # opens browser → log in with work accountclaude-profile default personalAdd this to your ~/.zshrc to activate the default globally:
[ -f ~/.claude-profiles/default-env.sh ] && source ~/.claude-profiles/default-env.shcd ~/work/my-project
claude-profile init workThat's it. Now claude uses your work account in that project, and your personal account everywhere else.
Need to use a different profile without changing the project setup? Use use:
claude-profile use personal # launches Claude with personal account
claude-profile use personal --resume # passes --resume through to Claude| Command | Description |
|---|---|
claude-profile add <name> |
Add a new profile (opens browser to log in) |
claude-profile init [name] |
Set up current directory to use a profile |
claude-profile use <name> [args...] |
Launch Claude with a specific profile (one-time override) |
claude-profile list |
List all profiles with account emails |
claude-profile status |
Show which profile is active in current directory |
claude-profile default <name> |
Set the default profile |
claude-profile remove <name> |
Remove a profile |
claude-profile init --vscode— Also create/update.vscode/settings.jsonclaude-profile remove --force— Skip confirmation promptclaude-profile use <name> [args...]— Any arguments after the profile name are passed through toclaude
If your project has a .vscode/ directory, claude-profile init automatically adds the profile to .vscode/settings.json:
{
"claudeCode.environmentVariables": [
{
"name": "CLAUDE_CONFIG_DIR",
"value": "/Users/you/.claude-profiles/work"
}
]
}This ensures the Claude Code VS Code extension uses the correct account too. You can also pass --vscode to force this even without an existing .vscode/ directory.
┌─────────────────────────────────────────────────────┐
│ Shell startup │
│ 1. Source default-env.sh → sets CLAUDE_CONFIG_DIR │
│ 2. direnv hook installed → watches for .envrc files │
└─────────────────────────────────────────────────────┘
│
┌──────────────┴──────────────┐
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ cd ~/work/project│ │ cd ~/personal/ │
│ │ │ │
│ .envrc loads: │ │ No .envrc: │
│ CLAUDE_CONFIG_DIR│ │ Default profile │
│ = ~/.claude- │ │ takes effect │
│ profiles/work │ │ │
└──────────────────┘ └──────────────────┘
│ │
▼ ▼
claude → work account claude → personal account
brew uninstall claude-profile
rm -rf ~/.claude-profilesRemove the direnv hook and default-env.sh source line from your shell RC file.
MIT