Claude Code Account Switch Not Working? Symptoms, Causes and Fixes
If Claude Code still uses the old account after aisw use claude work, it is usually a Claude process or terminal that started before the switch. Exit it, checkaisw status --tool claude, and start a new claude. Otherwise, find the exact message aisw verify printed below. Each one has a cause and a fix.
This page assumes you already have aisw profiles. If you are setting up from scratch, start with how to switch Claude Code accounts. All output below comes from aisw 0.3.10 on macOS with Claude Code 2.1.294, using API-key profiles named personal and work. Home-directory paths are shortened to /Users/you.
Start with three read-only checks
Run these in the same terminal you will launch Claude Code from. None of them change any state.
aisw status --tool claude
aisw verify
aisw doctorstatus shows which profile aisw thinks is active and a one-lineState. verify turns that into pass, warn or fail with aFix line. doctor checks the binary version, the shell hook and file permissions. A healthy macOS setup with a file-backed profile looks like this:
$ aisw status --tool claude
Claude Code
Version : 2.1.294 (Claude Code)
Compatibility : newer_than_verified
installed Claude Code is outside the audited baseline v2.1.266
Active : work
Auth : api_key
Backend : file
Claude auth : api_key
State mode : isolated
State : credentials present (stored in profile files; Claude reads live macOS Keychain)aisw verify also exits non-zero when anything fails, so you can put it in a script before claude. The symptoms below are grouped by what you see.
Claude Code still uses the old account after switching
Cause: the Claude process started before the switch
aisw use rewrites the credential Claude Code reads at startup. It does not reach into a Claude process that is already running, so that session keeps the account it started with. This also covers editor tasks and terminals that launched Claude earlier.
Fix: exit Claude Code, switch, and start a new process.
aisw use claude work
aisw status --tool claude
claudeIf you need a different account without leaving the session, use Claude Code's own/login instead. See the Claude Code login guide for how that interacts with saved profiles.
Cause: the live login no longer matches the active profile
When aisw can read Claude's live credential (file storage, or a profile kept in the system keyring) it compares it with the active profile. If you ran /login or another tool changed the login after the last aisw use, you get:
State : credentials present, but live tool config does not match the active profileand from aisw verify:
live tool credentials do not match the recorded active profile
Fix
Run 'aisw use claude work' to reapply the active profileFix: run aisw use claude work to put the profile back. If you want to keep the account you just logged into instead, save it as its own profile:
aisw add claude current --from-live --set-activeaisw verify: "live macOS Keychain state was not verified"
This is the most common warning on a Mac, and it is not an error:
$ aisw verify
Claude Code
Status : warn
Active : work
live macOS Keychain state was not verified for this Claude file-backed profile
Fix
Use 'aisw status --json' for the current live-match signal, or switch once with 'aisw use claude <profile>'.What it means: on macOS, Claude Code reads its live login from the Keychain, even when a .credentials.json file is present. Your profile's backend is file, so aisw stores the profile on disk, and it does not read the Keychain to compare the two during status or verify. Inaisw status --json this shows as "active_profile_applied": null: unknown, not mismatched.
Fix: if Claude Code is on the account you expect, there is nothing to do. If it is not, or you are unsure, switch once so aisw writes the profile into the Keychain:
aisw use claude workmacOS asks for Keychain access when switching Claude Code
On macOS, aisw use claude prints this before it touches anything:
Claude on macOS stores live auth in Keychain. Switching this profile may trigger a macOS Keychain prompt so aisw can update Claude's active credentials.What it means: the prompt is macOS asking whether aisw may update Claude Code's Keychain item. That write is the switch.
Fix: allow it. If you deny it, aisw cannot write the credential, the switch fails before the active profile changes, and Claude Code keeps the previous account. The security page explains what aisw stores and where.
Switch works in one terminal but not another
Cause: CLAUDE_CONFIG_DIR is set per shell
The default Claude state mode is isolated: each profile gets its own Claude config directory, selected through CLAUDE_CONFIG_DIR. With the shell hook installed, aisw use claude work exports that variable into the shell you ran it in. Every other terminal that was already open keeps the value it had, so Claude Code there reads the previous profile's directory.
Compare the two terminals:
echo "$AISW_SHELL_HOOK"
echo "$CLAUDE_CONFIG_DIR"AISW_SHELL_HOOK should print 1. CLAUDE_CONFIG_DIRshould point at ~/.aisw/profiles/claude/work in both.
Fix: run aisw use claude work in the other terminal too. Or, if you do not want per-terminal state, switch with shared mode, which unsetsCLAUDE_CONFIG_DIR and only swaps the credential:
aisw use claude work --state-mode sharedIf you want different accounts in different repositories rather than different terminals, see a Claude Code account per project.
Cause: the shell hook is not installed
aisw doctor reports it directly:
⚠ shell/hook /Users/you/.zshrc does not exist — hook not installedor, when the rc file exists but has no hook:
✗ shell/hook hook not found in /Users/you/.zshrc — run 'aisw init' to install itWithout the hook, aisw use still writes Claude's live credential, but nothing sets CLAUDE_CONFIG_DIR in your shell. Fix: runaisw init, open a new terminal, and switch again. For a single shell without the hook, evaluate the exports yourself:
eval "$(aisw use claude work --emit-env)"aisw says isolated-mode Claude OAuth switching is unsupported
aisw use claude work refuses with:
isolated-mode Claude OAuth switching is unsupported for profile 'work'.
This Claude install uses the legacy shared live Keychain credential, so CLAUDE_CONFIG_DIR isolates config/history but not the live OAuth credential.
This is an expected upstream limitation, not an aisw corruption bug.
Use shared mode instead: aisw use claude work --state-mode shared
For repeatable automation or durable multi-profile setups, prefer an API key or long-lived auth token.What it means: older Claude Code builds (aisw treats 2.1.19 and earlier this way) keep every OAuth login in one Keychain entry, whateverCLAUDE_CONFIG_DIR says. aisw status shows it asClaude auth : oauth_macos_keychain_shared_live. Giving each profile its own directory would not give it its own login, so aisw refuses instead of pretending.
Fix: switch in shared mode as the message says, or update Claude Code. Builds from 2.1.121 scope the Keychain entry by CLAUDE_CONFIG_DIR, andaisw use then confirms:
Claude OAuth for this install is scoped by CLAUDE_CONFIG_DIR, so isolated mode keeps refreshes tied to this profile.Builds in between are reported as unknown:
Claude OAuth keychain behavior is unknown for this install; isolated mode may not be durable unless Claude scopes credentials by config dir.If you see that line and Claude Code later falls back to another account after a token refresh, use --state-mode shared for that profile.
Switching broke after a Claude Code update
Both status and doctor compare the installed version with the release aisw was tested against:
Compatibility : newer_than_verified
installed Claude Code is outside the audited baseline v2.1.266
⚠ tool/claude /Users/you/.local/bin/claude found (2.1.294 (Claude Code)) — baseline v2.1.266; compatibility is newer_than_verifiedWhat it means: this aisw release was audited against Claude Code v2.1.266, and you are running something newer (older_than_verified means older). It is a warning on its own; most updates do not change how credentials are stored.
Fix: if switching still works, ignore it. If it stopped working after the update, look for this State line:
State : credential storage layout is unrecognized; inspect the profile before switchingThat means the stored profile does not have a credential layout aisw recognizes. Do not run aisw use over it. Update aisw first, then check again.
Claude Code uses the wrong account in VS Code
VS Code's integrated terminal is a normal shell, so everything above applies, with one addition: a terminal opened before the switch keeps its old CLAUDE_CONFIG_DIRuntil you run aisw use in it or open a new one. Claude sessions started from the editor also keep the account they started with until you restart them. TheClaude Code account switching in VS Code post covers the editor side.
Claude Code will not start: "workspace guard refused to launch"
If a repository is bound to a context and the guard is strict, theclaude wrapper from the shell hook blocks the launch when the active profile does not match:
Error: workspace guard refused to launch Claude Code.
Expected context: 'work'
Current state: 'claude personal, codex none, gemini none, agy none'
Status: mismatch
Run 'aisw context use work'.This is the guard doing its job: personal is active in a repository bound to the work context. Fix: run the command it prints, thenclaude again. aisw workspace status shows which rule matched. To set this up for your own repositories, see how to prevent the wrong account in a repository.
Other aisw verify failures for Claude Code
"managed credential permissions are too broad"
Claude Code
Status : fail
Active : work
managed credential permissions are too broad
Fix
Run 'aisw doctor --json' to inspect the failing permission checkA file in the profile is readable by other users. aisw doctor names it (expected 0600, found: …/profiles/claude/work/.credentials.json is 0644).Fix: preview, then apply the permission repair:
aisw repair --dry-run
aisw repair --apply --fix permissions"managed credentials are missing"
managed credentials are missing
Fix
Restore the profile from backup or re-run 'aisw add claude work'The profile is registered but its credential file is gone (status showscredential files missing). Fix: find a backup withaisw backup list and restore it with aisw backup restore <id>, or remove the profile and add the account again.
"active profile is missing from aisw config"
Active : old-work
active profile is missing from aisw config
Fix
Run 'aisw repair --apply' or re-add claude old-workThe active pointer names a profile that no longer exists, usually after a hand edit or a partial restore. Fix: select a profile that does exist withaisw use claude work, or run the command it suggests.
"profiles are stored, but no active profile is selected"
You added profiles but never switched to one, so aisw has not touched Claude's live login.Fix: aisw use claude work.
For the same checks across Codex CLI, Gemini CLI and Antigravity, see theaisw troubleshooting docs.
Make Claude Code account switching predictable
Install aisw for profile checks in the terminal, or inspect the active account in Desktop.