hatswap: Run multiple Claude Code accounts at once

An open-source CLI to run multiple Claude Code accounts at once, one per client. Switch a running conversation between them, history intact.

$curl -fsSL https://raw.githubusercontent.com/orvi2014/hatswap/main/install.sh | bash
View on GitHub
~/billing main · personal@example.com
Same chat. Different hat.

The problem

Changing accounts used to cost you the conversation.

Claude Code holds one login at a time, so switching Claude Code accounts meant logging out, signing in through the browser, and starting again from nothing.

Without hatswap context lost

Every switch is a logout, a browser sign-in and a blank session.

> Invoice totals are off by a cent ⏺ Found it: tax is rounded before the discount. > Fix it and add a test ⏺ Done. 3 files changed, tests pass. the whole conversation, gone
> /logoutOpening browser to sign in…

With hatswap same chat

One command. The tab restarts on the other account and the conversation carries on.

✻main · personal@example.comacme · you@acme.examplemain · personal@example.com
> Invoice totals are off by a cent ⏺ Found it: tax is rounded before the discount. > Fix it and add a test ⏺ Done. 3 files changed, tests pass.
> /switch acme ✓ resumed on you@acme.example

Built for people who bill more than one client.

Multiple accounts, all signed in

Each client keeps its own login. Run two of them in two terminals at once. hatswap add acme

main██░░░░░░░░24%
acme██████░░░░64%
work█░░░░░░░░░10%

Folders that know their client

Pin a folder once. Every claude started inside it uses that client's account.

~/clients/
  ├─ acme/ acme
  ├─ globex/ work
  └─ anywhere else → your default

Hand off to Codex

Claude writes a brief of the session and repo state; Codex starts from it.

handoff-brief.md
Codex

Private history per client

History is shared by default. Mark a client private and its chats stay with it.

acmeprivate history
not shared
workshared history

Always know where you are

The account sits in Claude Code's status line. statusline --install

> review the migration
◆acme · you@acme.example

How it works

One folder per login. Everything else is shared.

~/.claude settings, skills, plugins, hooks CLAUDE.md, agents, history symlinks main personal login acme acme login work work login
  • Logins stay separateEach account is its own CLAUDE_CONFIG_DIR, so Claude Code keeps a separate sign-in for it (its own Keychain item on macOS). hatswap never reads or copies credentials.
  • Your setup is written onceSettings, skills, plugins, hooks and history are linked from ~/.claude. Nothing to keep in sync.
  • Plain claude picks the accountA one-line shell hook finds the nearest pinned folder, falls back to your default, and starts Claude there.
  • It never switches on its ownAccounts change only when you ask. hatswap usage reports limits and does nothing else.

Running in two minutes.

zsh
 

More than a CLAUDE_CONFIG_DIR alias

An alias per account gets you a second login. hatswap adds what client work needs on top. See how it differs from other account switchers.

alias claude-acme='CLAUDE_CONFIG_DIR=… claude'hatswap
A separate login per accountYesYes
Settings, skills, plugins and history sharedNo, each folder starts emptyYes, linked from ~/.claude
Plain claude picks the account per folderNoYes, with pin
Move a live conversation to another accountNoYes, /switch
Hand a session to Codex with a briefNoYes, /handoff codex
Every account's usage in one tableNoYes, usage
Switches accounts automatically at a limitNoNo, by design

Before you install

Is it allowed to use several Claude Code accounts?

hatswap is for accounts you legitimately hold, such as your own and the seats clients give you. It never switches accounts automatically and does not rotate between accounts when you hit a limit. Creating accounts to get around usage limits, or sharing and reselling them, is against Anthropic's policies.

How do I switch Claude Code accounts without logging out?

Add each account once with hatswap add, then run /switch <account> inside Claude Code. The session restarts on the other account and resumes the same conversation; in tmux, iTerm2 and Terminal.app it happens in the same tab.

Does hatswap touch my credentials?

No. Sign-in is handled entirely by Claude Code; hatswap only chooses which config folder Claude starts with. Handoff briefs are written through your own Claude login, with common secret formats redacted first.

Can one client see another client's conversations?

By default every account shares history, which is what most people want on their own machine. Run hatswap private <account> and that account keeps its conversations and memory to itself.

What do I need to run it?

macOS or Linux, Bash 3.2 or later, Python 3 and Claude Code. tmux, iTerm2 or Terminal.app let a switch restart the same tab; the Codex CLI is needed only for Codex handoffs.

Is hatswap official?

No. hatswap is an independent, MIT-licensed open-source project. Claude Code's session format is not a public interface, so a Claude Code update can occasionally need hatswap update.

The right hat for every client.

Free and open source. One line to install.

$curl -fsSL https://raw.githubusercontent.com/orvi2014/hatswap/main/install.sh | bash
Star on GitHub