You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-40Lines changed: 16 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,18 +4,10 @@
4
4
5
5
It swaps only the active auth file. Your main Codex history, logs, sessions, and other state stay shared.
6
6
7
-
## Status
8
-
9
-
- Public GitHub repository: ready
10
-
- npm package name: selected as `codex-auth-switch`
11
-
12
-
For now, the supported installation path is running from this repository checkout. Package-install instructions will be added after the package is published.
13
-
14
7
## Before You Start
15
8
16
-
-**This tool runs as `./codex-auth-switch ...` in this repository.**
17
-
- Running `pnpm install` and `pnpm build` does **not** create a global `codex-auth-switch` command.
18
-
-`./codex-auth-switch` is a small wrapper that runs `node dist/index.mjs`.
9
+
-**This tool runs as `./codex-auth-switch ...` from this repository's root.**
10
+
-`pnpm install && pnpm build` does **not** create a global command. Always invoke via `./codex-auth-switch`.
19
11
20
12
## Requirements
21
13
@@ -26,9 +18,9 @@ For now, the supported installation path is running from this repository checkou
26
18
27
19
## Important Constraints
28
20
29
-
-**File-backed auth only.**`cli_auth_credentials_store` must be `"file"` or `"auto"` resolving to a readable file-backed auth file. Keyring-backed auth is not supported.
21
+
-**File-backed auth only.**Codex's `cli_auth_credentials_store`setting must be `"file"`(or `"auto"` resolving to a file). Keyring-backed auth is not supported.
30
22
-**Email is a label.**`add <email>` stores the email as a user-provided label. It is not verified against the browser session used during `codex login`.
31
-
-**Usage is best-effort.**`usage`depends on upstream behavior that is not a public stable API.
23
+
-**Usage is best-effort.**The `usage`command relies on Codex's internal API, which is not a public stable interface and may change without notice.
32
24
33
25
## Install
34
26
@@ -37,13 +29,13 @@ pnpm install
37
29
pnpm build
38
30
```
39
31
40
-
After that, run the CLI like this:
32
+
Verify the build:
41
33
42
34
```bash
43
35
./codex-auth-switch --help
44
36
```
45
37
46
-
Windows is not supported at the moment. The CLI currently depends on POSIX process inspection and file-permission behavior.
38
+
> **Note:**Windows is not supported. The CLI depends on POSIX process inspection and file-permission behavior.
bar@example.com a1b2c3d4-e5f6-7890-abcd-1234567890ef 2026-04-03 18:00 local
82
74
```
83
75
84
-
Columns:
85
-
86
-
- active flag
87
-
- email label
88
-
- full `account_id`
89
-
-`last_used_at` in local time
76
+
Columns: active flag, email label, `account_id`, and `last_used_at` in local time.
90
77
91
78
### 3. Switch the active account
92
79
@@ -102,7 +89,7 @@ Direct:
102
89
./codex-auth-switch use foo@example.com
103
90
```
104
91
105
-
This writes the selected auth to `$CODEX_HOME/auth.json`. If `CODEX_HOME` is not set, the default target is `~/.codex/auth.json`.
92
+
This writes the selected auth to `$CODEX_HOME/auth.json` (default: `~/.codex/auth.json`).
106
93
107
94
Example output:
108
95
@@ -189,15 +176,9 @@ Reads usage information.
189
176
-`--all`: all saved accounts
190
177
-`--json`: machine-readable output
191
178
192
-
`--all` continues when one account fails. If the resolved auth belongs to a different `account_id`, the command fails closed for that account.
193
-
If the upstream usage payload reports a different email than the saved label, the human-readable output shows `Observed email`.
179
+
`--all` continues even when individual accounts fail. If the fetched auth belongs to a different `account_id` than expected, that account is treated as an error (fail-closed).
194
180
195
-
Typical empty state:
196
-
197
-
```text
198
-
No saved accounts yet.
199
-
Run `./codex-auth-switch add <email>` to register your first account.
200
-
```
181
+
If the upstream response reports a different email than the saved label, the output shows it as `Observed email`.
201
182
202
183
## Where Data Is Stored
203
184
@@ -210,9 +191,8 @@ Managed auth snapshots live outside the main Codex directory:
210
191
<profile_id>.json
211
192
```
212
193
213
-
-`email` is the user-facing identifier
214
-
-`profileId` is the internal primary key
215
-
- managed auth paths are derived from `profileId` at runtime
194
+
-`email` — user-facing identifier (the label you pass to commands)
195
+
-`profileId` — internal primary key; auth file paths are derived from it at runtime
216
196
217
197
Example `state.json`:
218
198
@@ -239,13 +219,11 @@ MIT
239
219
240
220
- Atomic replacement of auth and state files
241
221
- Lock-file based concurrency control for `add` and `use`
242
-
-`0700` for directories and`0600` for auth files
222
+
-`0700` for directories,`0600` for auth files
243
223
- No logging of tokens or raw auth payloads
244
224
- Rollback on failed switch when possible
245
225
246
-
Important risk:
247
-
248
-
- If `~/.config/codex-auth-switch/` is compromised, every saved session is exposed
226
+
> **Risk:** If `~/.config/codex-auth-switch/` is compromised, every saved session is exposed.
249
227
250
228
Please report security issues privately as described in [`SECURITY.md`](./SECURITY.md).
251
229
@@ -259,12 +237,10 @@ Exit codes:
259
237
|`2`| Local state, auth, or lock failure |
260
238
|`3`| External dependency failure |
261
239
262
-
For structured logs:
240
+
Structured logs (JSON Lines on `stderr`, sensitive fields redacted):
0 commit comments