Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

claude-profile

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.

How It Works

~/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.

Install

Homebrew

brew tap carsonyong/claude-profile
brew install claude-profile

Manual

git clone https://github.com/carsonyong/claude-profile.git
cd claude-profile
make install

Prerequisites

Quick Start

1. Add the direnv hook to your shell

# ~/.zshrc (or ~/.bashrc)
eval "$(direnv hook zsh)"

2. Create your profiles

claude-profile add personal    # opens browser → log in with personal account
claude-profile add work        # opens browser → log in with work account

3. Set your default profile

claude-profile default personal

Add this to your ~/.zshrc to activate the default globally:

[ -f ~/.claude-profiles/default-env.sh ] && source ~/.claude-profiles/default-env.sh

4. Initialize a project

cd ~/work/my-project
claude-profile init work

That's it. Now claude uses your work account in that project, and your personal account everywhere else.

One-time override

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

Commands

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

Options

  • claude-profile init --vscode — Also create/update .vscode/settings.json
  • claude-profile remove --force — Skip confirmation prompt
  • claude-profile use <name> [args...] — Any arguments after the profile name are passed through to claude

VS Code Support

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.

How Auto-Switching Works

┌─────────────────────────────────────────────────────┐
│ 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

Uninstall

brew uninstall claude-profile
rm -rf ~/.claude-profiles

Remove the direnv hook and default-env.sh source line from your shell RC file.

License

MIT

About

Automatic Claude Code account switching based on project directory

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages