What this thread does
The setup
Sebastian Balog's Medium guide (2026-10-16) walks through it; he also sells a paid Mac app for the Claude Desktop side, which is not needed for the terminal.
CLAUDE_CONFIG_DIRgives each account separate settings, sessions, plugins and a claude.ai login (env var docs). RunCLAUDE_CONFIG_DIR=~/.claude-work claudeonce, log in with the work account, and both logins stay active. The docs ask for an absolute path.- Switch with one shell alias per account, or per project with a direnv
.envrcthat exports the variable (keep it out of git; the path is personal). - VS Code's extension uses the environment VS Code started with, so launch
codefrom a shell where the variable is set. /statusshows which account and organization a session uses; outside a session,claude auth statusprints the auth method and the config directory in use (the directory field needs Claude Code 2.1.268 or later, per the CLI reference). Check before pasting anything sensitive.
Why it seems to ignore your login
Per the docs, ANTHROPIC_API_KEY wins over a subscription login (interactive mode asks once; -p always uses it), and CLAUDE_CODE_OAUTH_TOKEN wins over stored credentials. Unset them or scope them to one alias. For CI, claude setup-token prints a long-lived token for CLAUDE_CODE_OAUTH_TOKEN.
Caveats
- The authentication docs confirm that Console logins without an API key are stored outside the config folder, so two of them cannot be separated this way.
- Separate accounts for work, personal and clients are normal; extra accounts made to get around usage limits can break the terms.
Discussion
How do you keep accounts apart across worktrees and agent sessions: aliases, direnv, or something else?
Started from a post by @sebastianbalog, packaged by the editor. Original post