claude-switcher-account 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 khainguyenhm-itr
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,172 @@
1
+ # claude-switcher-account — switch between multiple Claude Code accounts (`claudep`)
2
+
3
+ Use several Claude Code accounts on one machine and switch between them in a
4
+ single command. `claudep` saves each logged-in account, swaps the active one
5
+ instantly, and only makes you log in again when a token actually breaks.
6
+ macOS + Linux + Windows.
7
+
8
+ ```bash
9
+ npm i -g claude-switcher-account
10
+ claudep # pick an account to switch to
11
+ ```
12
+
13
+ ## Why
14
+
15
+ Claude Code keeps a single active login per machine — logging into a second
16
+ account overwrites the first, so juggling a personal account and a work account
17
+ normally means re-authenticating every time you change. `claudep` snapshots each
18
+ login and swaps only the canonical credential when you switch, so everything else
19
+ in `~/.claude` stays shared.
20
+
21
+ ## Install
22
+
23
+ Requires Node ≥ 18.
24
+
25
+ From npm:
26
+
27
+ ```bash
28
+ npm i -g claude-switcher-account
29
+ ```
30
+
31
+ (The npm package is `claude-switcher-account`; the command it installs is `claudep`.)
32
+
33
+ From source or git (the `prepare` script builds automatically):
34
+
35
+ ```bash
36
+ npm i -g git+https://github.com/khainguyenhm-itr/claude-switcher-account.git
37
+ # or, from a local clone:
38
+ git clone https://github.com/khainguyenhm-itr/claude-switcher-account.git
39
+ cd claude-switcher-account && npm i -g .
40
+ ```
41
+
42
+ Verify with `claudep doctor`. On macOS the first run may raise a Keychain
43
+ "allow access" dialog — click Allow.
44
+
45
+ ### Migrating from `claude-login-switcher`
46
+
47
+ The npm package was renamed; the command is still `claudep`. npm has no rename
48
+ redirect, so `npm update -g claude-login-switcher` will never find the new
49
+ releases — reinstall once, **removing the old package first** (both packages own
50
+ the `claudep` bin, so installing before removing leaves you without the command):
51
+
52
+ ```bash
53
+ npm rm -g claude-login-switcher
54
+ npm i -g claude-switcher-account
55
+ claudep list # your accounts are still there
56
+ ```
57
+
58
+ Nothing of yours is lost: saved accounts, config, and credentials live in
59
+ `~/.claude-profiles/` and the Keychain, outside the package, and `npm rm` has no
60
+ uninstall hook that touches them.
61
+
62
+ The autostart watcher is renamed too, so the install deregisters the old entry
63
+ (`com.claude-login-switcher.daemon`, `claude-login-switcher.service`, or the
64
+ `claude-login-switcher` logon Task) before registering the new one — you are never
65
+ left with two watchers, and no `claudep daemon uninstall` is needed first. If you
66
+ upgrade with `CLAUDE_P_NO_DAEMON=1` the old entry survives, since nothing ran to
67
+ clear it; a later `claudep daemon install` or `claudep daemon uninstall` removes it.
68
+
69
+ ## Commands
70
+
71
+ ```
72
+ claudep # interactive menu: pick an account to switch to
73
+ claudep <n> # switch to account #n (as numbered by `list`)
74
+ claudep list # (ls, status, current) list saved accounts, mark the active one
75
+ claudep switch <name|n> # (use) make an account active, by name or number
76
+ claudep remove <name|n> [-y] # (rm) forget a saved account; -y skips the confirm
77
+ claudep rename <old> <new> # relabel a saved account
78
+ claudep version # show the version and check npm for a newer one
79
+ claudep doctor # diagnose credential path, config, and store
80
+ claudep daemon install # run a background watcher for INSTANT capture (autostart on login)
81
+ claudep daemon status # is the watcher installed?
82
+ claudep daemon uninstall # remove the watcher
83
+ ```
84
+
85
+ Accounts are numbered in a stable order (by email), so `claudep 2` always refers
86
+ to the same account. Output is colored on a terminal and plain when piped, `--json`,
87
+ or `NO_COLOR` is set.
88
+
89
+ Global flags: `--json` (on `list`), `--version`, `--help`.
90
+
91
+ ### Interactive menu
92
+
93
+ Running `claudep` with no arguments (in a terminal) opens a menu of your saved
94
+ accounts. Navigate with **↑/↓ or the mouse wheel**, press **Enter** (or a
95
+ **number key**) to switch to the highlighted account. Action hotkeys work
96
+ anywhere: **r** rename · **d** doctor · **q**/**Esc** quit. Removing an account is
97
+ deliberately kept out of the menu — use `claudep remove <name|n>`.
98
+
99
+ ## How capture works
100
+
101
+ There is **no manual `save`** — capture is automatic. A global install
102
+ (`npm i -g`) turns on **instant** capture by default; the **lazy** path is the
103
+ fallback when the daemon is off.
104
+
105
+ **Instant (default on global install).** A `postinstall` step runs
106
+ `claudep daemon install`, starting a background watcher on `~/.claude.json` that
107
+ captures every login/switch/logout the moment it happens — no `claudep` command
108
+ needed. It autostarts on login (launchd on macOS, systemd user service on Linux,
109
+ a logon Task on Windows). Check with `claudep daemon status`; turn it off with
110
+ `claudep daemon uninstall`, or skip it at install time with
111
+ `CLAUDE_P_NO_DAEMON=1 npm i -g claude-switcher-account`.
112
+
113
+ **Lazy (fallback).** With the daemon off, every `claudep` command runs a
114
+ reconcile first: it reads your current login and, if new, snapshots it. So after
115
+ logging in with `claude`, simply running `claudep list` captures the account. A
116
+ login that happens while you never run `claudep` is saved on your next invocation.
117
+
118
+ Give any account a friendlier name with `claudep rename <email> <name>`.
119
+
120
+ ## Logout behavior
121
+
122
+ Configured in `~/.claude-profiles/config.json`:
123
+
124
+ ```jsonc
125
+ { "logoutBehavior": "keep" }
126
+ ```
127
+
128
+ | value | on logout (credential + profile both gone) |
129
+ |-------|--------------------------------------------|
130
+ | `keep` (default) | keep the account saved, stay signed out — never loses a backup |
131
+ | `keep-switch` | keep the account saved, switch to another |
132
+ | `delete-switch` | forget the logged-out account, switch to the newest remaining |
133
+ | `none` | do nothing |
134
+
135
+ ## Where things live
136
+
137
+ - **macOS**: canonical login in Keychain `Claude Code-credentials`; saved accounts
138
+ in Keychain service `claude-profiles-accounts`.
139
+ - **Linux/Windows**: canonical login file `~/.claude/.credentials.json`; saved
140
+ accounts in `~/.claude-profiles/creds.json` (mode `0600`).
141
+ - Account metadata: `~/.claude-profiles/accounts.json`.
142
+
143
+ On macOS the first read of Claude's Keychain item may raise an "allow access"
144
+ dialog — click Allow. Run `claudep doctor` if anything looks off.
145
+
146
+ ## Uninstalling
147
+
148
+ Your saved accounts live in the Keychain (service `claude-profiles-accounts`) and
149
+ `~/.claude-profiles/` — **outside** the npm package — so uninstalling the CLI does
150
+ **not** delete them. Reinstalling picks them right back up.
151
+
152
+ Remove cleanly (turn off the autostart watcher first, or it's left orphaned pointing
153
+ at the deleted binary):
154
+
155
+ ```bash
156
+ claudep daemon uninstall
157
+ npm rm -g claude-switcher-account
158
+ ```
159
+
160
+ To also erase the saved accounts:
161
+
162
+ ```bash
163
+ rm -rf ~/.claude-profiles
164
+ # macOS also: delete each Keychain item
165
+ security delete-generic-password -s claude-profiles-accounts -a "<account-name>"
166
+ ```
167
+
168
+ ## Scope
169
+
170
+ Switching changes the login for **all** Claude Code on the machine (the canonical
171
+ slot is shared). A `claude` session already running keeps its old login until
172
+ restarted.