An open API service indexing awesome lists of open source software.

https://github.com/yangtaeyoung/claude-switch

πŸ”„ Switch between multiple Claude Code subscription accounts with one command β€” Keychain-native, with per-account usage limit visibility (macOS)
https://github.com/yangtaeyoung/claude-switch

account-switcher anthropic claude claude-code cli developer-tools golang keychain macos rate-limit

Last synced: 2 days ago
JSON representation

πŸ”„ Switch between multiple Claude Code subscription accounts with one command β€” Keychain-native, with per-account usage limit visibility (macOS)

Awesome Lists containing this project

README

          

# πŸ”„ claude-switch

**Claude Code 토큰 리밋이 μ°Όλ‹€λ©΄? λͺ…λ Ή ν•˜λ‚˜λ‘œ λ‹€μŒ ꡬ독 κ³„μ •μœΌλ‘œ μ „ν™˜ν•˜μ„Έμš”.**

[![CI](https://github.com/YangTaeyoung/claude-switch/actions/workflows/ci.yml/badge.svg)](https://github.com/YangTaeyoung/claude-switch/actions/workflows/ci.yml)
[![Release](https://img.shields.io/github/v/release/YangTaeyoung/claude-switch?logo=github)](https://github.com/YangTaeyoung/claude-switch/releases/latest)
[![Go Version](https://img.shields.io/badge/Go-1.25+-00ADD8?logo=go&logoColor=white)](https://go.dev/)
[![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-black)](https://github.com/YangTaeyoung/claude-switch/releases/latest)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

[English](README.md) Β· [ν•œκ΅­μ–΄](README.ko.md)

---

![claude-switch μΈν„°λž™ν‹°λΈŒ TUI 데λͺ¨](docs/demo.gif)

```console
$ claude-switch next
Switched to profile "personal" (personal@example.com)
Takes effect for new claude sessions. Restart any running session.

$ claude-switch status
Active profile: personal

work work@example.com limit: allowed | 5h 80% (resets 06-12 16:00) | 7d 12% (resets 06-19 14:00)
* personal personal@example.com limit: allowed | 5h 3% (resets 06-12 18:00) | 7d 40% (resets 06-15 09:00)
```

## ✨ μ£Όμš” κΈ°λŠ₯

- **πŸ–₯️ μΈν„°λž™ν‹°λΈŒ TUI** β€” 인자 없이 `claude-switch`λ₯Ό μ‹€ν–‰ν•˜λ©΄ ν’€μŠ€ν¬λ¦° ν™ˆ 메뉴: ν”„λ‘œν•„ 관리(μ „ν™˜Β·μ΄λ¦„λ³€κ²½Β·μ‚­μ œ + μ‹€μ‹œκ°„ μ‚¬μš©λŸ‰), ν˜„μž¬ 계정 μ €μž₯, μ„€μ •. [Bubble Tea v2](https://github.com/charmbracelet/bubbletea) 기반.
- **🌐 English / ν•œκ΅­μ–΄** β€” μ„€μ • ν™”λ©΄ λ˜λŠ” `claude-switch lang ko`둜 ν‘œμ‹œ μ–Έμ–΄ μ „ν™˜.
- **πŸ”” 항상 μ΅œμ‹  버전** β€” TUIκ°€ ν•˜λ£¨ ν•œ 번 쑰용히 GitHub 릴리즈λ₯Ό 확인해 μƒˆ 버전이 있으면 μ•Œλ €μ€λ‹ˆλ‹€. μ–Έμ œλ“  `claude-switch update`둜 직접 μ—…λ°μ΄νŠΈν•˜κ±°λ‚˜, μ„€μ •μ—μ„œ **μ‹œμž‘ μ‹œ μžλ™ μ—…λ°μ΄νŠΈ**λ₯Ό 켜면 μžλ™μœΌλ‘œ μ΅œμ‹  λ²„μ „μœΌλ‘œ μ˜¬λΌκ°‘λ‹ˆλ‹€.
- **⚑ λͺ…λ Ή ν•˜λ‚˜λ‘œ μ „ν™˜** β€” `claude-switch next` ν•œ 번이면 λ‹€μŒ 등둝 κ³„μ •μœΌλ‘œ μˆœν™˜. μ…Έ λž˜νΌλ„, ν™˜κ²½λ³€μˆ˜λ„, μž¬λ‘œκ·ΈμΈλ„ ν•„μš” μ—†μŠ΅λ‹ˆλ‹€.
- **πŸ“Š 계정별 μ‚¬μš©λŸ‰ ν•œλˆˆμ—** β€” `status`κ°€ Anthropic의 `anthropic-ratelimit-unified-*` ν—€λ”μ—μ„œ μ½μ–΄μ˜¨ **μ‹€μ œ 5μ‹œκ°„/7일 μ‚¬μš©λ₯ κ³Ό 리셋 μ‹œκ°**을 κ³„μ •λ³„λ‘œ λ³΄μ—¬μ€λ‹ˆλ‹€. μ–΄λŠ 계정에 μ—¬μœ κ°€ μžˆλŠ”μ§€ μ „ν™˜ *전에* μ•Œ 수 μžˆμŠ΅λ‹ˆλ‹€.
- **πŸ” Claude Code와 λ™μΌν•œ λ°©μ‹μœΌλ‘œ μ €μž₯** β€” macOSμ—μ„œλŠ” 킀체인(평문 μ €μž₯ μ—†μŒ), Linux/Windowsμ—μ„œλŠ” Claude Code 자체의 `.credentials.json` μ˜†μ— `0600` κΆŒν•œ 파일둜 μ €μž₯ν•©λ‹ˆλ‹€. OSκ°€ μ“°λŠ” 방식을 κ·ΈλŒ€λ‘œ λ”°λ¦…λ‹ˆλ‹€.
- **πŸ” 토큰 νšŒμ „ λŒ€μ‘** β€” Claude CodeλŠ” μ‚¬μš© 쀑 refresh token을 νšŒμ „μ‹œν‚΅λ‹ˆλ‹€. claude-switchλŠ” μ „ν™˜ 직전 μ‚΄μ•„μžˆλŠ” 자격증λͺ…을 ν™œμ„± ν”„λ‘œν•„μ— *sync-back* ν•˜λ―€λ‘œ, μ§€λ‚œμ£Όμ— μ €μž₯ν•œ ν”„λ‘œν•„λ„ 였늘 κ·ΈλŒ€λ‘œ λ™μž‘ν•©λ‹ˆλ‹€.
- **πŸͺΆ μ΅œμ†Œ μ˜μ‘΄μ„±** β€” Go ν‘œμ€€ 라이브러리 + Charm μŠ€νƒ(Bubble Tea v2, Lip Gloss v2). μž‘μ€ λ°”μ΄λ„ˆλ¦¬ ν•˜λ‚˜.

## πŸ“¦ μ„€μΉ˜

[μ΅œμ‹  릴리즈](https://github.com/YangTaeyoung/claude-switch/releases/latest)μ—μ„œ **λΉŒλ“œλœ λ°”μ΄λ„ˆλ¦¬**(macOS μœ λ‹ˆλ²„μ„€, Linux amd64/arm64, Windows amd64/arm64)λ₯Ό λ°›κ±°λ‚˜:

```shell
go install github.com/YangTaeyoung/claude-switch@latest
```

μ†ŒμŠ€μ—μ„œ λΉŒλ“œ:

```shell
git clone https://github.com/YangTaeyoung/claude-switch.git
cd claude-switch && go build -o claude-switch .
```

## πŸš€ λΉ λ₯Έ μ‹œμž‘

**1. κ³„μ •λ§ˆλ‹€ ν•œ λ²ˆμ”© 등둝** β€” Claude Code둜 λ‘œκ·ΈμΈν•œ λ’€ μŠ€λƒ…μƒ·:

```shell
claude # Aκ³„μ •μœΌλ‘œ /login ν›„ μ’…λ£Œ
claude-switch save work

claude # Bκ³„μ •μœΌλ‘œ /login ν›„ μ’…λ£Œ
claude-switch save personal
```

**2. 리밋이 μ°¨λ©΄:**

```shell
claude-switch next
```

끝. μƒˆλ‘œ μ‹œμž‘ν•˜λŠ” `claude` μ„Έμ…˜λΆ€ν„° λ‹€μŒ 계정이 μ μš©λ©λ‹ˆλ‹€.

### 전체 λͺ…λ Ή

| λͺ…λ Ή | λ™μž‘ |
|---|---|
| `claude-switch` | μΈν„°λž™ν‹°λΈŒ λŒ€μ‹œλ³΄λ“œ(TUI) β€” μ „ν™˜Β·μ‚­μ œΒ·μ‹€μ‹œκ°„ μ‚¬μš©λŸ‰ |
| `claude-switch save ` | ν˜„μž¬ 둜그인된 계정을 ν”„λ‘œν•„λ‘œ μ €μž₯ |
| `claude-switch use ` | μ§€μ • ν”„λ‘œν•„λ‘œ μ „ν™˜ |
| `claude-switch next` | λ‹€μŒ ν”„λ‘œν•„λ‘œ μˆœν™˜ μ „ν™˜ |
| `claude-switch list` | ν”„λ‘œν•„ λͺ©λ‘ (`*` = ν™œμ„±) |
| `claude-switch status` | 계정별 μ‚¬μš©λŸ‰(5h/7d)κ³Ό 리셋 μ‹œκ° |
| `claude-switch rename ` | ν”„λ‘œν•„ 이름 λ³€κ²½ |
| `claude-switch delete ` | ν”„λ‘œν•„ μ‚­μ œ (ν™œμ„± ν”„λ‘œν•„μ€ 보호) |
| `claude-switch lang ` | ν‘œμ‹œ μ–Έμ–΄ μ„€μ • |
| `claude-switch update` | μ΅œμ‹  릴리즈λ₯Ό λ‚΄λ €λ°›μ•„ μ„€μΉ˜ |
| `claude-switch version` | 버전 좜λ ₯ |

### μžλ™ μ—…λ°μ΄νŠΈ

claude-switchλŠ” [GitHub 릴리즈](https://github.com/YangTaeyoung/claude-switch/releases)μ—μ„œ μƒˆ 버전을 ν™•μΈν•©λ‹ˆλ‹€. 기본값은 **μ•Œλ¦Όλ§Œ** β€” μƒˆ 버전이 있으면 TUI에 λ°°λ„ˆκ°€ λœΉλ‹ˆλ‹€(μ΅œλŒ€ 24μ‹œκ°„μ— ν•œ 번 ν™•μΈν•˜λ©°, `go install`둜 λΉŒλ“œν•œ dev λ°”μ΄λ„ˆλ¦¬μ—μ„œλŠ” ν™•μΈν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€). μ—…λ°μ΄νŠΈ μ‹œμ μ€ `claude-switch update`둜 직접 μ •ν•˜μ„Έμš”.

TUI μ‹œμž‘ μ‹œ μžλ™μœΌλ‘œ 올리렀면 μ„€μ •μ—μ„œ **μ‹œμž‘ μ‹œ μžλ™ μ—…λ°μ΄νŠΈ**λ₯Ό μΌœκ±°λ‚˜, `~/.config/claude-switch/config.json`에 직접 μ„€μ •ν•˜μ„Έμš”:

```json
{ "autoUpdate": true }
```

> μžκ°€ μ—…λ°μ΄νŠΈλŠ” μ‹€ν–‰ 쀑인 λ°”μ΄λ„ˆλ¦¬λ₯Ό μ œμžλ¦¬μ—μ„œ κ΅μ²΄ν•˜λ―€λ‘œ, μ„€μΉ˜λœ μœ„μΉ˜μ— μ“°κΈ° κΆŒν•œμ΄ ν•„μš”ν•©λ‹ˆλ‹€(`go install` κ²½λ‘œμ™€ 직접 λ‹€μš΄λ‘œλ“œλŠ” λ¬Έμ œμ—†μŒ). μΆ”ν›„ νŒ¨ν‚€μ§€ λ§€λ‹ˆμ €λ‘œ μ„€μΉ˜ν•œλ‹€λ©΄ μžλ™ μ—…λ°μ΄νŠΈλŠ” 끄고 λ§€λ‹ˆμ €λ‘œ μ—…κ·Έλ ˆμ΄λ“œν•˜λŠ” 것을 ꢌμž₯ν•©λ‹ˆλ‹€.

## βš™οΈ λ™μž‘ 원리

Claude CodeλŠ” OSκ°€ 비밀값을 λ³΄κ΄€ν•˜λŠ” 곳에 OAuth 자격증λͺ…을 μ €μž₯ν•©λ‹ˆλ‹€ ([곡식 λ¬Έμ„œ](https://code.claude.com/docs/en/authentication)). macOSμ—μ„œλŠ” **킀체인 ν•­λͺ©** `Claude Code-credentials`, Linux/Windowsμ—μ„œλŠ” 파일 `~/.claude/.credentials.json`(κΆŒν•œ `0600`)μž…λ‹ˆλ‹€. claude-switchλŠ” OS에 λ§žλŠ” λ°©μ‹μœΌλ‘œ 이 자격증λͺ…을 ν”„λ‘œν•„ λ‹¨μœ„λ‘œ κ΅μ²΄ν•©λ‹ˆλ‹€:

```mermaid
flowchart LR
subgraph Store["πŸ” 자격증λͺ… μ €μž₯μ†Œ (macOSλŠ” 킀체인 Β· Linux/WindowsλŠ” 0600 파일)"]
CC["Claude Code-credentials
(라이브)"]
P1["profile: work"]
P2["profile: personal"]
end
next["claude-switch next"] -- "β‘  sync-back
(νšŒμ „λœ 토큰 반영)" --> P2
CC -. "β‘ " .-> P2
P1 -- "β‘‘ 볡원" --> CC
next -- "β‘’ ~/.claude.json의
oauthAccount ꡐ체" --> CJ["~/.claude.json"]
```

1. **Sync-back** β€” μ‚΄μ•„μžˆλŠ”(νšŒμ „λμ„ 수 μžˆλŠ”) 자격증λͺ…을 ν˜„μž¬ ν™œμ„± ν”„λ‘œν•„μ— λ¨Όμ € 반영
2. **볡원** β€” λŒ€μƒ ν”„λ‘œν•„μ˜ 자격증λͺ…을 라이브 `Claude Code-credentials` ν•­λͺ©μ— 기둝
3. **계정 정보 ꡐ체** β€” `~/.claude.json`의 `oauthAccount`λ₯Ό ꡐ체해 `/status`에 μ˜¬λ°”λ₯Έ 계정이 ν‘œμ‹œλ˜κ²Œ 함

`~/.config/claude-switch/config.json`μ—λŠ” 비밀값이 μ•„λ‹Œ 메타데이터(ν”„λ‘œν•„λͺ…, μˆœμ„œ, 이메일)만 μ €μž₯λ©λ‹ˆλ‹€.

## ⚠️ ν•œκ³„

- **크둜슀 ν”Œλž«νΌ.** macOSλŠ” 킀체인을, Linux/WindowsλŠ” Claude Code 자체의 `~/.claude/.credentials.json`(`0600`)을 직접 읽고 μ”λ‹ˆλ‹€. Linux/Windowsμ—μ„œλŠ” 자격증λͺ…이 평문 파일둜 μ €μž₯되며 β€” Claude Code μžμ²΄μ™€ λ™μΌν•œ 방식 β€” μ‚¬μš©μž κ³„μ •μ˜ 파일 κΆŒν•œ μˆ˜μ€€λ§ŒνΌλ§Œ λ³΄ν˜Έλ©λ‹ˆλ‹€.
- **μ‹€ν–‰ 쀑인 μ„Έμ…˜μ€ κΈ°μ‘΄ 계정 μœ μ§€** β€” μ „ν™˜μ€ μƒˆ `claude` μ„Έμ…˜λΆ€ν„° μ μš©λ©λ‹ˆλ‹€.
- **`status`λŠ” ν”„λ‘œν•„λ‹Ή μ΅œμ†Œ inference μš”μ²­ 1회λ₯Ό λ³΄λƒ…λ‹ˆλ‹€** (haiku 1토큰) β€” 무과금 μ—”λ“œν¬μΈνŠΈλŠ” 리밋 헀더λ₯Ό λ°˜ν™˜ν•˜μ§€ μ•ŠλŠ” 것을 μ‹€μΈ‘μœΌλ‘œ ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€. λΉ„μš©μ€ κ·Ήλ―Έν•˜μ§€λ§Œ 0은 μ•„λ‹™λ‹ˆλ‹€.
- macOSμ—μ„œλŠ” 첫 킀체인 μ ‘κ·Ό μ‹œ ν—ˆμš© ν”„λ‘¬ν”„νŠΈκ°€ 뜰 수 μžˆμŠ΅λ‹ˆλ‹€ β€” "항상 ν—ˆμš©"을 μ„ νƒν•˜μ„Έμš”.

## πŸ“„ λΌμ΄μ„ μŠ€

[MIT](LICENSE)

---


Go둜 μ œμž‘ Β· Anthropicκ³Ό λ¬΄κ΄€ν•œ 개인 ν”„λ‘œμ νŠΈ