Guide
Multiple Codex accounts on one Mac.
Codex keeps one login per machine, in ~/.codex. With a work account and a personal one you end up running codex logout and codex login all day. You don't have to: give every account its own Codex folder.
Why it works
Codex reads everything it keeps (the login in auth.json, your sessions, history, logs and config.toml) from one folder, the one in the CODEX_HOME environment variable. It defaults to ~/.codex. Point it somewhere else and Codex is a separate account there, with nothing shared unless you share it.
Set it up by hand
- Make a folder for the second account. Codex wants it to exist already:
mkdir -p ~/.codex-work - Sign that folder in. Use a private browser window for the sign-in, otherwise the browser picks the account you used last:
CODEX_HOME=~/.codex-work codex login - Open Codex with it, and keep your normal
codexas it is:CODEX_HOME=~/.codex-work codex # work account codex # your main ~/.codex - Make it short with an alias in
~/.zshrc:alias codex-work='CODEX_HOME="$HOME/.codex-work" codex'
Both run at the same time in two terminals, each with its own account.
Keep one setup for both
A new folder starts empty, so your AGENTS.md, MCP servers and model settings aren't there. Link them from the main folder and only the login stays separate:
for f in AGENTS.md config.toml prompts skills; do
[ -e ~/.codex/$f ] && ln -s ~/.codex/$f ~/.codex-work/$f
done
Leave that out for a client account that needs its own instructions and servers.
The same with one command
The free codex-switch CLI does the folder, the shared links and the alias for you:
curl -fsSL https://raw.githubusercontent.com/SaschaHeyer/codex-switch/main/install.sh | bash
codex-switch create work
codex-switch login work
codex-switch work
The Codex app too
The Codex desktop app only runs once: opening it again brings back the first window, signed in to the first account. It can run a second, separate instance though; here is how. Switch for Codex opens every profile in its own app window with one click.
Questions
Can I be signed in to two Codex accounts at the same time?
Yes. Give each account its own CODEX_HOME folder. Each folder holds its own login, so two terminals (or two Codex app windows) can use two accounts at once.
Where does Codex store its login?
In auth.json inside CODEX_HOME, which is ~/.codex unless you set it. Codex can also be configured to keep credentials in the system keyring, keyed to that same folder.
Why did my second account sign in as the first one?
Codex signs in through your browser, and the browser was still signed in to the other ChatGPT account. Sign in the second folder from a private window, or sign out of ChatGPT in the browser first.
Is this allowed?
It's for people with more than one real account, for example one from work and one of their own. It only uses CODEX_HOME, which Codex supports, and doesn't share or create accounts.
Switch for Codex does this with one click on a Mac: every account in its own Codex app window and in your terminal, all open at once, from the app or the menu bar. $9.99 once, no subscription.