Guide

How to Use Multiple Claude Code and Codex Accounts on One Mac

One config directory per login, one alias per account, and no logging out to switch.

To use multiple Claude Code accounts on one Mac, give each login its own configuration directory and start Claude Code with CLAUDE_CONFIG_DIR pointing at it. Codex works the same way with CODEX_HOME. Wrap each profile in a shell alias such as claude-work or codex-work, and both accounts stay signed in at once in separate terminals, with no logging out. If you would rather not edit ~/.zshrc, Agentastic's Usage & Cost panel creates the same profiles with Add account and shows each login's remaining quota.

Every variable, command, and path below was checked against Anthropic's and OpenAI's documentation on October 5, 2026.

People usually split accounts to keep an employer's seat apart from a personal plan. How accounts and plans may be used is set by each provider's terms (Anthropic, OpenAI) and by your organization's policies. Follow them, and don't use extra accounts to work around usage limits.

The short version#

Claude CodeCodex CLI
Profile variableCLAUDE_CONFIG_DIRCODEX_HOME
Default directory~/.claude~/.codex
Where the login lives on a MacKeychain entry tied to the directory, with a file fallback inside itauth.json inside the directory by default
Sign inclaude auth login or /logincodex login
See the active accountclaude auth status --text or /statuscodex login status
Create the directory firstRecommendedRequired
Resume a past sessionSame alias, for example claude-work --resumeSame alias, for example codex-work resume

Switching accounts vs running them side by side#

There are two ways to live with two logins.

Switch in place. Keep one profile and sign out and back in: /logout then /login in Claude Code, or codex logout then codex login. That works if you change accounts rarely. Done daily, it gets tedious, and every session that uses the same directory shares the login: Anthropic's docs note that a session waiting on a login picks up one you complete in another window with the same configuration directory.

One profile per account. Give each account its own directory. Both stay signed in, and each terminal uses whichever account you launched. Anthropic's authentication guide describes exactly this for work and personal accounts, and it is the rest of this guide.

Set up a second Claude Code account#

  1. Create a directory for the profile:

    bash
    mkdir -p "$HOME/.claude-work"
  2. Add an alias to ~/.zshrc (or ~/.bashrc):

    bash
    alias claude-work='CLAUDE_CONFIG_DIR="$HOME/.claude-work" claude'
  3. Open a new terminal, or run source ~/.zshrc, and sign in:

    bash
    claude-work auth login

    Running plain claude-work works too. On its first launch in a new directory, Claude Code walks you through login and setup.

  4. Confirm the two commands reach different accounts:

    bash
    claude auth status --text claude-work auth status --text

    Inside a session, /status shows the account in use.

Why this works: each configuration directory holds its own settings, session history, and claude.ai login or API key. On macOS, Claude Code stores the login in the Keychain and keys that entry to the directory, so a session started with a different CLAUDE_CONFIG_DIR reads a different entry. When the Keychain refuses the write, for example while it is locked in an SSH session, Claude Code falls back to a .credentials.json file with mode 0600 inside the same directory.

Two habits keep this predictable:

  • Spell the path the same way everywhere. An absolute path such as $HOME/.claude-work is safest, because the login is tied to the directory you pass.
  • Set the variable in your shell, not in a repository. Claude Code ignores CLAUDE_CONFIG_DIR in project and local settings files.

Set up a second Codex account#

  1. Create the directory. Codex requires a custom CODEX_HOME to exist before it starts:

    bash
    mkdir -p "$HOME/.codex-work"
  2. Add an alias:

    bash
    alias codex-work='CODEX_HOME="$HOME/.codex-work" codex'
  3. Sign in with ChatGPT, or pipe in an API key for usage-based billing:

    bash
    codex-work login # API key instead of a ChatGPT plan: printenv OPENAI_API_KEY | codex-work login --with-api-key
  4. Check both profiles:

    bash
    codex login status codex-work login status

CODEX_HOME is the root for Codex's state: configuration, login, logs, and sessions. OpenAI's docs say the login is cached in auth.json under CODEX_HOME or in your operating system's credential store. In the open-source CLI, the default store is the file, and when you switch cli_auth_credentials_store to keyring, the entry is keyed by the CODEX_HOME path. Either way, separate directories keep separate logins. The CLI and the IDE extension share the same cached login.

Don't confuse this with Codex config profiles. codex --profile deep-review layers ~/.codex/deep-review.config.toml over your settings, such as the model and approval policy. It changes configuration, not the login, which stays with CODEX_HOME. When Codex behaves as if your configuration vanished, OpenAI's own troubleshooting tip applies: run echo $CODEX_HOME to see which home it is using.

Run both accounts side by side#

Once the aliases exist, choosing an account is choosing a command:

bash
# Terminal 1: personal plan, personal project cd ~/code/side-project && claude # Terminal 2: work account, in a worktree of the work repository cd ~/code/billing-worktrees/fix-invoice-rounding && claude-work # Terminal 3: Codex on the work account, in a second worktree cd ~/code/billing-worktrees/add-refund-tests && codex-work

Two rules make this safe:

  • One worktree per session. Separate accounts don't isolate files. Two sessions editing the same checkout can still overwrite each other, whichever account they bill. The Git worktree cheat sheet covers the commands, and running multiple Claude Code agents in parallel covers the workflow.
  • Resume with the alias you started with. Session history lives in the profile directory, so claude --resume won't list a session you ran with claude-work. Use claude-work --resume, or codex-work resume for Codex.

Aliases only exist in interactive shells. In scripts, cron jobs, and CI, set the variable on the command itself, for example CLAUDE_CONFIG_DIR="$HOME/.claude-work" claude -p "summarize the open TODOs".

What a new profile doesn't inherit#

A fresh profile starts empty. Anything you keep in the default directory has to be copied or recreated:

WhatClaude CodeCodexWhat to do
User settingssettings.json in the profileconfig.toml in CODEX_HOMECopy the settings you want
Personal instructionsCLAUDE.md in the profileAGENTS.md in CODEX_HOMECopy, or move shared rules into the repository
Personal MCP servers.claude.json in the profile[mcp_servers] tables in config.tomlRe-add them under the new alias
Skills, subagents, commandsskills/, agents/, commands/ in the profileUser skills live in ~/.agents/skills, outside CODEX_HOMECopy Claude's folders; Codex user skills are already shared
Session historyPer profilesessions/ per profileResume with the same alias
Repository config.claude/settings.json, .mcp.json, CLAUDE.md.codex/config.toml, AGENTS.mdShared automatically, because it lives in the repo

Re-adding a personal MCP server looks the same as the first time, with the alias in front:

bash
claude-work mcp add --scope user --transport http notion https://mcp.notion.com/mcp codex-work mcp add context7 -- npx -y @upstash/context7-mcp

Do not copy .claude.json or auth.json between profiles. Anthropic documents that .claude.json holds your sign-in session along with MCP servers and per-project state, and OpenAI warns that auth.json contains access tokens. Copy settings and instructions; let each profile sign in on its own.

Expect a new profile to ask you to trust each project folder again. Claude Code keeps trust decisions in the profile's .claude.json, and Codex records project trust in the profile's config.toml and loads a repository's .codex/config.toml only for trusted projects.

The tidiest arrangement keeps team configuration in the repository, where every account sees it, and treats each profile as a thin layer: the login, a few preferences, and personal MCP servers.

Pitfalls that send you to the wrong account#

An API key in your shell overrides every profile#

Claude Code checks environment credentials before your /login session. Cloud-provider variables, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_API_KEY, an apiKeyHelper, and CLAUDE_CODE_OAUTH_TOKEN all rank above the subscription login. If one of them is exported in ~/.zshrc, every alias sees it, whichever profile you meant to use. An ANTHROPIC_API_KEY needs your approval once in interactive mode and is always used with -p; after that, usage is billed to the API instead of your plan.

bash
unset ANTHROPIC_API_KEY

Then run /status. When a login and a key are both present, it marks the one not in use.

Console sign-ins without an API key aren't per directory#

Separate directories keep claude.ai logins and API keys apart. They don't separate two Claude Console sign-ins made without an API key, because Claude Code stores that kind of sign-in outside the configuration directory.

Codex needs the directory to exist#

OpenAI's docs are explicit: if you set CODEX_HOME, the directory must already exist. The mkdir -p in step 1 is not optional, and a typo in the alias points Codex at a folder that isn't there.

Editors and desktop apps need their own setting#

The Claude Code VS Code extension has an environmentVariables setting for the Claude process. Put CLAUDE_CONFIG_DIR there as an absolute path; the extension doesn't expand ~ and ignores relative values. The desktop apps sign in from their own menus, and neither vendor documents a profile variable for them, so run the second account from a terminal or an editor.

Do the same thing in Agentastic#

Agentastic is a native macOS workspace for running Claude Code, Codex, and other agent CLIs in parallel. It launches the CLIs and logins you already have, and its Usage & Cost panel manages one profile per login.

  1. Open View → Usage (Cmd+Opt+U).
  2. Check the cards. Agentastic looks in each provider's default directory, in sibling profile directories named by convention (~/.claude-work, ~/.codex-personal), and in directories it created itself. Profiles you made with the steps above appear without extra work. Discovery stops there; it doesn't search your home directory for credentials.
  3. To add a login, click Add account under Claude or Codex and name the profile. Agentastic runs the provider's own sign-in in a terminal and opens the login page in a browser tab. The new login gets its own config directory, so it never overwrites the first.
  4. Read the quota. Each card shows the provider's reported rate-limit windows, such as the 5-hour and weekly windows, with a countdown to reset. Numbers refresh every five minutes, and a card that needs a new token shows the exact sign-in command to copy.
  5. Launch agents. Agents launched against a profile inherit it through the same variables you would set by hand: CLAUDE_CONFIG_DIR and CODEX_HOME.
  6. Optionally, turn on Show Subscription Usage for an agent in Settings → Agents to see its remaining quota in the Inspector's Agents card, for example 58% 5h · 41% wk.

Rename or remove a profile from its card menu. Grok logins work the same way through GROK_HOME.

The tradeoffs are worth knowing. Agentastic is macOS only (macOS 14 or later). The Usage panel covers logins on this Mac; agents on remote hosts or cloud VMs write their logs on those machines and aren't included yet. And if you only ever use one provider in one terminal, two aliases are all you need.

To see what each account has actually consumed over a week or a quarter, read how to track Claude Code and Codex usage and cost. To try the panel, download Agentastic.

Sources and further reading#

Frequently asked questions#

How do I use Claude Code with multiple accounts?#

Give each account its own configuration directory and start Claude Code with the CLAUDE_CONFIG_DIR environment variable pointing at it. A shell alias such as claude-work makes that one word. Each directory keeps its own login, settings, and session history, so both accounts stay signed in.

How do I switch accounts in Claude Code?#

With a single profile, type /logout and then /login, and pick the other account. With one profile per account, you don't switch at all: launch claude for one account and your alias, such as claude-work, for the other. Run /status or claude auth status --text to confirm which login is active.

Can I run two Claude Code accounts at the same time?#

Yes, as long as each runs with a different CLAUDE_CONFIG_DIR. On macOS, Claude Code ties the Keychain entry to the config directory, so two terminals with different directories use different logins. Sessions that share a directory share one login.

Does the Codex CLI support multiple accounts?#

Yes, through CODEX_HOME. Create a directory such as ~/.codex-work, start Codex with CODEX_HOME pointing at it, and run codex login. The directory must exist before Codex starts, and codex login status shows which account it uses.

Can the Codex app use multiple accounts?#

OpenAI documents signing in and out from the desktop app's profile menu, not two simultaneous logins there. CODEX_HOME is documented for the Codex CLI, IDE extension, and app-server, so the reliable way to run a second account at the same time is a terminal profile or a tool that launches the CLI with that variable.

Can I use multiple Claude accounts in VS Code?#

The Claude Code extension has an environmentVariables setting for the Claude process. Set CLAUDE_CONFIG_DIR there to an absolute path, because the extension does not expand ~ and ignores relative paths.

Is it against the rules to use multiple Claude Code or Codex accounts?#

That depends on each provider's terms and your plan, which this guide can't interpret for you. Read Anthropic's and OpenAI's terms and your employer's policy for work seats, and don't use extra accounts to get around usage limits.

About the Author

Adel Ahmadyan

Builds Agentastic.dev, the native macOS multi-agent IDE.