ai newsMo., 2. Nov.
EilmeldungAnthropic’s message threads let Claude agents skip resending chats

Why my saved Claude Code logins kept dying, and the switcher I built around it

I pay for more than one Claude subscription, and I wanted plain claude to run on whichever one has room left, without losing my sessions or splitting my history in two. The obvious fix looked easy: keep a copy of each account's login file and copy the right one back when I want to switch. It worked

dev.toMontag 20:35 · 02.11.2 Min. Lesezeit
Bild: dev.to

I pay for more than one Claude subscription, and I wanted plain claude to run on whichever one has room left, without losing my sessions or splitting my history in two.

The obvious fix looked easy: keep a copy of each account's login file and copy the right one back when I want to switch. It worked for a few hours. Then Claude Code started asking me to log in again.

Repo: https://github.com/Abubakr-Alsheikh/claude-account-switch

Claude Code signs in with OAuth. It holds a short-lived access token, about 8 hours, and a refresh token. When the access token runs out, Claude Code trades the refresh token for a new pair and writes both back.

The server accepts each refresh token once. After a renewal, the old one is dead.

So a copy you saved on Monday dies the moment any running claude renews that login on Monday night. Copy it back on Tuesday and you are logged out. Every "save the file, swap the file" approach hits this.

claude-switch keeps one Claude Code profile and swaps only the login. To stay correct with single-use tokens:

$ claude-switch list CLAUDE ACCOUNTS active: work (me@work.example) name email plan weekly use (resets) 5-hour use (resets) renewed ends >> work me@work.example Ultra #######... 71% Sun 09:00 ###... 48% 17:00 10-30 12:10 11-24 personal me@home.example Max ##........ 18% Tue 21:00...... 0% 19:40 10-30 09:02 11-19 Most weekly room: personal (18% used) -> claude-switch use personal or claude-switch auto Enter fullscreen mode Exit fullscreen mode claude-switch use personal swaps the login. In an open session, /exit and claude -c continue the same conversation on the other account.

Getting this right meant reading how Claude Code itself behaves, version by version:

It is unofficial: not made, endorsed or supported by Anthropic. It reads and writes the same files Claude Code uses, so a Claude Code update can break it.

It is for one person moving between their own subscriptions. Don't share logins or pool access, and follow Anthropic's terms for every account. Renewing logins you are not using ( refresh, keepalive ) is opt-in, and the README lists exactly what leaves your machine.

pipx install git+https://github.com/Abubakr-Alsheikh/claude-account-switch@v0.2.1 claude-switch save work claude-switch add personal # then sign the browser into the other account claude auth login claude-switch save personal claude-switch list Enter fullscreen mode Exit fullscreen mode I use it daily on Windows. Linux runs in CI. The macOS code passes its tests against a fake Keychain, but I haven't run it on a real Mac yet, so reports from Mac users are welcome.

Quelle: dev.to (dev.to). Original öffnen