Cross-tool · Tested with aisw v0.3.7 · Updated July 16, 2026
Prevent the Wrong Account from Being Used in a Repository
Bind the repository to the context it should use with aisw workspace bind . --context <name>, then set aisw workspace guard --mode strict. aisw's shell hook checks the active accounts against the binding every time you launch a coding agent from that repository, and blocks the launch in strict mode if they don't match.
The most common way teams lose an account boundary isn’t a leaked credential — it’s opening the wrong terminal tab in the wrong repository with the wrong account still active. Workspace guardrails turn that from a silent mistake into a blocked action.
How it works
aisw’s shell hook — installed during aisw init — runs a check whenever you launch Claude Code, Codex CLI, or Gemini CLI from a directory. If that directory (or one of its parents) is bound to a context, the hook compares the currently active profiles against what the binding expects.
Set it up
1. Bind each sensitive repository to the context it should use.
cd ~/code/client-acme-appaisw workspace bind . --context client-acmeRun this once per repository. aisw records the binding against the repo’s Git remote when available, so it still matches if the repo is cloned to a different path later.
2. Turn on enforcement.
aisw workspace guard --mode strictThis applies globally to every bound repository. Use --mode warn first if you want to confirm your bindings are correct before anything gets blocked.
3. Confirm the setup.
aisw workspace statusLists every bound repository, its expected context, and whether the current directory (if you’re inside one) currently matches.
What it looks like when it catches a mistake
$ cd ~/code/client-acme-app$ claudeaisw: blocked — this repository expects context "client-acme", but the active Claude Code profile is "personal". Run `aisw context use client-acme` to fix this, or `aisw workspace guard --mode warn` to downgrade to a warning.Desktop method (coming soon)
AI Switcher Desktop is currently in private testing and not yet available for public download. The steps below reflect the current build; use the CLI method above until it ships.
Screenshot placeholder
AI Switcher Desktop Diagnostics screen showing a repository-context mismatch with a one-click fix action
The Diagnostics screen in AI Switcher Desktop lists every mismatch across all bound repositories in one place, with a one-click action to switch to the correct context.
Verify the result
Switch to an account outside the bound context, then try to launch the coding agent from the bound repository. Confirm it’s blocked (strict mode) or warned (warn mode), then switch back and confirm the launch proceeds normally.
Frequently asked questions
What's the difference between strict and warn mode?
Strict mode blocks the coding-agent launch entirely when the active account doesn't match the repository's binding. Warn mode prints a warning to the terminal but still lets the launch continue — useful while you're first setting up bindings and don't want to risk blocking real work.
Does this require the Desktop app, or does it work from the terminal alone?
It works entirely from the CLI via a shell hook installed during aisw init. The Desktop app adds a visual Diagnostics view for the same bindings, but isn't required for enforcement.
Does workspace binding affect repositories I haven't explicitly bound?
No. Guardrails only apply to repositories you've bound with aisw workspace bind. Everything else behaves exactly as it did before.