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 codex2. 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 verify3. 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.
codexThe 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
codexFor 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 strictWhat 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.
