A small CLI for switching between two local Codex accounts without replacing your whole ~/.codex directory.
It only switches auth.json and keeps your shared local state in place:
- trusted projects
- local session history
- Electron desktop state
Codex local state mixes account auth with machine-local data. Replacing the entire ~/.codex directory is risky and can make your saved projects or local UI state disappear.
This tool keeps the safe part simple:
- save the current account as a named profile
- switch to another saved profile
- restart Codex automatically
Install it globally:
npm i -g @lchmpm/codex-account-switcherThen run:
codex-accountIf you want to develop locally, clone the repo and run it directly:
node src/cli.jsOr use the wrapper:
./codex-accountIf you want a shell shortcut:
alias c1='/path/to/codex-account switch chenghaocode'
alias c2='/path/to/codex-account switch second'- Save your current account:
./codex-account capture chenghaocode- Manually switch Codex to your other account.
- Save that account too:
./codex-account capture secondAfter that, you usually only need:
./codex-account switchThat opens a small menu and lets you choose the target account.
Open the interactive menu:
./codex-accountSwitch by choosing from a list:
./codex-account switchSwitch directly:
./codex-account switch chenghaocodeSave the current logged-in account:
./codex-account capture secondCheck current status:
./codex-account statusCheck saved profiles and shared state:
./codex-account doctor--no-restart
--dry-run
--json
--codex-home <path>
--state-dir <path>-
switchrestarts Codex by default. - This tool does not merge cloud conversations between different accounts.
- This tool is focused on a single machine with shared local state.
Run tests:
npm test