Point CLAUDE_CONFIG_DIR at a second folder and Claude Code runs as a second account, with its own login, settings and history. This post covers the setup, what stays behind in your first folder, and how to keep an eye on each login's usage.
I build a Mac app called Offrun, which does this folder bookkeeping for you. Everything below works with the plain CLIs; there's a short note about the app at the end.
Tested on macOS with Claude Code 2.1.332 and Codex CLI 0.172.0.
Why two accounts
Claude plans limit Claude Code twice: over a session window that resets every few hours, and over a week. Run two or three agents at once and a session can run out halfway through a task:
You've hit your limit · resets 3am If you have a second account, say a work seat and a personal plan, you'll want to carry on with the other one. You may also want the opposite: keep a client repository on the work seat and side projects on your own plan, so neither eats the other's limit.
Claude Code won't switch accounts by itself, and by default it knows one login per machine.
The setup
Claude Code keeps its state in one config folder, ~/.claude by default. Set CLAUDE_CONFIG_DIR and it uses another folder instead. A new, empty folder means a new, signed-out Claude Code:
CLAUDE_CONFIG_DIR=~/.claude-work claude -p "hi" # Not logged in · Please run /login So start it once on the new folder and sign in as the second account:
CLAUDE_CONFIG_DIR=~/.claude-work claude # then, inside Claude Code: /login From then on, start it with the variable for the work account and without it for your default one. An alias saves the typing:
alias claude-work='CLAUDE_CONFIG_DIR=~/.claude-work claude' Run /status inside a session when you want to be sure which account you're on.
What stays behind in the first folder
The new folder starts empty, and almost everything you've set up over time lives in the old one. Here's where things are:
| Lives in the config folder (one per account) | Lives in the repository (shared by both) |
|---|---|
| Sign-in state | CLAUDE.md in the repo |
.claude.json: user-scope MCP servers, per-project state | .claude/settings.json in the repo |
Your personal settings.json and CLAUDE.md | .mcp.json (project MCP servers) |
| Skills, commands, agents, plugins | |
Session history (projects/) |
MCP servers are the easiest to miss. Same machine, two folders:
claude mcp list # claude.ai Google Drive: ... - ✔ Connected # (8 servers in total) CLAUDE_CONFIG_DIR=~/.claude-work claude mcp list # No MCP servers configured. Use `claude mcp add` to add a server. Three ways to deal with it:
- Put shared setup in the repo. Anything in the repository's
CLAUDE.md,.claude/settings.jsonand.mcp.jsonis read by every account. This is the cleanest fix for anything project-specific. - Add user-scope MCP servers again in each account:
CLAUDE_CONFIG_DIR=~/.claude-work claude mcp add -s user .... - Symlink the personal files you want both accounts to share:
ln -s ~/.claude/settings.json ~/.claude-work/settings.json ln -s ~/.claude/CLAUDE.md ~/.claude-work/CLAUDE.md ln -s ~/.claude/skills ~/.claude-work/skills Don't symlink .claude.json. It holds that account's own state, which is the thing you're trying to keep apart.
Where the login actually is (macOS)
On a Mac the sign-in isn't a file in the folder. It's in the login Keychain, one entry per config folder. On my machine:
Claude Code-credentials (the default ~/.claude) Claude Code-credentials-37df6bfa (another folder) Claude Code-credentials-4ce12427 (another folder) So deleting a folder doesn't delete its login. If you're cleaning up an account, remove its entry in Keychain Access as well.
Codex works the same way, with one difference
Codex uses CODEX_HOME. Unlike Claude Code, it won't create the folder for you:
CODEX_HOME=~/.codex-work codex login # Error loading configuration: CODEX_HOME points to "/Users/you/.codex-work", but that path does not exist Create it first:
mkdir -p ~/.codex-work CODEX_HOME=~/.codex-work codex login Pick the account by folder
If the split is "work repos on the work seat", a shell function can choose for you based on where you are. In ~/.zshrc:
claude() { case "$PWD" in $HOME/work/*) CLAUDE_CONFIG_DIR=~/.claude-work command claude "$@" ;; *) command claude "$@" ;; esac } command claude runs the real binary rather than calling the function again. Anything under ~/work now starts on the work account, and everything else on your default one.
History doesn't move between accounts
Each folder keeps its own session history, so claude --resume on one account won't list conversations from the other. When a limit stops you mid-task, the other account starts from nothing.
One thing that helps: before switching, ask the agent that's about to run out to write a short handoff file.
Write HANDOFF.md: the goal, what's done, what's left, the files you changed and anything you were about to try. Then start the other account in the same repo and tell it to read HANDOFF.md. It's a minute of writing instead of re-explaining the task from memory.
Keeping an eye on each account's usage
Run /usage inside a session to see how much of the session window and the week that account has used, and when each resets. With two accounts you run it twice, once per folder:
claude # then /usage claude-work # then /usage There's no single view of both, so it's easy to forget the second account until the first one stops.
A note on terms
Each account is yours, on its own plan and its own terms. Check your provider's terms for how they expect accounts to be used.
About Offrun
Offrun is a Mac app I'm building that runs Claude Code, Codex, Antigravity CLI, Grok Build and Muse Code with the logins you already have. It uses the same folders described above: add each login in Settings, and each one gets its own folder. Home lists every login's usage and when it resets, and when one hits its limit, the chat moves to your next login and tells you so. The agent signs in through its own login; Offrun never reads, copies or stores your tokens.
Everything in this post works without it, so try the plain version first.
What I checked and what I didn't
| What | Status |
|---|---|
An empty CLAUDE_CONFIG_DIR folder is signed out, and .claude.json is created inside it | Run |
| User-scope MCP servers don't carry over to a new folder | Run (claude mcp list in both) |
The per-folder claude() function picks the folder by path | Run in zsh |
CODEX_HOME must exist first; an empty one reports "Not logged in" | Run |
| One Keychain entry per config folder on macOS | Seen in Keychain on my machine |
Symlinked settings.json, CLAUDE.md and skills being picked up by the second account | Not run end to end |
/status, /usage and --resume behaviour per account | Not run for this post |
This post was drafted with AI (Claude), and the commands in it were run to check the results.


