Multiple accounts in every coding agent CLI: a reference

Copilot CLI (/user switch), Amp (amp account switch) and OpenCode 2 hold several accounts and switch between them. Claude Code, Codex, Gemini CLI, Grok, Kimi, Pi and Mistral Vibe need one home folder per account, set with one variable, while Cursor CLI takes an API key per shell and OpenCode 1 its own XDG data folder.

Contents

Two of the 11 coding agent CLIs we checked handle multiple accounts on their own: Copilot CLI (/user switch) and Amp (amp account switch). OpenCode 2, installed separately as @opencode/cli, does too; OpenCode 1, which opencode.ai/install gives you, doesn't. Most of the others keep one sign-in per home folder, so the way to run two accounts is one folder per account, picked with an environment variable: CLAUDE_CONFIG_DIR for Claude Code, CODEX_HOME for Codex, GEMINI_CLI_HOME for Gemini CLI. Cursor CLI is the odd one: its docs offer only an API key for a second account.

The rows follow each CLI's docs as they read on 24 October 2026, and "Not documented" marks a gap in them. Two cells needed the source code. Gemini CLI's command reference lists only /auth, and /auth signout turned up in authCommand.ts. OpenCode's docs give the data path, and global-roots.ts shows it becomes $XDG_DATA_HOME/opencode when that variable is set.

Multiple accounts in each coding agent CLI, at a glance#

Agent Sign-in kept in Variable that moves it Log out Several accounts built in Sessions kept in
Claude Code macOS Keychain (one entry per config folder); ~/.claude/.credentials.json on Linux and Windows CLAUDE_CONFIG_DIR /logout or claude auth logout No ~/.claude/projects/
Codex ~/.codex/auth.json, or the OS keyring if cli_auth_credentials_store says so CODEX_HOME codex logout No (--profile is config, not accounts) ~/.codex/sessions/
Copilot CLI OS keychain, service copilot-cli; ~/.copilot/config.json if there is no keychain COPILOT_HOME (the folder); COPILOT_GITHUB_TOKEN, GH_TOKEN, GITHUB_TOKEN override the login /logout Yes: /user list, /user switch ~/.copilot/session-state/
Gemini CLI ~/.gemini/oauth_creds.json GEMINI_CLI_HOME /auth signout (or /auth logout) No; personal Google sign-ins stopped on 18 June 2026 ~/.gemini/tmp/<project_hash>/chats/
Cursor CLI "Stored locally"; no path in the docs None documented; CURSOR_API_KEY or --api-key agent logout (agent status shows who) Not in the docs Not documented; agent ls lists chats
OpenCode ~/.local/share/opencode/auth.json XDG_DATA_HOME opencode auth logout No in OpenCode 1 (one credential per provider); OpenCode 2 keeps several (opencode auth switch) ~/.local/share/opencode/opencode.db
Amp Not documented AMP_API_KEY overrides saved accounts amp logout Yes: amp account list, amp account switch Not a local folder in the docs
Grok ~/.grok/auth.json GROK_HOME grok logout No ~/.grok/sessions/
Kimi Code Under ~/.kimi-code KIMI_CODE_HOME /logout No Under ~/.kimi-code
Pi ~/.pi/agent/auth.json PI_CODING_AGENT_DIR /logout No; one credential per provider ~/.pi/agent/sessions/
Mistral Vibe API key in the OS keyring or ~/.vibe/.env VIBE_HOME None documented; vibe --setup sets a new key No ~/.vibe/logs/

Notes on each agent#

Claude Code#

Anthropic's authentication page has a section called "Log in with multiple accounts", and its answer is one config folder per account: "Each directory has its own settings, session history, and claude.ai login or API key." On a Mac the Keychain entry is keyed to the folder too, so a session with a different folder reads a different entry. One gap: two Claude Console sign-ins made without an API key are stored outside the folder, so separate folders don't keep them apart. claude auth status prints the folder in use as configDirectory. The aliases, step by step, are in CLAUDE_CONFIG_DIR profiles.

Codex#

CODEX_HOME "sets the root for Codex state, including config, auth, logs, sessions, skills, and standalone package metadata", per OpenAI's environment variables page, and the folder must exist before you point Codex at it. Set cli_auth_credentials_store = "file" in each home's config.toml, because the login then sits in that folder's auth.json rather than the system keyring. codex login status shows which method is active. Profiles (--profile) layer config files and have nothing to do with accounts. Steps for a second ChatGPT account are in switching accounts in Codex CLI.

Copilot CLI#

GitHub's docs say "You can log in with multiple accounts, and the CLI will remember the last-used account."

  • /user list shows the accounts and /user switch changes the active one, so most people never need COPILOT_HOME.
  • A token in your shell beats every stored login. The CLI checks COPILOT_GITHUB_TOKEN, then GH_TOKEN, then GITHUB_TOKEN, so if /user switch seems to change nothing, env | grep TOKEN shows whether one is set.
  • /logout removes the local token but doesn't revoke it on GitHub.

Step by step: Copilot CLI: switch GitHub accounts.

Gemini CLI#

GEMINI_CLI_HOME stands in for your home folder: the CLI makes a .gemini folder inside it. Since 18 June 2026 Google no longer serves Gemini CLI requests for free Gemini Code Assist for individuals or Google AI Pro and Ultra, per Google's announcement of 19 May 2026. After that date a second account needs a Code Assist Standard or Enterprise licence, or a paid GEMINI_API_KEY. Changing the Google account in Gemini CLI walks through /auth signout, the GOOGLE_CLOUD_PROJECT a work account needs, and a second home.

Cursor CLI#

agent login, agent logout and agent status (alias whoami) handle the one stored sign-in. Cursor's docs name no folder variable, so the documented way to use a second account is its API key in CURSOR_API_KEY or --api-key for that shell. The editor side is in switching accounts in Cursor.

OpenCode#

  • opencode auth login writes to auth.json, one entry per provider, so a second Anthropic or OpenAI login replaces the first.
  • A profile with its own XDG_DATA_HOME gets its own auth.json and opencode.db.
  • The config, MCP servers included, stays shared in ~/.config/opencode, because it follows XDG_CONFIG_HOME.
  • opencode debug paths prints where everything went.

OpenCode 2 saves each login as an account, and opencode auth switch changes the active one. OpenCode with more than one account covers both versions.

Amp#

"Run amp login to add an account", and the CLI keeps the accounts for each Amp server apart. amp account switch <email-or-user-id> changes the active one, but a running process keeps the account it started with, so start a new amp after switching. AMP_API_KEY "takes precedence over saved accounts until you unset it".

Grok, Kimi Code, Pi and Mistral Vibe#

One variable moves each of these homes whole. They differ on API keys.

  • GROK_HOME (default ~/.grok). In Grok a stored sign-in beats XAI_API_KEY, so to use the key you run grok logout first.
  • KIMI_CODE_HOME (default ~/.kimi-code): "the config file, sessions, logs, OAuth credentials, and all other data land under the new path". Kimi doesn't read KIMI_API_KEY from your shell at all; keys go in config.toml.
  • PI_CODING_AGENT_DIR (default ~/.pi/agent). Pi's /logout removes the stored credential but "does not unset environment variables" or revoke it at the provider.
  • VIBE_HOME (default ~/.vibe). Mistral Vibe reads MISTRAL_API_KEY from the shell first, then ~/.vibe/.env, then the keyring, and its docs describe no logout.

How to keep two accounts signed in at once#

Each extra account gets one alias in ~/.zshrc or ~/.bashrc:

bash
alias claude-work='CLAUDE_CONFIG_DIR=~/.claude-work claude'
alias codex-work='CODEX_HOME=~/.codex-work codex'
alias gemini-work='GEMINI_CLI_HOME=~/gemini-work gemini'
alias opencode-work='XDG_DATA_HOME=~/.local/share-work opencode'
  1. Make the folders first (mkdir -p ~/.codex-work), because Codex needs its CODEX_HOME to exist already.
  2. Open a new terminal and run the alias once. Each CLI asks you to sign in for the new folder (codex-work login and opencode-work auth login also work).
  3. Sign in with the second account. The first one stays signed in under the default folder.

Windows takes the same variables. In PowerShell, $env:CLAUDE_CONFIG_DIR = "$HOME\.claude-work" followed by claude holds for that window only; two Claude Code accounts on Windows has a profile function and the WSL route.

What breaks when you split homes#

A fresh ~/.claude-work or ~/.codex-work holds only what the CLI writes on first run. Everything in this list stays behind in the old home.

  • Sessions. claude --resume under claude-work won't list a chat you started under claude, and codex resume behaves the same. Logging out doesn't delete them (does logging out of Claude Code delete your chats lists what stays).
  • User-level MCP servers: Claude Code's user-scope servers, Codex's config.toml, Copilot's mcp-config.json, Gemini's settings.json and Pi's mcp.json. Each profile needs them added again, and a server you sign in to needs that sign-in again. Servers in a project's own config file live in the repository, so every profile sees those.
  • Skills and slash commands.
  • Instruction files: CLAUDE.md, AGENTS.md, GEMINI.md.

Pi is the one CLI with a separate variable for history: point every profile's PI_CODING_AGENT_SESSION_DIR at one folder and they share it. For the rest, the fix by hand is a symbolic link from each extra home to the folder you want shared, such as ln -s ~/.claude/skills ~/.claude-work/skills. Never link the credential files. Don't link Gemini CLI's settings.json either, because the CLI writes the chosen sign-in method into it (security.auth.selectedType) and two homes sharing it would share that choice.

Is it allowed to have several accounts?#

Use only accounts you own and are entitled to use, and read your provider's terms, because they may not allow sharing a sign-in.

How Shuriken handles multiple accounts for every agent#

In Shuriken each sign-in or API key you add is a source (what a source is), and you can add several per agent in Settings › Sources. If a sign-in is already on the computer, Sources offers to add it. Behind each sign-in, Shuriken makes a home with the same variables as the table above (CLAUDE_CONFIG_DIR, CODEX_HOME, COPILOT_HOME, GEMINI_CLI_HOME, GROK_HOME, KIMI_CODE_HOME, PI_CODING_AGENT_DIR, VIBE_HOME, or separate XDG folders), so you never edit an alias.

The split-home problems get the by-hand fix, links, from one table in our server code (provider-specs.ts). Each account's home links these back to your own folder:

  • Claude Code: projects (the transcripts), settings.json, CLAUDE.md, agents, commands, skills, plugins and todos. History and skills stay the same whichever account runs.
  • Codex: sessions, archived_sessions, config.toml, AGENTS.md, prompts and skills. Each Codex also starts with file storage for the login, so every account's tokens stay in its own home.
  • Gemini CLI: GEMINI.md, commands, extensions, skills and tmp, where its chats are kept, and not settings.json. Shuriken also sets GEMINI_FORCE_ENCRYPTED_FILE_STORAGE=false, because with it on, Gemini CLI keeps its tokens in one Keychain item that every home shares, and a second sign-in would replace the first.
  • Copilot CLI: mcp-config.json, agents and skills.

Credentials are never linked. For Claude Code and Codex, Shuriken also writes the MCP settings from one list, so every account sees the same servers (global MCPs).

When the source in use nears its limit (99% by default), your chats move to another source of the same agent. We call that hot swapping: Shuriken moves your chats to another of your accounts or sources when one nears its limit. A Claude Code chat moves on its next request; other agents move when their current turn ends. The details are in switching Claude accounts without logging out.

Not every agent takes a sign-in. Cursor, Factory Droid, Qwen Code, Z.ai and MiniMax are added with an API key only, because Shuriken has no folder variable for those CLIs that would keep a second sign-in apart from the first. The full list of agents is on the coding agents page. Free holds two sources, Pro has no cap, and the download is here.

Sources

  1. Claude Code docs: Authentication (multiple accounts, credential management, precedence) (accessed 24 October 2026)
  2. Claude Code docs: CLI reference (claude auth) (accessed 24 October 2026)
  3. Claude Code docs: Explore the .claude directory (accessed 24 October 2026)
  4. Codex docs: Authentication (accessed 24 October 2026)
  5. Codex docs: Environment variables (CODEX_HOME) (accessed 24 October 2026)
  6. Codex docs: Advanced configuration (profiles) (accessed 24 October 2026)
  7. GitHub Docs: Authenticating GitHub Copilot CLI (accessed 24 October 2026)
  8. GitHub Docs: Copilot CLI configuration directory reference (accessed 24 October 2026)
  9. Gemini CLI docs: Configuration (GEMINI_CLI_HOME) (accessed 24 October 2026)
  10. Gemini CLI docs: Authentication (accessed 24 October 2026)
  11. Gemini CLI docs: Session management (accessed 24 October 2026)
  12. Gemini CLI source: authCommand.ts (/auth signout) (accessed 24 October 2026)
  13. Gemini CLI source: storage.ts (oauth_creds.json) (accessed 24 October 2026)
  14. Google Developers Blog: Transitioning Gemini CLI to Antigravity CLI (accessed 24 October 2026)
  15. Cursor docs: CLI authentication (accessed 24 October 2026)
  16. Cursor docs: CLI parameters (accessed 24 October 2026)
  17. OpenCode docs: CLI (auth login, list, logout) (accessed 24 October 2026)
  18. OpenCode docs: Troubleshooting (storage) (accessed 24 October 2026)
  19. OpenCode source: global-roots.ts (XDG base directories) (accessed 24 October 2026)
  20. OpenCode 2 docs: CLI providers (accounts, auth switch) (accessed 24 October 2026)
  21. Amp docs: CLI (accounts, AMP_API_KEY) (accessed 24 October 2026)
  22. Grok Build docs: Settings (GROK_HOME) (accessed 24 October 2026)
  23. Grok Build docs: Sessions (accessed 24 October 2026)
  24. Grok Build user guide: Authentication (accessed 24 October 2026)
  25. Kimi Code CLI docs: Environment variables (KIMI_CODE_HOME) (accessed 24 October 2026)
  26. Kimi Code CLI docs: Getting started (/login, /logout) (accessed 24 October 2026)
  27. Pi docs: Configuration (PI_CODING_AGENT_DIR) (accessed 24 October 2026)
  28. Pi docs: Providers (/login, /logout) (accessed 24 October 2026)
  29. Pi docs: Sessions (PI_CODING_AGENT_SESSION_DIR) (accessed 24 October 2026)
  30. Mistral Vibe docs: Configuration (VIBE_HOME) (accessed 24 October 2026)
  31. Mistral Vibe docs: API keys and profiles (accessed 24 October 2026)
  32. Anthropic Consumer Terms of Service (accessed 24 October 2026)
  33. OpenAI Terms of Use (accessed 24 October 2026)
  34. GitHub Terms of Service (accessed 24 October 2026)

Frequently asked questions

Which coding agent CLIs support multiple accounts natively?

Copilot CLI and Amp, of the 11 we checked on 24 October 2026. Copilot CLI has /user list and /user switch; Amp has amp account list and amp account switch. OpenCode 2, a separate install from OpenCode 1, adds opencode auth switch, and the rest need a second home folder for a second account.

Where does Claude Code store its login?

Mac: the Keychain, in an entry keyed to the config folder. Linux and Windows: ~/.claude/.credentials.json. Setting CLAUDE_CONFIG_DIR=~/.claude-work moves both, so that folder gets its own login.

Does logging out delete my chat history?

Not in any doc we read. Copilot CLI's and Pi's logout delete the stored credential and leave it valid at the provider. Claude Code's /logout also resets first-run setup, and the session files under ~/.claude/projects/ stay where they are.

Why does my CLI ignore the account I just signed in with?

Usually an environment variable wins. ANTHROPIC_API_KEY (once approved), COPILOT_GITHUB_TOKEN, GH_TOKEN, GITHUB_TOKEN, AMP_API_KEY and MISTRAL_API_KEY all take precedence over what the CLI stored. Grok is the exception: its stored sign-in beats XAI_API_KEY.

Can I use Gemini CLI with my personal Google account?

Not since 18 June 2026. Google stopped serving Gemini CLI requests for free Code Assist for individuals and for Google AI Pro and Ultra. Code Assist Standard or Enterprise licences and paid Gemini API keys still work.

Free tools