# Multiple accounts in every coding agent CLI: a reference

> Multiple accounts in a coding agent CLI: Copilot, Amp and OpenCode 2 switch natively. Most others need a home folder per account, set by one variable.

Source: https://shuriken.sh/guides/coding-agent-multiple-accounts

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.

By Shuriken Updated 27 October 2026 9 min read

**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](https://code.claude.com/docs/en/authentication) 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](https://shuriken.sh/guides/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](https://learn.chatgpt.com/docs/config-file/environment-variables), 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](https://shuriken.sh/guides/codex-cli-switch-account).

### 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](https://shuriken.sh/guides/copilot-cli-switch-account).

### 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](https://developers.googleblog.com/en/an-important-update-transitioning-gemini-cli-to-antigravity-cli/) 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](https://shuriken.sh/guides/gemini-cli-change-google-account) 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](https://shuriken.sh/guides/cursor-switch-account).

### 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](https://shuriken.sh/guides/opencode-multiple-accounts) 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'

- Make the folders first (mkdir -p ~/.codex-work), because Codex needs its CODEX_HOME to exist already.
- 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).
- 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](https://shuriken.sh/guides/claude-code-multiple-accounts-windows) has a profile function and the WSL route.

Shuriken moves a running chat to another of your own accounts when one reaches its limit, on every device.

[Download](https://shuriken.sh/download)

## 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](https://shuriken.sh/guides/claude-code-logout-chat-history) 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.

- Anthropic's [Consumer Terms](https://www.anthropic.com/legal/consumer-terms) say you may not share your login or credentials "with anyone else" or "make your Account available to anyone else". We found no limit on how many accounts one person holds ([the rules for multiple Claude accounts](https://shuriken.sh/guides/multiple-claude-accounts-rules)).
- OpenAI's [Terms of Use](https://openai.com/policies/terms-of-use/) forbid sharing credentials or making your account available to anyone else ([two ChatGPT accounts with Codex](https://shuriken.sh/guides/chatgpt-multiple-accounts-codex-rules)).
- GitHub's [Terms of Service](https://docs.github.com/en/site-policy/github-terms/github-terms-of-service) say "One person or legal entity may maintain no more than one free Account", and a login may only be used by one person.

## 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](https://shuriken.sh/blog/what-is-a-source)), 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](https://shuriken.sh/features/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](https://shuriken.sh/guides/switch-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](https://shuriken.sh/features/coding-agents). Free holds two sources, Pro has no cap, and [the download is here](https://shuriken.sh/download).

Share

[X](https://x.com/intent/post?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Fcoding-agent-multiple-accounts&text=Multiple%20accounts%20in%20every%20coding%20agent%20CLI%3A%20a%20reference)[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Fcoding-agent-multiple-accounts)[Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fshuriken.sh%2Fguides%2Fcoding-agent-multiple-accounts&t=Multiple%20accounts%20in%20every%20coding%20agent%20CLI%3A%20a%20reference)[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fshuriken.sh%2Fguides%2Fcoding-agent-multiple-accounts&title=Multiple%20accounts%20in%20every%20coding%20agent%20CLI%3A%20a%20reference)[E-mail](mailto:?subject=Multiple%20accounts%20in%20every%20coding%20agent%20CLI%3A%20a%20reference&body=https%3A%2F%2Fshuriken.sh%2Fguides%2Fcoding-agent-multiple-accounts)

## Sources

- [Claude Code docs: Authentication (multiple accounts, credential management, precedence)](https://code.claude.com/docs/en/authentication) (accessed 24 October 2026)
- [Claude Code docs: CLI reference (claude auth)](https://code.claude.com/docs/en/cli-reference) (accessed 24 October 2026)
- [Claude Code docs: Explore the .claude directory](https://code.claude.com/docs/en/claude-directory) (accessed 24 October 2026)
- [Codex docs: Authentication](https://learn.chatgpt.com/docs/auth) (accessed 24 October 2026)
- [Codex docs: Environment variables (CODEX_HOME)](https://learn.chatgpt.com/docs/config-file/environment-variables) (accessed 24 October 2026)
- [Codex docs: Advanced configuration (profiles)](https://learn.chatgpt.com/docs/config-file/config-advanced) (accessed 24 October 2026)
- [GitHub Docs: Authenticating GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/authenticate-copilot-cli) (accessed 24 October 2026)
- [GitHub Docs: Copilot CLI configuration directory reference](https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-config-dir-reference) (accessed 24 October 2026)
- [Gemini CLI docs: Configuration (GEMINI_CLI_HOME)](https://geminicli.com/docs/reference/configuration/) (accessed 24 October 2026)
- [Gemini CLI docs: Authentication](https://geminicli.com/docs/get-started/authentication/) (accessed 24 October 2026)
- [Gemini CLI docs: Session management](https://geminicli.com/docs/cli/session-management/) (accessed 24 October 2026)
- [Gemini CLI source: authCommand.ts (/auth signout)](https://github.com/google-gemini/gemini-cli/blob/main/packages/cli/src/ui/commands/authCommand.ts) (accessed 24 October 2026)
- [Gemini CLI source: storage.ts (oauth_creds.json)](https://github.com/google-gemini/gemini-cli/blob/main/packages/core/src/config/storage.ts) (accessed 24 October 2026)
- [Google Developers Blog: Transitioning Gemini CLI to Antigravity CLI](https://developers.googleblog.com/en/an-important-update-transitioning-gemini-cli-to-antigravity-cli/) (accessed 24 October 2026)
- [Cursor docs: CLI authentication](https://cursor.com/docs/cli/reference/authentication) (accessed 24 October 2026)
- [Cursor docs: CLI parameters](https://cursor.com/docs/cli/reference/parameters) (accessed 24 October 2026)
- [OpenCode docs: CLI (auth login, list, logout)](https://opencode.ai/docs/cli/) (accessed 24 October 2026)
- [OpenCode docs: Troubleshooting (storage)](https://opencode.ai/docs/troubleshooting) (accessed 24 October 2026)
- [OpenCode source: global-roots.ts (XDG base directories)](https://github.com/anomalyco/opencode/blob/dev/packages/util/src/global-roots.ts) (accessed 24 October 2026)
- [OpenCode 2 docs: CLI providers (accounts, auth switch)](https://opencode.ai/v2/docs/cli/providers) (accessed 24 October 2026)
- [Amp docs: CLI (accounts, AMP_API_KEY)](https://ampcode.com/docs/cli) (accessed 24 October 2026)
- [Grok Build docs: Settings (GROK_HOME)](https://docs.x.ai/build/settings) (accessed 24 October 2026)
- [Grok Build docs: Sessions](https://docs.x.ai/build/features/sessions) (accessed 24 October 2026)
- [Grok Build user guide: Authentication](https://github.com/xai-org/grok-build/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/02-authentication.md) (accessed 24 October 2026)
- [Kimi Code CLI docs: Environment variables (KIMI_CODE_HOME)](https://www.kimi.com/code/docs/en/kimi-code-cli/configuration/env-vars.html) (accessed 24 October 2026)
- [Kimi Code CLI docs: Getting started (/login, /logout)](https://www.kimi.com/code/docs/en/kimi-code-cli/guides/getting-started) (accessed 24 October 2026)
- [Pi docs: Configuration (PI_CODING_AGENT_DIR)](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/configuration.md) (accessed 24 October 2026)
- [Pi docs: Providers (/login, /logout)](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/providers.md) (accessed 24 October 2026)
- [Pi docs: Sessions (PI_CODING_AGENT_SESSION_DIR)](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/docs/sessions.md) (accessed 24 October 2026)
- [Mistral Vibe docs: Configuration (VIBE_HOME)](https://docs.mistral.ai/vibe/code/cli/configuration) (accessed 24 October 2026)
- [Mistral Vibe docs: API keys and profiles](https://docs.mistral.ai/vibe/code/cli/api-keys-profiles) (accessed 24 October 2026)
- [Anthropic Consumer Terms of Service](https://www.anthropic.com/legal/consumer-terms) (accessed 24 October 2026)
- [OpenAI Terms of Use](https://openai.com/policies/terms-of-use/) (accessed 24 October 2026)
- [GitHub Terms of Service](https://docs.github.com/en/site-policy/github-terms/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.

Source switching

One account runs dry. The next one takes over.

Add the Claude, Codex and Gemini accounts you own. At your switch point, your chats move to another of them and keep going.

[Download](https://shuriken.sh/download)

[Other platforms](https://shuriken.sh/download#main)

## Keep reading

- [Codex usage limits explained (2026): Guide 27 Oct 2026 5 min read How Codex limits work on ChatGPT Plus and Pro: the 5-hour and weekly windows, the 2026 changes, checking yours with /status, and using several accounts.](https://shuriken.sh/guides/codex-usage-limits)
- [Codex login not working? Every sign-in error, fixed: Guide 27 Oct 2026 8 min read Codex login not working? Match your error: port 1455 busy, no browser on a server, refresh token already used, or a config.toml that logs you out.](https://shuriken.sh/guides/codex-login-not-working)
- [Hot swapping: chats that move when an account runs out: Story 27 Oct 2026 4 min read Hot swapping AI accounts, the way Shuriken does it: your running chats move to another of your accounts when one nears its limit. What happens at 99%.](https://shuriken.sh/blog/hot-swapping-accounts)
- [How Shuriken picks the next account: Story 27 Oct 2026 5 min read At your switch point (99% by default) or a limit, Shuriken moves your chats to the source with the most room. Expiring capacity goes first, API keys last.](https://shuriken.sh/blog/how-switching-picks-the-next-account)
- [Codex with more than one ChatGPT account: Update 27 Oct 2026 4 min read Add each ChatGPT sign-in you own as a source. When one reaches its Codex limit, Shuriken moves your Codex chats to the next and they carry on.](https://shuriken.sh/blog/codex-multiple-chatgpt-accounts)

## Free tools

- [Claude limit reset tracker](https://shuriken.sh/tools/limit-resets/claude)
- [Codex limit reset tracker](https://shuriken.sh/tools/limit-resets/codex)
