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.
- 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.
- Add one alias per profile pointing the tool at a per-profile config dir.
Scope the env var to the alias (never
exportit globally), quote$HOME, and wrap everything in a marked block in the user's shell rc (~/.zshrcetc.). - 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.
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.
# === 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.