Automation and Scripting
Use this page when you want to run aisw safely from scripts, CI, or shell automation.
Prompt behavior
Section titled “Prompt behavior”aisw does not currently provide a global --non-interactive or --quiet flag.
Current automation-safe usage:
- Use
--yesfor commands that otherwise prompt for confirmation:aisw init --yesaisw remove ... --yesaisw backup restore ... --yes
- Use
aisw add ... --api-key ...when you need non-interactive profile creation. Without--api-key,aisw adduses an interactive auth flow. - Use
--jsonfor machine-readable inventory and status output:aisw list --jsonaisw status --jsonaisw backup list --json
aisw use --emit-envandaisw shell-hookintentionally print raw shell output for scripting and shell integration.
If you need fully non-interactive automation today, prefer API-key-based add, explicit --yes flags, and the JSON output modes above.
Output contract
Section titled “Output contract”aisw uses this output model:
- Human-oriented command results and status output go to stdout.
- Errors are printed to stderr and return a non-zero exit code.
- Interactive prompts appear during prompt-driven flows such as
init,remove, andbackup restorewhen you do not pass--yes. --jsonmodes are the supported machine-readable interface for scripting.aisw use --emit-envandaisw shell-hookintentionally emit raw shell text to stdout.
Supported JSON interfaces:
aisw list --jsonaisw status --jsonaisw backup list --json
JSON output is intended to remain stable for automation within a released major version. Human-readable stdout should be treated as presentation output and may change between releases.
Practical patterns
Section titled “Practical patterns”Create a profile without prompts
Section titled “Create a profile without prompts”aisw add claude work --api-key "$ANTHROPIC_API_KEY"Remove a profile non-interactively
Section titled “Remove a profile non-interactively”aisw remove claude work --yesRead profile inventory from a script
Section titled “Read profile inventory from a script”aisw list --jsonExport shell variables for the selected profile
Section titled “Export shell variables for the selected profile”eval "$(aisw use codex work --emit-env)"Recommended references
Section titled “Recommended references”- Commands for the full command and flag reference
- Shell Integration for hook and completion setup
- Quickstart for the common interactive workflow