Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ npm run dist # installers for the current OS into dist/
- **Usage** (`usage`): `GET api.anthropic.com/api/oauth/usage`, at most every 10 minutes per account. Answers are cached in `~/.claude-profiles/.usage-cache.json` (numbers only); after a 429 it waits for `Retry-After`. The active account reuses Claude Code's own `cachedUsageUtilization` when fresh.
- **Session manager** (`keepSessions`): every 5 minutes, accounts with no running window and weekly limit left get the starting message via `claude -p --model haiku --tools ""`. The active account runs from the default location; others from their profile directory.
- **Config** lives in `~/.claude-profiles/.switcher.json`: session manager (`autoStart`, `message`), `settings` (`startAtLogin`, `notify`, `autoSwitch`, `autoSwitchSkip`, `shortcut`, `trayHintShown`), `accounts` (per-name `label`, `color`, `pinned`) and `order`. Labels are display only; the folder name stays the account's identity.
- **Folder accounts** (`projects` in the config: folder → account): VS Code's `claudeCode.claudeProcessWrapper` points at our launcher, which sets `CLAUDE_CONFIG_DIR` to the account's profile for the folder Claude starts in (the deepest match wins; `configDirFor`). Folders are added in Settings → Folder accounts (path + account; nothing is bound by default). An account can be both bound and active: then `configDirFor` and the launcher return no override, since a second live copy of one refresh token logs the other out (`use` rewrites the launcher via `refreshFolders`). Known gap: a VS Code window already running from the profile keeps its token when you switch to that account. On macOS/Linux the launcher is `~/.claude-profiles/claude-launcher.sh`, rewritten by `refreshFolders`; on Windows it's Switcher.exe itself (the branch at the top of `main.js`), since VS Code can't start a script there. `refreshFolders` also links the user's own `~/.claude` setup (the `SHARED` list) into bound profiles; never add account or organisation files to that list.
- **Tray and shortcut**: closing the window hides it to the tray; **Quit** is in the tray menu. The shortcut (an Electron accelerator, empty = off) opens the quick switcher. A single-instance lock brings the window back when the app is launched again.
- **Notifications** (`watchUsage`, every 5 minutes): `usageAlerts` compares the last two usage readings and fires only when a threshold is crossed. `bestAccount` picks the account with the most left (lower of session and weekly headroom).
- **Auto switch** (Settings → Auto switch, off by default; in `watchUsage`): when the active account's session or week is full, `autoSwitchTarget` picks the account with the most left among those taking part (`autoSwitchSkip` lists the accounts left out) and `main.js` runs a normal `use`. It never runs when the active account is left out or nobody has anything left; Claude Code picks the new login up on its next start.
Expand All @@ -54,7 +55,7 @@ npm run dist # installers for the current OS into dist/
## Invariants (never break these)

1. **Tokens never leave the machine** except to `api.anthropic.com` and `platform.claude.com`. No logging, printing, telemetry or new endpoints.
2. **Never refresh the active login.** Only Claude Code may refresh the login it's using; doing it here rotates the refresh token and logs Claude Code out.
2. **Never refresh the active login or a folder account's login.** Only Claude Code may refresh a login it's using; doing it here rotates the refresh token and logs Claude Code out. For the same reason a folder account can never be made the active login, and the active account can't get a folder.
3. **Back up before changing credentials**, and write credential files with `writeAtomic` (temporary file, then rename).
4. **Swap only `claudeAiOauth` and `oauthAccount`.** Every other key in those files belongs to Claude Code.
5. **Token-touching operations go through `serial()`**, so a refresh never races a switch.
Expand Down
3 changes: 3 additions & 0 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ Fonts are bundled from `@fontsource` (SIL Open Font License), so nothing loads f
| **Status tag** | One per account, next to the name, from `tags.js`, by priority: **Expired** and **Limit hit · 2h 5m** (red outline), **Almost out** (80%+, amber outline), **Most left** (coral outline), then plain pills: **Resets in 20m**, **Fresh**, **Session running**, **Pinned** (tray and quick switcher only). The active account keeps its **Active** badge and only gets the red and amber ones; a folder account gets **Folder** the same way |
| **Side panel (What's new)** | A 420px panel that slides over the right of the main window (`.panel`, with a 25% ink scrim you can click to close; Esc closes it too): title and a muted line, a close button, then a scrolling list of notes. A note: a 15px title (a small coral dot when it's new since the user last looked), the date in `--muted`, then lines each with a tag (**New** on `--primary`, **Improved** and **Fixed** on `--pill`) and one short sentence. Opened from the sidebar's **What's new** link, which shows the same dot while something is unseen |
| **Colour dot** | 10px circle before the account name, filled with a `--label-*` token; absent when no label is set |
| **Folder chip** | Under an account's email: "Used in" in `--muted`, then one `--pill` chip per folder (folder name, full path on hover). Read-only: folders are edited in Settings → Folder accounts |
| **Setup guide panel** | A 480px side panel that slides over the right of a settings pane (Settings → Folder accounts; opens by itself the first time, and the line-icon help button at the top right of the pane title reopens it). Header with title, "Step 2 of 4" and a close button; then one step at a time (22px `--primary` circle, 15px title, 14px `--muted` line with `kbd` keys), each with a real VS Code screenshot (`assets/guide/stepN.webp`: a short before/after loop, with the place to look outlined in `--focus`; `stepN.png` is the still for reduced motion). A footer holds the progress dots (6px, current in `--primary`), **Back** (hidden on the first step) and a primary **Next** (**Done** on the last); ← and → also move between steps, and the pane behind is dimmed. Esc closes the panel before the dialog. To retake them, use a throwaway VS Code profile and empty folder so no personal data is in the shot |
| **Folder row** | In Settings → Folder accounts: the folder path (ellipsis, full path on hover), an account select and a × link button; below the list, an add row: path field, Choose…, account select and a primary Add |
| **Card menu** | Opened by the **⋯** link button: `--card` fill, hairline border, 12px radius, the menu shadow. Items are 34px rows with `--pill` on hover; **Remove** is `--error` |
| **Settings dialog** | Modal, up to 860×560, 16px radius, `--card` fill, backdrop ink at 45%. Header: "Settings" (17px / 500) and a close button. Left: a 220px section list on `--soft`, 38px items, the current one on `--pill`. Right: the section title (16px / 500), then rows of label (15px; optional 13px `--muted` line under it) on the left and the control on the right, hairlines between rows. Opens from the sidebar or Ctrl/Cmd+,; Esc or a backdrop click closes it. Under 640px the section list becomes a row on top |
| **Switch** | A checkbox with `role="switch"`: 38×22 round track, `--field-line` when off, `--primary` when on, 16px white knob |
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ See every account's session and weekly usage, and keep a 5-hour window running o
- **Lives in the tray.** Closing the window keeps Switcher in the system tray (menu bar on macOS). Its popup shows every account's session (a ring with the % used) and this week (a bar), and switches with one click. Optionally starts when you log in.
- **Notifications.** A heads-up when an account reaches 80% of its weekly limit, runs out, or gets its session back, and when a login expires.
- **Most left.** The account with the most usage left is marked, so you know which one to switch to.
- **Folder accounts.** Give a project folder its own account: Claude Code in VS Code uses it there, whichever account is active.
- **Yours to arrange.** Rename accounts, give them a colour, pin them to the top, and drag to reorder.
- **Safe by design.** Credentials are backed up before every switch, never leave your machine except to Anthropic, and are never logged.
- **Updates itself.** New versions download in the background; one click installs them.
Expand Down Expand Up @@ -91,13 +92,16 @@ You also need the [Claude Code](https://docs.anthropic.com/en/docs/claude-code)

If a card can't load usage, **Reconnect** retries, or reopens sign-in when the login has expired. Each card's **⋯** menu renames, pins, colours, moves or removes the account.

**Folder accounts**: in **Settings → Folder accounts** add the project folder and pick its account. Then, once, copy the launcher (the **?** icon on that page walks you through each step, one at a time) from **Settings → Folder accounts** into VS Code's *Claude Process Wrapper* setting (`claudeCode.claudeProcessWrapper`) and reload the window. The account stays usable everywhere else too, including as the active account (inside its folder the active login is simply used as is, so there are never two live copies). `claude` in a terminal keeps using the active account. One catch: switching to an account that a VS Code window is already running in its folder can sign that window out until you reload it.

**Settings** also has start at login (installed app only), notifications, and the quick switcher shortcut: click the field and press the new combination, or **Turn off**.

## How it works

- Each account lives in `~/.claude-profiles/<name>/`, with its own `.credentials.json` and `.claude.json`.
- Switching replaces only the login (`claudeAiOauth` in `~/.claude/.credentials.json`, or the `Claude Code-credentials` Keychain item on macOS) and the account info (`oauthAccount` in `~/.claude.json`).
- Credentials are backed up to `~/.claude-profiles/.backups/` before every switch.
- A folder account runs from its profile folder. Your own setup in `~/.claude` (settings, `CLAUDE.md`, agents, commands, skills, plugins, hooks and session history) is linked into it, so nothing goes missing; the login, policy limits and remote settings stay per account. Switcher never refreshes a folder account's login: Claude Code does that.
- Usage comes from Anthropic, using each account's own token, at most every 10 minutes per account. Switcher remembers the last answer, and backs off when Anthropic asks it to.

## Privacy
Expand Down Expand Up @@ -130,6 +134,7 @@ Pushes to any branch build and test on Windows, macOS and Linux ([ci.yml](.githu

- Built against Claude Code 2.1.332. It relies on Claude Code's file formats and undocumented endpoints, which can change.
- Used day to day on Windows. Linux passes the full test suite in CI; the macOS Keychain switching isn't covered by automated tests yet.
- Folder accounts on Windows: VS Code starts Claude through Switcher.exe, which adds about half a second. Clear the *Claude Process Wrapper* setting before uninstalling Switcher. User-scope MCP servers (`claude mcp add --scope user`) aren't shared into folder accounts; project `.mcp.json` servers work.
- Use it with your own accounts and within Anthropic's terms.

## License
Expand Down
1 change: 1 addition & 0 deletions assets/chevron.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/guide/step1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/guide/step1.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/guide/step2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/guide/step2.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/guide/step3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/guide/step3.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/guide/step4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/guide/step4.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading