@lchmpm/codex-account-switcher

Small CLI for switching between local Codex accounts while keeping shared local state.


Keywords
codex, cli, account-switcher
License
MIT
Install
npm install @lchmpm/codex-account-switcher@0.1.2

Documentation

codex-account-switcher

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

Why

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

Install it globally:

npm i -g @lchmpm/codex-account-switcher

Then run:

codex-account

If you want to develop locally, clone the repo and run it directly:

node src/cli.js

Or use the wrapper:

./codex-account

If you want a shell shortcut:

alias c1='/path/to/codex-account switch chenghaocode'
alias c2='/path/to/codex-account switch second'

First-time setup

  1. Save your current account:
./codex-account capture chenghaocode
  1. Manually switch Codex to your other account.
  2. Save that account too:
./codex-account capture second

After that, you usually only need:

./codex-account switch

That opens a small menu and lets you choose the target account.

Commands

Open the interactive menu:

./codex-account

Switch by choosing from a list:

./codex-account switch

Switch directly:

./codex-account switch chenghaocode

Save the current logged-in account:

./codex-account capture second

Check current status:

./codex-account status

Check saved profiles and shared state:

./codex-account doctor

Options

--no-restart
--dry-run
--json
--codex-home <path>
--state-dir <path>

Notes

  • switch restarts 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.

Development

Run tests:

npm test