4 ms·
Show HN: Claude-account – switch Claude Code accounts without logging in again
I use separate Claude Code accounts for work and personal projects. Having to log out and go through the login flow every time I switched accounts became annoying, so I built a small CLI to solve it.
The commands are intentionally simple:
claude account add myworkaccount
claude account add mypersonalaccount
claude account use myworkaccount
claude account current
After switching, Claude Code works normally:
claude
claude "fix this bug in main.py"
Repository: https://github.com/hamzarehmandeveloper/claude-account https://github.com/hamzarehmandeveloper/claude-account
Give it a try
- pandoro 2mo agoI use this: https://gist.github.com/KMJ-007/0979814968722051620461ab2aa01bf2 https://gist.github.com/KMJ-007/0979814968722051620461ab2aa0... Simple and works great but requires one alias per account
- orliesaurus 2mo agosimple and easy - thank you
- cowlby 2mo agoThis is great. My enhancement was to create a .claude-profile file which specifies the account alias. "claude" can be aliased to read the file, set the correct env var, and launch claude. Another benefit was if no .claude-profile file exists, claude refuses to launch.
- bdemirkir 2mo agoOr use https://omp.sh https://omp.sh and add multiple accounts. omp tracks usage and when limit is reached it uses the next account.
- AlexErrant 2mo agoSadly incompatible with Claude subs.
- bdemirkir 2mo agoSubs are supported
- AlexErrant 2mo agoDoesn't this require pi, which CC famously bans you for using?
- kn9 2mo agoTry https://www.onorca.dev/ https://www.onorca.dev/ too very good
- dotancohen 2mo agoDoes it share the global ~/.claude/CLAUDE.md file? For some use case I'd like that, for others it could be problematic.
- cute_boi 2mo ago[flagged]
- carloslfu 2mo agothanks for sharing this one!
- dotancohen 2mo ago> Do you expect vibe-coded slop to care about such things? I'm divorced - I no longer have any expectations. I ask.
- brentmitchell25 2mo agoAnother way for those who use mise. You can auto-switch accounts by directory: ~/development/account1/mise.toml: [env] CLAUDE_CONFIG_DIR = "{{ env.HOME }}/.claude-account1"
- acuteaura 2mo agorevolutionary. you can do this with 2 lines of shell code. i do this: https://github.com/acuteaura/universe/blob/main/overlays/claude-wrap.nix https://github.com/acuteaura/universe/blob/main/overlays/cla...
- carloslfu 2mo agoappreciate you building this! I have two Claude max accounts. The way I do it is that I have two app launchers (claude desktop). I use the desktop app and a different data directory for each launcher like `open -n -a /Applications/Claude.app --args --user-data-dir="<its profile directory>"`. I got my first Claude to make me two different launchers for the two apps, and it's been working perfectly. wdyt? The only problem I've noticed is with Claude in Chrome. It seems to not work well in the second account. And this makes sense because it was designed just for one app. Do you find yourself having the same problem with this setup? have you tried the second one with the Claude in Chrome ext?
- baron3dl 2mo agodon't people get banned for doing this kind of thing?
- dpoloncsak 2mo agoIf it's honestly 'One account is paid for by my employer and used as a tool for my job' and 'One account is for personal use, where I work on passion-projects and the likes' I think it's fine....? Not a lawyer but I'd assume as long as you're not using it to bypass usage limits Anthropic wouldn't even really notice or care.
- baron3dl 2mo agonot sure law matters, anthropic is draconian about bans/appeals.
- rew0rk 2mo agoThe threat of account bans and a less than friendly appeal system does make me wary of trying it, even though this would be incredibly useful.
- ttoinou 2mo agoA lot of them also don’t get banned, right ? There are vibecoders youtubers switching accounts all the time So what’s the differenve ?
- pwython 2mo agoI use the Claude Code desktop app for work, and the CLI for personal, so I'm always logged into both accounts!
- swyx 2mo agodoes this also extend to codex?
- hamza_rehman 2mo agoNot currently It is specific to Claude Code right now
- hmokiguess 2mo agoI built the same thing for myself, but I like your implementation so much better.
- noobmax 2mo ago[dead]
- hassanmehdi98 2mo agoIs it even safe to switch accounts frequently? worried about them imposing a ban
- DobarDabar 2mo ago[dead]
- pdimitar 2mo agoCool but I would like to reuse my entire account directory and just switch accounts and nothing else. Now I just do `/logout` and then go through the login flow again because I don't want to lose access to all memories and transcripts. Is that supported?
- hamza_rehman 2mo agoNo, I kept the whole CLAUDE_CONFIG_DIR isolated because I didn’t want it to directly copying or replacing Claude’s credential files. It felt too easy to get wrong
- lukasco 2mo agoCan you be logged into two accounts at once? It's not the switching, but the different sessions on different accounts that I find myself doing. As some have said, easy enough to build yourself, but I think it' nice not to have to test it and make sure it works.
- spk_ 2mo agoYes, you can, just need to set a separate config dir. I have the below in my zshrc. alias claude-personal='CLAUDE_CONFIG_DIR=~/.claude-personal claude'
- hamza_rehman 2mo agoYep, that’s supported. Switching only affects newly started Claude processes, so you can keep work open in one terminal and personal in another using claude account
- kingzabbu 2mo agoIs this safe to use? as some print from other accounts may leak and will it not harm the accounts?
- mlitwiniuk 2mo agoAnd knowing Anthropic being developer friendly we can expect them to ban this in 3... 2...
- hamza_rehman 2mo ago[dead]