CLAUDE_CONFIG_DIR: what it does in Claude Code
CLAUDE_CONFIG_DIR tells Claude Code to use a different configuration directory instead of the default ~/.claude. Settings, session history, plugins and the login follow it, so each directory acts as a separate Claude Code setup. Anthropic suggests it for keeping a work and a personal account signed in at the same time.
A guide from Switch, an independent Claude Desktop profile manager. Switch is in early access ahead of its public release.
What the variable does
Anthropic’s environment variable reference describes CLAUDE_CONFIG_DIR as an override for the configuration directory, which is ~/.claude by default. All settings, session history and plugins are stored under whatever path you give it.
Nothing else about Claude Code changes. The claude command is the same program; it simply reads and writes a different folder. Start it with one value and you get one setup. Start it with another and you get a second, independent one.
What lives in a configuration directory
According to Anthropic’s guide to the .claude directory, when you set CLAUDE_CONFIG_DIR, every path that would normally sit under ~/.claude lives under your directory instead. That includes:
- Your personal
CLAUDE.md,settings.json, skills, commands, subagents and output styles. - Session transcripts in
projects/, plus auto memory for each project. - File snapshots used for checkpoint restore, plan files and your prompt history.
- Keybindings and custom themes.
Project files are not affected. A repository’s own CLAUDE.md, .claude/ folder and .mcp.json belong to the project, so every configuration directory sees them.
How logins stay separate on a Mac
On macOS, Claude Code stores credentials in the encrypted Keychain. Anthropic’s credential management notes say that with CLAUDE_CONFIG_DIR set, Claude Code keys the Keychain entry to that directory, so a session with a different directory reads a different entry. If the Keychain refuses the write, the fallback .credentials.json file also goes in that directory.
There is one documented exception. Separate directories don’t keep two Claude Console sign-ins made without an API key apart, because Claude Code stores that kind of sign-in outside the configuration directory (authentication docs, as of October 2026).
Environment variables can also override the login in every directory. If ANTHROPIC_API_KEY, ANTHROPIC_AUTH_TOKEN or CLAUDE_CODE_OAUTH_TOKEN is exported in your shell, it can win over the account you signed in with. See how to change your Claude Code account for the full order.
Where to set it
The simplest way is a shell alias, which is the example Anthropic gives. Add it to ~/.zshrc and open a new Terminal window:
alias claude-work='CLAUDE_CONFIG_DIR=~/.claude-work claude'The first run walks you through login and setup for the new directory. Plain claude keeps using ~/.claude.
You can also set the variable in user or managed settings. In a settings file, write the absolute path. Claude Code ignores it in project and local settings, so it can’t be set per repository that way.
To check which directory a shell is using, run claude auth status. On recent versions its JSON output includes a configDirectory field (CLI reference).
Common mistakes
- Forgetting the variable in one window. A Terminal tab without it uses
~/.claudeand its login, which is easy to miss. Aliases avoid this. - Using
~in a settings file. Settings files need the absolute path, such as/Users/you/.claude-work. - Copying a whole folder to make a new one. That copies one account’s history and state into the other. Start from an empty folder and add what you need. Sharing skills and MCP servers covers this.
- Expecting old sessions to follow. Transcripts live in the directory that created them, so
claude --resumein another directory won’t list them. See resuming Claude Code sessions. - An exported API key. It overrides the login in every directory.
How Switch uses it for Claude Desktop
Claude Code inside Claude Desktop doesn’t read your shell aliases. Switch handles that case. Each Switch profile opens Anthropic’s own Claude Desktop app with its own data folder. With Keep coding preferences separate on, which is the default for new profiles, the profile also gets its own Claude Code configuration folder, and Switch launches that profile’s Claude Desktop with CLAUDE_CONFIG_DIR pointed at it.
Switch adds no Terminal command, and each account keeps its own plan and usage limits. How Switch handles Claude Code.