The common Codex CLI account-switching problem is simple: one machine needs a personal account, a work account, or separate client accounts, while Codex normally sees one active home directory. Moving auth.json by hand makes the active identity difficult to verify and can mix credentials with state that should stay together.
Save each Codex account as a named profile
Initialize aisw, capture the account that is already signed in, and add the next account through Codex's normal OAuth flow. List the profiles so the names are clear before making the first switch.
aisw init
aisw add codex work --from-live
aisw add codex personal
aisw list codexFor an API-key account, use the supported environment input rather than putting a secret in a command that will remain in shell history. Profile names are local labels; aisw does not bypass authentication or proxy Codex traffic.
Switch Codex accounts without logging out or copying auth.json
Activate the intended profile in isolated mode, check the result, and then launch Codex. Each profile-owned CODEX_HOME keeps authentication and related local state together, which is especially important for ChatGPT-managed credentials that refresh in place.
aisw use codex work --state-mode isolated
aisw status
aisw verify
codex
aisw use codex personal --state-mode isolated
codexUse it on Windows or from VS Code
The account boundary is the same on Windows, macOS, and Linux. From VS Code, switch in a new terminal before launching Codex. A Codex process that is already running may retain its previous environment and session, so selecting another profile is not a hot swap.
aisw use codex work --state-mode isolated
aisw verify
codexUse contexts when Codex is part of a client setup
A Codex profile is enough when only Codex changes. If the repository also uses Claude Code, Gemini CLI, or Antigravity CLI, group the profiles in one context and switch the whole setup together.
aisw context create client-acme \
--claude acme-claude \
--codex acme-codex \
--gemini acme-gemini
aisw context use client-acme
aisw statusPrevent the wrong account in a repository
A remembered account is not a strong repository boundary. Bind the directory to its expected context and start with a warning. When the mapping is correct, strict mode stops a supported coding agent from launching under the wrong identity.
cd ~/src/client-acme-app
aisw workspace bind . --context client-acme
aisw workspace guard --mode strictWhat an account switcher should not promise
aisw does not bypass Codex account limits, make provider sessions interchangeable, or rewrite a running process. It manages deliberate local switching. For concurrent sessions, keep each process attached to its own supported home directory and make that choice explicit.
CLI or Desktop?
Use the CLI for scripts, shell hooks, and repository setup. Use AI Switcher Desktop when you want a visual view of the active Codex profile and its repository binding. Both use the same local profile model and the same safety boundaries.
For the concise setup, read How to Switch Codex CLI Accounts. For several named accounts, see Manage Multiple Codex CLI Accounts.
