Claude Code: A Different Account for Each Project
Make plain claude use your client's account in the client's folder and your own account everywhere else, with direnv, a zsh hook or Clawdrobe.

Claude Code has no per-project account setting, but you can get the same result by changing CLAUDE_CONFIG_DIR when you enter a folder. Give each account its own configuration folder, then use direnv or a small shell hook to point CLAUDE_CONFIG_DIR at the right one whenever you cd into a project. Plain claude then runs as the client's account inside the client's folders and as your own account everywhere else.
Why a project setting won't do it#
Claude Code keeps its login, settings and session history in one configuration folder, ~/.claude by default. Anthropic's authentication docs say how to stay signed in to several accounts: give each account its own folder and pick it with the CLAUDE_CONFIG_DIR environment variable when you start claude. On a Mac the Keychain entry follows the folder too, so two folders are two separate logins.
The obvious next step would be putting CLAUDE_CONFIG_DIR in the repo's .claude/settings.json. That doesn't work. Anthropic's environment variable reference says project and local settings can't set it (as of November 2026). It has to come from the shell that starts claude, so the trick is to make the shell set it for you based on the folder you're in.
First, create a folder per extra account and sign in once:
CLAUDE_CONFIG_DIR=$HOME/.claude-acme claude
Claude Code walks you through its first-run setup and opens a browser window to sign in. Use the account for that client, then quit. From now on that folder stays signed in to it. Your own account keeps using ~/.claude.
Option 1: direnv#
direnv loads an .envrc file when you enter a folder and undoes it when you leave. It's the most common way to keep per-project environment variables, so you may already have it.
Install it with
brew install direnv, then add its hook to the end of~/.zshrcand open a new Terminal window:eval "$(direnv hook zsh)"Put an
.envrcin the client's folder with one line:export CLAUDE_CONFIG_DIR="$HOME/.claude-acme"Run
direnv allowin that folder. direnv refuses to load an.envrcuntil you approve it, and asks again whenever the file changes.cdinto the folder and runclaude. Type/statusto check which account it's using.
direnv looks for the nearest .envrc in the current folder and its parents. If you keep a client's repos together, say under ~/clients/acme/, one .envrc in that parent covers every repo below it. That also keeps the file out of the client's repositories. If you do put it inside a repo, add .envrc to .gitignore: the path to your home folder means nothing to anyone else on the project.
Option 2: a few lines of zsh#
If you'd rather not install anything, zsh can run a function every time the folder changes. Add this to ~/.zshrc:
_claude_account() {
case "$PWD/" in
"$HOME/clients/acme/"*) export CLAUDE_CONFIG_DIR="$HOME/.claude-acme" ;;
"$HOME/clients/globex/"*) export CLAUDE_CONFIG_DIR="$HOME/.claude-globex" ;;
*) unset CLAUDE_CONFIG_DIR ;;
esac
}
autoload -Uz add-zsh-hook
add-zsh-hook chpwd _claude_account
_claude_account
Each line under case maps a folder to an account; the *) line sends every other folder back to your default ~/.claude. Put deeper folders above shallower ones, because the first match wins. This version always clears the variable outside the listed folders, so if you also set CLAUDE_CONFIG_DIR by hand or through an alias, the hook will undo it the next time you cd. It also matches the path as you typed it, so a folder reached through a symlink won't match.
Option 3: Clawdrobe, if your accounts are in Claude Desktop too#
Clawdrobe is a Mac app that gives each Claude account its own copy of Claude Desktop, plus its own Claude Code folder. Starting with Clawdrobe 1.6, folders can belong to an account. If you don't see Folders yet, use Check for Updates… in the Clawdrobe menu.
- Select an added account in Clawdrobe's sidebar. (Your main account is the default everywhere, so it has no folder list.)
- In its Tools section, under Folders, add the client's or project's folders.
- The first time, Clawdrobe shows one line for
~/.zshrcwith a Copy button. Paste it at the end of the file and open a new Terminal window.
Now cd into one of those folders and plain claude runs as that account. Leave the folder and your usual account is back. Some details:
- Subfolders count. A folder you add covers everything inside it. If two accounts claim nested folders, the deepest one wins.
- Symlinks work. The folder matches whether you reach it by the path you typed or by the real path behind a link.
- Your own setting wins. If you set
CLAUDE_CONFIG_DIRyourself, Clawdrobe leaves it alone. It only changes a value it set. - Nothing replaces
claude. Clawdrobe doesn't wrap theclaudecommand or edit your shell files. The line you paste is the only change to your shell setup; it runs a small script Clawdrobe keeps in~/.local/bin. Bash works too (put the line in~/.bash_profile).
Each account's folder also links back to your main ~/.claude for your personal setup, so your CLAUDE.md, settings, slash commands, skills, hooks, plugins and MCP servers come along to every account. One consequence: sessions are shared, so claude --resume and the Claude Desktop Code tab list sessions from every account. If a client contract says their work must stay completely separate from everything else, use option 1 or 2 with a fresh folder for that client instead.
Each account has its own 5-hour and weekly limits, and on Pro and Max Anthropic counts Claude and Claude Code against the same limits. Clawdrobe shows both meters for every account in one window, so you can see whether the client's account has room before a long session.
Clawdrobe is free for two accounts with every feature, and Clawdrobe Pro is a one-time $10 for more. It needs macOS 26 or later and isn't affiliated with Anthropic.
Pitfalls#
- A running session doesn't switch. Claude Code reads
CLAUDE_CONFIG_DIRwhen it starts. Changing folders inside a session, or in the shell after it started, does nothing to it. Quit and startclaudeagain from the right folder. - Starting from the wrong place. The account comes from the folder your shell was in when you typed
claude.claudefrom your home folder runs as your default account, even if you then point it at a client's repo. - An API key in your environment. If
ANTHROPIC_API_KEYis exported, Claude Code can bill that key instead of the folder's subscription once you've approved it. Run/statuswhen the billing looks wrong. - A literal
~. In quotes or in an editor's environment settings,~isn't expanded. Use$HOMEin shell files and a full path such as/Users/you/.claude-acmeeverywhere else. - Apps opened from the Dock. The hook lives in your shell, so it only applies to
claudestarted from a terminal. Anything launched another way gets whatever environment that app has. - A login in the wrong folder. If you ran
/loginin the client's folder with your own account by mistake, run/logoutthere and sign in again. It only affects that one folder.
Which one should you pick?#
- You already use direnv: add an
.envrcand you're done. - You want no extra tools and have a couple of clients: the zsh function.
- You use Claude Desktop with the same accounts, or want to see each account's limits: Clawdrobe's folders, set from the account's Tools.
If you're still setting up the accounts themselves, start with how to use multiple accounts in Claude Code, and for keeping the habits straight day to day, see how to manage multiple Claude accounts.
More from the blog
Switched accounts in Claude Desktop and the Code tab is empty? Your sessions aren't deleted. Why the list changes, how to get them back, and how to see them everywhere.
Stay signed in to a work and a personal Claude account at the same time in the browser, Claude Desktop and Claude Code, without the sign-in landing in the wrong one.
Hit "5-hour limit reached" or "You've reached your weekly limit" in Claude? How to tell which limit stopped you, your options, and how to avoid a repeat.
Every Claude account, side by side
Clawdrobe is free for two accounts. macOS 26 or later · Apple silicon and Intel.


