Running multiple Claude Code and Codex accounts on one machine A developer shared a guide for running multiple Claude Code and Codex accounts on a single machine by using separate configuration directories and shell aliases. The approach isolates settings, plugins, and sessions per account, preventing cross-account data leaks and accidental API key usage. Running multiple Claude Code and Codex accounts on one machine Tip Keep your personal, work, and admin accounts signed in at once. Each command starts the CLI with its own settings folder, so you never switch accounts and never log in twice. What you end up with - One folder per account, so nothing leaks between them. - A short command for each account, which picks that folder for a single launch. - No stray API key reaching Codex when you meant to use your ChatGPT plan. How isolation works how-isolation-works Before you begin before-you-begin Set up profiles set-up-profiles Daily use daily-use Calling this from mobile or a desktop app calling-this-from-mobile-or-a-desktop-app Running sessions in parallel running-sessions-in-parallel Agent-to-agent messaging agent-to-agent-messaging Invoking one CLI from the other invoking-one-cli-from-the-other Command reference command-reference Troubleshooting troubleshooting Operational notes operational-notes When either CLI starts, it picks one folder to work from. That folder holds the account's settings, its plugins, its MCP servers, its hooks, and its past sessions. The command you type picks the folder for that one launch, and it leaves your other terminals alone. | CLI | Selector | Default profile directory | |---|---|---| | Claude Code | CLAUDE CONFIG DIR | ~/.claude | | Codex | CODEX HOME | ~/.codex | php flowchart LR T Terminal -- P plain command T -- W work alias T -- A admin alias P -- CP default profile root W -- CW work profile root A -- CA admin profile root classDef terminal fill: 24292f,stroke: 8b949e,color: ffffff classDef profile fill: 0a3069,stroke: 54aeff,color: ffffff classDef work fill: 116329,stroke: 56d364,color: ffffff classDef admin fill: 9a6700,stroke: e3b341,color: ffffff class T terminal class P,CP profile class W,CW work class A,CA admin Note The ~ in these paths means your home folder. On a Mac, ~/.codex-work is really /Users/yourname/.codex-work . Names that start with a dot stay hidden in Finder, which is normal. This guide assumes macOS or Linux with zsh. If you use Bash, everything works the same, but edit ~/.bashrc instead of ~/.zshrc . echo $SHELL claude --version codex --version Important Only set up profiles for accounts you are allowed to use. A profile keeps things separate on your own machine. It has no effect on what an account is permitted to do, and it will not get you around workspace rules or usage limits. If you have never signed in, do that first with the plain commands. Whatever you sign in as here becomes your default account. claude auth login codex login --device-auth The examples below add two accounts called work and admin . Call yours whatever you like, as long as you use the same names throughout. The Claude Code and Codex halves do not depend on each other, so do one, the other, or both, in whichever order suits you. mkdir -p ~/.claude-work ~/.claude-admin ls -d ~/.claude mkdir -p prints nothing when it works, and it will not complain if the folders already exist. Open your shell configuration: open -e ~/.zshrc Add this block at the bottom: Claude Code: default remains ~/.claude alias claude-work='CLAUDE CONFIG DIR="$HOME/.claude-work" command claude' alias claude-admin='CLAUDE CONFIG DIR="$HOME/.claude-admin" command claude' Why command claude matters command skips over aliases and runs the installed program directly. Without it, an alias can end up calling itself forever. Warning Do not put export CLAUDE CONFIG DIR=... on a line of its own. That applies to every command in every new terminal, and it quietly moves your default account too. An alias sets the folder for one launch and nothing else. source ~/.zshrc claude-work auth login claude-admin auth login Sign in to each one with the account you actually want. If your browser is still signed in from the previous login, sign out first, or open the link in a private window, or keep a separate browser profile per account. claude auth status --text claude-work auth status --text claude-admin auth status --text Each command should name the account you expect. If two of them show the same person, sign out of only the one that is wrong and log in again: claude-work auth logout claude-work auth login Codex works the same way, using CODEX HOME . It creates the folder for you the first time you sign in, so there is nothing to make by hand. Open ~/.zshrc and add: Codex: default remains ~/.codex. Each wrapper removes shell API credentials. alias codex='env -u OPENAI API KEY -u CODEX API KEY -u CODEX ACCESS TOKEN command codex' alias codex-work='env -u OPENAI API KEY -u CODEX API KEY -u CODEX ACCESS TOKEN CODEX HOME="$HOME/.codex-work" command codex' alias codex-admin='env -u OPENAI API KEY -u CODEX API KEY -u CODEX ACCESS TOKEN CODEX HOME="$HOME/.codex-admin" command codex' Important The env -u entries only affect the Codex process being launched. Your shell keeps its variables, and so does everything else on the machine. Reload the aliases: source ~/.zshrc codex-work login --device-auth codex-admin login --device-auth Codex prints a one-time code and a link. Open the link, type the code, and approve it with the account you meant to use. If the browser is already signed in as somebody else, use a private window or a second browser profile. codex login status codex-work login status codex-admin login status Each profile should report Logged in using ChatGPT . Note codex login status confirms the login method and state; it does not print the account email. Keep the browser authorization flows separate and label profile directories clearly. Separate profile roots and separate successful device-auth flows establish the intended isolation. Inspect the three separate Codex roots This shows that each command really does use its own folder. It will not tell you which account is signed in, since the login you completed is what decides that. ls -la ~/.codex/auth.json ~/.codex-work/auth.json ~/.codex-admin/auth.json For current subscription access, plan limits, and workspace controls, see Using Codex with your ChatGPT plan https://help.openai.com/en/articles/11369540-using-codex-with-your-chatgpt-plan . There is no switch command. Start the account you want: claude default identity claude-work work identity claude-admin admin identity codex default identity codex-work work identity codex-admin admin identity This guide is not CLI-only in practice. A mobile client or a desktop app's session, running on the same host as these aliases, already carries a shell tool — the same bash any CLI agent uses. Every command in this guide is nothing more than a shell command. There is no bridge, skill, or MCP server to build: you set up the aliases once on the host, exactly as described above, then tell the mobile or desktop session to run them there. Run codex-work exec --sandbox read-only -o /tmp/review.txt "