I do client work. Most of my clients give me a seat on their own Claude Code account, and a few give me a Codex login too. That's the right call for them: the usage is billed to the client, the work stays inside their organisation, and nothing of theirs ends up on my personal account.
For me it meant a day that looked like this:
- Deep in a session for Client A.
- Client B pings with a bug.
- Log out, log in to the other account, wait for the browser.
- New session. Re-explain the whole task from scratch.
- An hour later, do it all again in the other direction.
I was spending more time switching logins than writing code. So I built hatswap, a small open-source CLI that keeps every Claude Code account signed in at once and moves work between them. Different client, different hat. (If you saw it on X, it was called claude-account until this week; old links redirect.)
How it works (the short version)
Claude Code stores its login per configuration directory. hatswap gives each account its own CLAUDE_CONFIG_DIR under ~/.claude-accounts/<name>, so each one keeps its own login (in the macOS Keychain, or in that directory on Linux) and they never overwrite each other.
Everything else (settings, skills, agents, plugins, MCP servers, memory and history) is symlinked from your normal ~/.claude, so every account has the same setup. Only the login changes.
It never reads, copies or touches your credentials. Every sign-in is done by Claude Code itself. And if you have ANTHROPIC_API_KEY exported, hatswap clears it whenever it starts Claude on a named account, with a one-line note, so the key doesn't quietly override that account's login and bill the wrong place.
curl -fsSL https://raw.githubusercontent.com/orvi2014/hatswap/main/install.sh | bash
hatswap add acme # browser opens, sign in to the client's account
hatswap list
# main me@personal.com (~/.claude)
# acme me@acme.com
Your existing login shows up as main and is used as-is.
1. Move the conversation you're in to another account
This is the one I use most. Halfway through a task I realise I'm on the wrong account. Inside Claude Code:
! hatswap switch acme
A running Claude Code process can't change its login, so switch restarts it with --resume on the other account. Same conversation, same session ID, full history. It even restarts it in the same tab:
- tmux (including desktop apps that host each tab in tmux): the pane is respawned with its original flags, hooks and MCP config.
- Terminal.app / iTerm2 on macOS: Claude exits and the resume command is typed back into that tab.
-
Anything else:
/exit, then runhatswap switch acmein the same terminal.
There's a /switch acme slash command too.
2. Pin a client's folder to their account
Remembering which account goes with which repo is exactly the kind of thing I get wrong at 6 pm.
cd ~/clients/acme && hatswap pin acme
Now plain claude in that folder, and every folder under it, starts on Acme's account. Outside it, you get your default. The pin is a one-line .hatswap file, and inside a git repo it's added to .git/info/exclude, so it never gets committed to the client's repo.
The order is: an explicit CLAUDE_CONFIG_DIR first, then the nearest pin, then your default account (hatswap default <name>), then main. hatswap whoami tells you which one applies and why.
3. Keep client conversations apart
By default all accounts share conversation history, which is great for your own projects. For client work you often don't want Client A's account able to read what you did for Client B:
hatswap add acme --private # or: hatswap private acme
A private account keeps its conversations and memory in its own folder. Settings, skills and MCP servers are still shared. If you deliberately hand one of its conversations to another account, it's copied over and the command tells you so.
4. Hand a task to Codex (on the right Codex account)
Sometimes I want a second opinion, or I want to try something quickly in Codex:
hatswap handoff codex
Replaying a 200k-token conversation into another tool doesn't work, so this writes a handoff brief instead:
- Goal, in the user's words
- Done (verified): commits, PRs, test results
- In flight: the exact step that was in progress
- Decisions and constraints, quoting the user for strict rules
- Tried and rejected: approaches that were dropped, and why, so the next agent doesn't walk into the same dead end
- Key pointers, Open questions and Next step
It also collects your current branch, uncommitted changes, recent commits and open PRs, and tells the brief-writer to treat those as ground truth over the transcript. Passwords, API keys and tokens are redacted before anything is summarised.
Each account can also have its own Codex login:
hatswap codex-login acme # Acme's Codex account, in its own CODEX_HOME
hatswap handoff codex # uses the Codex login of the session's account
So a session on Acme's Claude account hands off to Acme's Codex, not yours.
5. Restart a session that got too long
Long sessions get slow and lose the plot. Instead of compacting again:
hatswap refresh # same account, fresh session, seeded with the brief
hatswap refresh --edit # read and fix the brief first
A fresh session that starts from a couple of thousand tokens of accurate brief beats one dragging 200k tokens of history.
What it is not
It's not a way to pool or get around usage limits. Creating accounts to evade limits, or sharing and reselling accounts, isn't allowed under Anthropic's terms, and the tool never switches accounts on its own. It's for people who legitimately work across several accounts: clients, a day job and side projects, personal and work.
It also reads Claude Code's on-disk session files, which aren't a public API. That format could change between versions, so the tool may need updating when it does.
Try it
It's one bash script plus Python 3, on macOS and Linux, MIT licensed, with 151 tests running in CI on both.
curl -fsSL https://raw.githubusercontent.com/orvi2014/hatswap/main/install.sh | bash
If it saves you some logging in and out, I'd really appreciate a ⭐ on the repo. It helps other people juggling several accounts find it. Issues and PRs are very welcome, and I'd love to hear how you're handling multiple accounts today.

Top comments (2)
Some comments may only be visible to logged-in visitors. Sign in to view all comments.