Codex CLI · September 9, 2026

How to Switch Codex Accounts in VS Code

In the VS Code terminal, activate a named Codex profile, verify the live state, and start a new Codex process. AI Switcher keeps the selected account in its own CODEX_HOMEso switching does not require copying auth.json.

VS Code does not provide a separate account boundary for a Codex CLI process. Codex reads the environment and local state of the terminal or task that launched it. That means the reliable workflow is the same as in a standalone terminal: select the account first, then launch Codex from the updated environment.

1. Save each Codex account as a named profile

Capture the account already active on the machine, then add the other account through Codex's normal authentication flow. Use labels that make the boundary obvious in a small VS Code terminal, such as work, personal, or client-acme.

aisw init
aisw add codex work --from-live
aisw add codex personal
aisw list codex

2. Switch from the VS Code terminal

Run the switch in the integrated terminal that will launch Codex. In isolated mode, aisw sets CODEX_HOME to the selected profile directory so Codex sees that account's authentication, configuration, and related local state together.

aisw use codex work --state-mode isolated
aisw status --tool codex
aisw verify

3. Start a new Codex process

Exit any Codex process that was running before the switch. A process can retain the old environment and session even after the selected profile changes. Launch Codex again from the verified VS Code terminal.

codex

The same rule applies to a VS Code task, extension command, or terminal tab: the process must start after the account boundary is selected. Switching does not hot-swap an active conversation.

4. Refresh the VS Code terminal when needed

If the terminal was opened before the shell hook was configured, create a new terminal or reload the shell configuration. The hook applies profile-specific exports such asCODEX_HOME to the current shell when you run aisw use oraisw context use.

aisw shell-hook zsh >> ~/.zshrc
source ~/.zshrc
aisw use codex personal --state-mode isolated
aisw status --tool codex
codex

For Bash, Fish, or PowerShell, use the matching shell-hook form from theshell integration documentation.

5. Bind the VS Code repository to the right account

If the workspace belongs to a client or organization, bind the repository to a context. The shell hook checks the binding before launching Codex and can warn or block when the active account setup is wrong.

aisw context create client-acme --codex client-acme-codex
aisw workspace bind . --context client-acme
aisw workspace guard --mode strict

What changes and what does not

The VS Code project, source files, and editor settings remain in place. aisw changes the local Codex profile boundary and reports whether the live state matches it. It does not bypass OpenAI authentication or usage limits, and it does not move credentials into a cloud service.

For the full multi-account setup, read how to switch between multiple Codex CLI accounts. For the short command sequence, see How to Switch Codex CLI Accounts.

Switch Codex accounts without leaving VS Code

Use the CLI for a visible, repeatable account boundary in every integrated terminal.

Codex and VS Code questions

Direct answers about integrated terminals, process boundaries, and repository context.

How do I switch Codex accounts in VS Code?

Run aisw use codex <profile> in the VS Code terminal, verify with aisw status --tool codex and aisw verify, then start a new Codex process.

Why does Codex still use the old account after I switch?

An existing Codex process can retain its previous environment. Exit it, switch the named profile, verify the live state, and launch Codex again from a fresh terminal or process.

Does switching Codex accounts change the VS Code project?

No. aisw changes the local Codex account and profile state. The VS Code workspace remains the same; a workspace rule can enforce which account context that repository expects.