Commands
Global flags
Section titled “Global flags”aisw [--no-color] [--non-interactive] [--quiet] <command> ...| Flag | Effect |
|---|---|
--no-color | Disable ANSI color output |
--non-interactive | Fail instead of prompting; safe for CI |
--quiet | Suppress human-readable presentation output; does not suppress errors, JSON output, --emit-env, or shell-hook |
At a glance
Section titled “At a glance”aisw init [--yes]aisw add <tool> <profile> [--api-key KEY] [--from-env] [--from-live] [--label TEXT] [--credential-backend file|system-keyring] [--set-active] [--yes]aisw context create <name> [--claude <profile>] [--codex <profile>] [--gemini <profile>]aisw context list [--search TEXT] [--json]aisw context use <name> [--state-mode isolated|shared] [--emit-env]aisw context set <name> [--claude <profile>] [--codex <profile>] [--gemini <profile>]aisw context unset <name> [--claude] [--codex] [--gemini]aisw context remove <name> [--yes]aisw context rename <old> <new>aisw use <tool> <profile> [--state-mode isolated|shared] [--emit-env]aisw use --all --profile <profile> [--state-mode isolated|shared] [--emit-env]aisw workspace bind [PATH] --context <name>aisw workspace bind --git-remote <PATTERN> --context <name>aisw workspace bind --default --context <name>aisw workspace status [--json]aisw workspace doctor [--json]aisw workspace guard --mode warn|strictaisw list [tool] [--tool <tool>] [--search TEXT] [--sort name|recent] [--active-only] [--json]aisw status [--tool <tool>] [--search TEXT] [--sort name|recent] [--active-only] [--context] [--json]aisw remove <tool> <profile> [--yes] [--force]aisw rename <tool> <old> <new>aisw backup list [--tool <tool>] [--search TEXT] [--sort name|recent] [--active-only] [--json]aisw backup restore <backup_id> [--yes]aisw uninstall [--dry-run] [--remove-data] [--yes]aisw shell-hook <bash|zsh|fish|pwsh>aisw doctor [--json]<tool> is one of: claude, codex, gemini.
aisw init
Section titled “aisw init”aisw init [--yes]Bootstrap command. Run once after install.
- Creates
~/.aisw/with0700permissions. - Offers shell hook installation for bash, zsh, or fish.
- Detects currently logged-in accounts for each tool and offers to import them as named profiles.
- Reports current live state per tool, including whether it matches any existing
aiswprofile.
| Flag | Effect |
|---|---|
--yes | Accept all prompts without confirmation |
Notes:
initis safe to re-run. If~/.aisw/already exists, it skips creation and proceeds to detection.- For Gemini, when both
~/.gemini/.envand OAuth cache files are present, import uses the.envfile first. - For Claude Code on macOS,
initchecks the Keychain before checking the credentials file. initwill not import a duplicate if the OAuth identity matches an already-stored profile.
aisw initaisw init --yesaisw add
Section titled “aisw add”aisw add <tool> <profile> [--api-key KEY] [--from-env] [--from-live] [--label TEXT] [--credential-backend file|system-keyring] [--set-active] [--yes]Create a named profile.
| Flag | Effect |
|---|---|
--api-key KEY | Store the given API key |
--from-env | Read the key from the tool’s env var (ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY) |
--from-live | Capture the tool’s current live credentials without launching login |
--label TEXT | Human-readable description, shown in list and status |
| `—credential-backend file | system-keyring` |
--set-active | Activate the profile immediately after adding |
--yes | Overwrite an existing profile when used with --from-live |
Notes:
- Without
--api-key,--from-env, or--from-live,addruns the interactive OAuth flow for the tool. - In
--non-interactivemode, interactive OAuth is not available and the command fails. --from-livecaptures what the tool is currently using; it does not launch a browser or auth flow.--from-livealways activates the profile because those credentials are already live.--from-live --yesoverwrites an existing profile in place; the existing entry is not removed until capture succeeds.- When OAuth identity can be resolved,
addblocks creating a duplicate profile for an already-stored account. --credential-backendaffects the managedaiswprofile only. It does not force the upstream CLI’s live auth backend.- Gemini supports only
file. Claude and Codex supportfileandsystem-keyring. Stored config and status output usesystem_keyring.
Live credential locations by tool:
- Claude:
~/.claude/.credentials.jsonor the macOS Keychain - Codex:
~/.codex/auth.jsonor the OS keyring - Gemini:
~/.gemini/.env(API key) or OAuth files in~/.gemini/
aisw add claude work --api-key "$ANTHROPIC_API_KEY"aisw add codex ci --from-envaisw add gemini personal --label "Personal account" --set-activeaisw add claude work --from-liveaisw add codex work --from-live --yesaisw use
Section titled “aisw use”aisw use <tool> <profile> [--state-mode isolated|shared] [--emit-env]aisw use --all --profile <profile> [--state-mode isolated|shared] [--emit-env]Activate a stored profile as the live account.
| Flag | Effect |
|---|---|
--state-mode isolated | Set CLAUDE_CONFIG_DIR or CODEX_HOME to the profile directory (default) |
--state-mode shared | Unset CLAUDE_CONFIG_DIR or CODEX_HOME; tool reads its standard config dir |
--all | Switch every tool that has a matching profile name |
--profile NAME | Profile name; required with --all |
--emit-env | Print shell export/unset lines to stdout instead of writing them to the session |
Notes:
--state-modeapplies to Claude Code and Codex CLI only. Gemini does not support it.- Switching is atomic: the previous live state is snapshotted before any write. A failed write triggers a full rollback.
- With shell hook active,
aisw usealso emits the environment variable exports into the current shell session. --emit-envis used internally by the shell hook. You can use it directly to apply exports in a subshell:eval "$(aisw use claude work --emit-env)".
aisw use claude workaisw use codex work --state-mode sharedaisw use --all --profile personaleval "$(aisw use claude work --emit-env)"aisw context
Section titled “aisw context”Contexts are saved cross-tool mappings. They let you bind different per-tool profile names under one higher-level name such as work, personal, client-acme, or oss.
Practical framing:
- Use a
profilewhen you want to switch one tool’s account. - Use a
contextwhen you want to switch one whole multi-tool work mode.
aisw context create
Section titled “aisw context create”aisw context create <name> [--claude <profile>] [--codex <profile>] [--gemini <profile>]Create a saved context. At least one tool mapping is required.
aisw context create acme --claude acme-claude --codex acme-codexaisw context list
Section titled “aisw context list”aisw context list [--search TEXT] [--json]List saved contexts.
| Flag | Effect |
|---|---|
--search TEXT | Filter by context name or mapped profile name |
--json | Output as JSON |
aisw context listaisw context list --search acmeaisw context list --jsonaisw context use
Section titled “aisw context use”aisw context use <name> [--state-mode isolated|shared] [--emit-env]Activate every mapped tool in a saved context as one transaction.
| Flag | Effect |
|---|---|
--state-mode isolated | Set CLAUDE_CONFIG_DIR and CODEX_HOME to profile directories (default) |
--state-mode shared | Unset CLAUDE_CONFIG_DIR and CODEX_HOME for Claude and Codex |
--emit-env | Print shell export/unset lines to stdout instead of writing them to the session |
Notes:
- Default state mode is
isolated. --state-mode sharedapplies only to Claude Code and Codex CLI.- Activation is transactional across mapped tools. If one tool write fails, prior live state is restored.
- With the shell hook active,
aisw context useapplies emitted env vars to the current shell the same wayaisw usedoes.
aisw context use acmeaisw context use acme --state-mode sharedeval "$(aisw context use acme --emit-env)"aisw context set
Section titled “aisw context set”aisw context set <name> [--claude <profile>] [--codex <profile>] [--gemini <profile>]Update one or more mappings without disturbing the others.
aisw context set acme --gemini acme-geminiaisw context unset
Section titled “aisw context unset”aisw context unset <name> [--claude] [--codex] [--gemini]Remove one or more mappings from a context. The command fails if it would leave the context empty.
aisw context unset acme --codexaisw context remove
Section titled “aisw context remove”aisw context remove <name> [--yes]Delete a saved context. This does not change live credentials or active per-tool profiles.
aisw context remove acme --yesaisw context rename
Section titled “aisw context rename”aisw context rename <old> <new>Rename a saved context. This does not change live credentials or active per-tool profiles.
aisw context rename acme client-acmeaisw workspace
Section titled “aisw workspace”Bind repos, directories, and git remotes to expected aisw contexts. The shell hook checks these bindings before launching claude, codex, or gemini, warning or blocking when the active context does not match.
See Workspace guardrails for a full explanation of the feature, setup steps, and common patterns.
aisw workspace bind
Section titled “aisw workspace bind”aisw workspace bind [PATH] --context <name>aisw workspace bind --git-remote <PATTERN> --context <name>aisw workspace bind --default --context <name>Create or update a workspace binding. The context must already exist.
| Flag | Effect |
|---|---|
PATH | Path to bind. Defaults to .. Inside a git repo, writes .git/info/aisw.json. Outside a repo, writes a path rule to ~/.aisw/workspaces.json. |
--context NAME | Expected context name for this location |
--git-remote PATTERN | Bind by git remote URL pattern. Supports * wildcards. |
--default | Set the fallback context for locations with no more specific rule. |
aisw workspace bind . --context client-acmeaisw workspace bind --git-remote "github.com/acme/*" --context client-acmeaisw workspace bind ~/clients --context client-acmeaisw workspace bind --default --context personalaisw workspace status
Section titled “aisw workspace status”aisw workspace status [--json]Show the resolved binding for the current directory: matched rule, expected context, active context/profiles, status, and recommended action.
aisw workspace statusaisw workspace status --jsonaisw workspace doctor
Section titled “aisw workspace doctor”aisw workspace doctor [--json]Validate all workspace rules. Checks that referenced context names still exist and reports the resolved state for the current directory.
aisw workspace doctoraisw workspace doctor --jsonaisw workspace guard
Section titled “aisw workspace guard”aisw workspace guard --mode warn|strictSet the default guard mode, saved to ~/.aisw/workspaces.json.
| Mode | Effect |
|---|---|
warn | Print a warning before launching an agent. The launch proceeds. (Default) |
strict | Block the agent launch entirely and print a remediation command. |
aisw workspace guard --mode warnaisw workspace guard --mode strictaisw list
Section titled “aisw list”aisw list [tool] [--tool <tool>] [--search TEXT] [--sort name|recent] [--active-only] [--json]Show all stored profiles. Pass a tool name as a positional argument or use --tool to filter to one tool.
| Flag | Effect |
|---|---|
[tool] or --tool | Filter to one tool: claude, codex, or gemini |
--search TEXT | Filter by profile name or label (substring match) |
--sort name|recent | Sort by profile name or by most recently used |
--active-only | Show only tools that have an active profile |
--json | Output as JSON |
aisw listaisw list claudeaisw list --tool codex --search workaisw list --sort recentaisw list --active-only --jsonaisw status
Section titled “aisw status”aisw status [--tool <tool>] [--search TEXT] [--sort name|recent] [--active-only] [--context] [--json]Show per-tool state: installed binary, active profile, credential backend, live-match status, and token expiry warnings.
| Flag | Effect |
|---|---|
--tool | Filter to one tool: claude, codex, or gemini |
--search TEXT | Filter by tool, profile, auth type, or backend text |
--sort name|recent | Sort rows by name or most recently used |
--active-only | Show only tools that have an active profile |
--context | Add derived context matching information |
--json | Output as JSON |
Notes:
- “Live match” indicates whether the tool’s current live credentials match the
aisw-recorded active profile. - Token expiry warnings appear when an OAuth token is expired or expires within 24 hours.
--contextdoes not change the shape of plainstatus --jsonoutput.status --context --jsonwraps the tool array in a{ "tools": [...], "context": ... }object.
aisw statusaisw status --contextaisw status --tool claudeaisw status --active-onlyaisw status --search work --jsonaisw status --context --jsonaisw remove
Section titled “aisw remove”aisw remove <tool> <profile> [--yes] [--force]Delete a stored profile. A backup is created before deletion.
| Flag | Effect |
|---|---|
--yes | Skip confirmation prompt |
--force | Allow removing the currently active profile |
aisw remove codex old --yesaisw remove claude work --force --yesaisw rename
Section titled “aisw rename”aisw rename <tool> <old> <new>Rename a profile. The profile directory and all config references are updated atomically.
aisw rename claude default workaisw backup list
Section titled “aisw backup list”aisw backup list [--tool <tool>] [--search TEXT] [--sort name|recent] [--active-only] [--json]List available backups with timestamps and associated profile names.
| Flag | Effect |
|---|---|
--tool | Filter to one tool: claude, codex, or gemini |
--search TEXT | Filter by backup id, tool, or profile name |
--sort name|recent | Sort by name or by most recently created |
--active-only | Show only backups for currently active profiles |
--json | Output as JSON |
aisw backup listaisw backup list --tool claudeaisw backup list --search work --jsonaisw backup list --sort recentaisw backup restore
Section titled “aisw backup restore”aisw backup restore <backup_id> [--yes]Restore profile files from a backup. Does not activate the profile; run aisw use after restore.
| Flag | Effect |
|---|---|
--yes | Skip confirmation prompt |
aisw backup restore 20260325T114502Z-claude-work --yesaisw use claude workaisw uninstall
Section titled “aisw uninstall”aisw uninstall [--dry-run] [--remove-data] [--yes]Remove aisw-managed shell hook blocks from shell config files.
| Flag | Effect |
|---|---|
--dry-run | Preview what would be changed without making any changes |
--remove-data | Also remove ~/.aisw/ after hook cleanup |
--yes | Skip confirmation prompt |
Notes:
- Does not remove the
aiswbinary. - Does not remove tool config directories (
~/.claude/,~/.codex/,~/.gemini/). - Only removes
# aiswhook blocks thataisw initoraisw shell-hookadded.
aisw uninstall --dry-runaisw uninstall --yesaisw uninstall --remove-data --yesaisw shell-hook
Section titled “aisw shell-hook”aisw shell-hook <bash|zsh|fish|pwsh>Print the shell hook code for the given shell. Redirect into your shell config file:
aisw shell-hook zsh >> ~/.zshrcaisw shell-hook bash >> ~/.bashrcaisw shell-hook fish >> ~/.config/fish/conf.d/aisw.fishaisw shell-hook pwsh >> $PROFILEThe hook does two things:
- Wraps
aisw useandaisw context useso environment variable exports are applied into the current shell session automatically. - Wraps
claude,codex, andgeminito runaisw workspace checkbefore each launch, enforcing any configured workspace guardrails.
See Shell integration for details and completion setup.
aisw doctor
Section titled “aisw doctor”aisw doctor [--json]Check install and environment health: binary locations, ~/.aisw/ permissions, shell hook status, and keyring availability.
aisw doctoraisw doctor --jsonAutomation reference
Section titled “Automation reference”For CI patterns, JSON output contracts, and non-interactive usage, see Automation and scripting.