Skip to content

Instantly share code, notes, and snippets.

@sanjeed5
Last active June 25, 2026 12:57
Show Gist options
  • Select an option

  • Save sanjeed5/327cefebe9d34974c3462d2254442b00 to your computer and use it in GitHub Desktop.

Select an option

Save sanjeed5/327cefebe9d34974c3462d2254442b00 to your computer and use it in GitHub Desktop.
Prompt: have your coding agent set up multiple isolated accounts/profiles (work, personal, client) for AI tools — Cursor Agent CLI, Claude Code, Cursor/VS Code GUI — via shell aliases

Multiple accounts/profiles for AI coding tools

Paste this into your coding agent. It adds shell aliases so you can run an AI tool under several isolated accounts (work / personal / client), each with its own login, settings, and history.

What to do

  1. Ask the user (use a multiple-choice/question tool if you have one): which tool(s), how many profiles + names, and preferred alias names. Suggest defaults.
  2. Add one alias per profile pointing the tool at a per-profile config dir. Scope the env var to the alias (never export it globally), quote $HOME, and wrap everything in a marked block in the user's shell rc (~/.zshrc etc.).
  3. Tell the user: first run of a profile is a clean slate — log in with that account (and reinstall extensions for the GUI). It persists per profile after.

Config mechanism per tool

This trick only isolates the account if the tool stores its auth in a file inside its config dir. Tools that keep the token in the OS keychain (or another global store) will share one login no matter what — verify before relying on it.

Tool How Isolates login? Default
Claude Code (claude) CLAUDE_CONFIG_DIR ✅ yes (file-based creds) ~/.claude
Codex CLI (codex) CODEX_HOME (dir must exist — mkdir -p first) ✅ yes (file-based creds) ~/.codex
Cursor / VS Code GUI (cursor/code) --user-data-dir DIR --extensions-dir DIR flags ✅ yes (session in data dir) OS default
Cursor agent CLI (agent) CURSOR_CONFIG_DIR isolates settings/history only no — token is in the macOS Keychain (single global login). Switch with agent logout/login. ~/.cursor

For any other tool, find its override: check TOOL --help, then strings "$(which TOOL)" | grep -iE '[A-Z_]*(CONFIG|DATA|HOME)_?DIR', and note where it stores auth today (~/.toolname).

Verify isolation works before trusting it: point the tool at a fresh empty config dir and check its auth status. If it still shows you logged in, the token is stored globally (keychain) and per-dir aliases won't separate accounts.

Examples

# === AI tool profiles (managed block) ===
alias claude-personal='CLAUDE_CONFIG_DIR="$HOME/.claude-personal" claude'
alias codex-personal='CODEX_HOME="$HOME/.codex-personal" codex'   # mkdir -p ~/.codex-personal first
alias cursor-personal='cursor --user-data-dir "$HOME/.cursor-profiles/personal" --extensions-dir "$HOME/.cursor-profiles/personal/extensions"'
# Note: the Cursor *agent CLI* (`agent`) can't be split this way — its login is in
# the macOS Keychain (one global account). Use `agent logout`/`login` to switch.
# === end ===

Aliases work in interactive shells only (a clickable Dock/taskbar launcher needs a wrapper app). GUI extensions are duplicated on disk per profile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment