Codex CLI · September 3, 2026

Codex CLI Account Switcher: Switch Between Multiple Accounts

A reliable Codex CLI account switcher saves each login as a named profile, gives it an isolated CODEX_HOME, and activates it before a new Codex process starts. AI Switcher handles that local boundary without manual auth.json copying.

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 codex

For 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
codex

Use 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
codex

Use 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 status

Prevent 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 strict

What 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.

Stop moving Codex credentials by hand

Install aisw for repeatable switching, or inspect account profiles in the Desktop app.

Codex CLI account-switching questions

Direct answers about saved profiles, isolated state, and account limits.

How do I switch between Codex CLI accounts?

Save each account as a named aisw profile, activate it with `aisw use codex <profile>`, verify the live state, and start a new Codex process.

Can I switch Codex CLI accounts without logging out?

Yes. Activate a saved aisw profile, verify the live state, and start a new Codex process. Use Codex's normal sign-in flow only when adding or refreshing an account.

Do I need to copy auth.json to switch Codex accounts?

No. aisw manages the profile boundary and can use an isolated CODEX_HOME so you do not have to copy or rename auth.json by hand.

Can I use a Codex account switcher on Windows or in VS Code?

Yes. The aisw workflow runs on macOS, Linux, and Windows. Start a new Codex process after switching because an existing process can retain its previous environment.