How to switch accounts in Codex CLI without logging out
Codex CLI keeps one sign-in per Codex home folder, ~/.codex by default. To switch accounts without logging out, sign in once in a separate folder per ChatGPT account, point Codex at the one you want, and link the sessions folder into each so codex resume still lists every chat.
Contents
Codex CLI reads its sign-in from whichever folder CODEX_HOME points at, so to switch accounts without logging out you give each ChatGPT account its own folder, sign in once in each, and start Codex with the one you want. Changing the variable changes the account. Link one shared sessions folder into every home as well, or codex resume under one account won't list the chats you started under the other.
OpenAI's authentication page only documents the other way, codex logout followed by codex login. We cover both, from that page and from Codex's source on GitHub, read on 24 October 2026.
How Codex CLI decides which account it uses#
Unless you set it, CODEX_HOME is ~/.codex. According to OpenAI's environment variable list, that one folder holds config, auth, logs, sessions and skills, and a folder you name instead must already exist.
Where the sign-in goes inside it is up to cli_auth_credentials_store in config.toml:
| Value | Where the sign-in is kept |
|---|---|
file |
auth.json in CODEX_HOME, as plain text. The default in Codex's source |
keyring |
Your system's credential store, and Codex fails if there isn't one |
auto |
The credential store when there is one, auth.json when not |
ephemeral |
Memory only, for that one process |
If you use the keyring instead, accounts still don't mix: storage.rs names the entry after a hash of the CODEX_HOME path, which gives ~/.codex and ~/.codex-work an entry each. OpenAI's page adds one wrinkle for the default folder: the IDE extension shares the CLI's cached sign-in, so a logout there logs the extension out too.
Log out and sign in again (the documented way)#
codex logoutremoves the stored credentials, ChatGPT and API key alike.codex loginopens a browser tab. Sign in there as the other account, and pick the workspace if ChatGPT asks.codex login statusprints "Logged in using ChatGPT" (login.rs), which confirms the method but not the account.- For which account, start a session and type
/status. Its Account line shows the email and the plan.
On a remote machine, codex login --device-auth gives you a code to enter in a browser elsewhere. OpenAI marks it beta, and you turn on device code login in ChatGPT's security settings first. Your sessions survive all of this, because logout only touches credentials. It is still a browser round trip every time you change accounts. If the browser step itself fails, Codex login not working goes through the errors one by one.
Switch Codex CLI accounts without logging out: one CODEX_HOME each#
These steps add a second account called work on macOS or Linux; your main account stays in ~/.codex.
-
Create the folder with
mkdir -p ~/.codex-work, since Codex expects aCODEX_HOMEthat already exists. -
Add this function to
~/.zshrcor~/.bashrc:bashcodex-work() { CODEX_HOME="$HOME/.codex-work" codex -c 'cli_auth_credentials_store="file"' "$@"; } -
In a new terminal, run
codex-work loginand sign in as the second account. -
From now on,
codexruns as your main account andcodex-workas the second, in any terminal, at the same time.
-c overrides config.toml for that one run. Shuriken passes the same override to every Codex it starts, because the config.toml each folder links to is your own, and a keyring or auto value in it could send the second account's tokens to the system credential store. With file, each sign-in stays in its own folder's auth.json, where you can see which folder holds which account.
One ChatGPT login with both a Business workspace and a personal plan behaves like two accounts here. A Codex sign-in carries one workspace's ID, so each workspace needs its own folder. Tools that make this switch for you are compared in Codex account switchers.
Keep your chats when you switch accounts#
Each CODEX_HOME has its own sessions folder. A session you started as your main account is therefore not in codex-work resume, and --all won't find it, because that flag searches other project folders, not other homes. Settings, AGENTS.md, prompts and skills are divided between the folders in the same way.
To share them, symlink each entry from ~/.codex into the other home before that home's first session:
mkdir -p ~/.codex/sessions ~/.codex/archived_sessions
for e in sessions archived_sessions config.toml AGENTS.md prompts skills; do
[ -e ~/.codex/$e ] && [ ! -e ~/.codex-work/$e ] && ln -s ~/.codex/$e ~/.codex-work/$e
done
We left auth.json out of the loop: it holds the sign-in, and a linked copy would put both folders on one account, so never link it. If ~/.codex-work already has a sessions folder of its own, merge it first with cp -R ~/.codex-work/sessions/. ~/.codex/sessions/, make sure the chats came across, delete ~/.codex-work/sessions and run the loop. Codex's resume picker reads the session files on disk, so after this, codex resume lists the same chats under either account, and you can carry one on from the other. Every command for finding a session is in resuming a Codex session.
In PowerShell the CODEX_HOME=… codex prefix doesn't work, so set $env:CODEX_HOME first and then run codex. Of the six entries, the four folders can be junctions (mklink /J in Command Prompt, or New-Item -ItemType Junction in PowerShell). config.toml and AGENTS.md are files and need a symbolic link, which Windows allows only with Developer Mode on or as an administrator.
When a limit is the reason you switch#
A new account takes effect at the next session or the next codex resume, and the turn that hit the limit stays stopped. For the limit message itself and how to check when it resets, see Codex usage limit reached.
Add only accounts you own and are entitled to use. OpenAI's Terms of Use say you may not share your account credentials or make your account available to anyone else. They also forbid circumventing any rate limits or restrictions, and don't say whether a second paid plan counts. OpenAI's help-center lines on extra accounts are quoted in the rules for two ChatGPT accounts with Codex.
How Shuriken switches Codex accounts#
Shuriken does the folder setup above for you. Each ChatGPT sign-in you add in Sources is a source with its own CODEX_HOME. Shuriken starts Codex there with cli_auth_credentials_store="file", and links whichever of the same six entries (sessions, archived_sessions, config.toml, AGENTS.md, prompts and skills) your ~/.codex, or the CODEX_HOME you set, already has into it. Your chats stay in one place, and the plain codex resume in your terminal sees them too.
Then it does the switching. Hot swapping is our name for it: Shuriken moves your chats to another of your accounts or sources when one nears its limit. When the account in use reaches your switch point, 99% by default, a Codex chat moves to the account with the most room when its current turn ends. If OpenAI reports a limit first, it moves at that moment. A "Switched to" card in the chat names the account that took over. Source switching has the settings, and Codex with more than one ChatGPT account explains why Codex moves at the end of a turn while Claude Code moves mid-turn.
The Free plan holds two sources, enough for a main and a second account. Download Shuriken for macOS, Windows or Linux.
Sources
- OpenAI: Codex authentication (accessed 24 October 2026)
- OpenAI: Codex environment variables (CODEX_HOME) (accessed 24 October 2026)
- OpenAI: Codex CLI command reference (accessed 24 October 2026)
- openai/codex on GitHub: codex-rs/config/src/types.rs (file is the default credential store) (accessed 24 October 2026)
- openai/codex on GitHub: codex-rs/login/src/auth/storage.rs (keyring entry per CODEX_HOME) (accessed 24 October 2026)
- openai/codex on GitHub: codex-rs/cli/src/login.rs (codex login status output) (accessed 24 October 2026)
- openai/codex on GitHub: codex-rs/tui/src/status/card.rs (the Account line in /status) (accessed 24 October 2026)
- OpenAI Developer Community: Upgraded to Pro Plan, Codex usage limits remain like Plus account (accessed 24 October 2026)
- OpenAI Terms of Use (accessed 24 October 2026)
Frequently asked questions
How do I see which ChatGPT account Codex CLI is using?
/status, typed inside a Codex session, has an Account line with the email and the plan. codex login status won't tell you, because it prints only the method, such as Logged in using ChatGPT.
Does codex logout delete my Codex sessions?
No. Logout removes the stored credentials for that CODEX_HOME, but the files in its sessions folder stay, and codex resume shows them again after you sign back in.
Why are my Codex sessions missing after I switched accounts?
They are still on disk, in the sessions folder of the CODEX_HOME they were started under. Start Codex with that CODEX_HOME again, or link one shared sessions folder into every home so each account lists them.
I upgraded to Pro but Codex CLI still shows Plus limits. What do I do?
Sign in afresh first: codex logout, codex login, then read the plan on the Account line of /status. The person in an April 2026 thread on OpenAI's community forum had already done that and still saw Plus limits, and OpenAI support asked them to get in touch so it could check the account.
How do I switch Codex between a Business workspace and my personal plan?
Treat them as two accounts. A Codex sign-in carries one workspace's ID, so either log out and sign in again choosing the other workspace, or give each workspace its own CODEX_HOME and sign in once in each.
Is it allowed to use several ChatGPT accounts with Codex?
Only accounts you own and are entitled to use. OpenAI's Terms of Use forbid sharing your account credentials or making your account available to anyone else, and circumventing any rate limits or restrictions.