ai command is the primary entry point for Andi AIRun. It runs AI prompts as scripts, provides executable markdown with shebang support, and enables cross-cloud provider switching.
Syntax
Usage Modes
Interactive Mode
Runai with no arguments to start an interactive session:
Script File Mode
Execute a markdown file as a prompt:Stdin Mode
Pipe content directly toai:
--stdin-position append to place it after.
Common Options
These are the AI Runner-specific options. See individual reference pages for detailed documentation:Provider Flags
Switch between Claude subscriptions and cloud providers
Model Flags
Select model tiers or specific model IDs
Permission Flags
Control file access and command execution permissions
Output Flags
Configure output format and streaming behavior
Flag Precedence
When the same configuration is specified in multiple places, AI Runner uses this precedence order (highest to lowest):- CLI flags -
ai --aws --opus file.md - Shebang flags -
#!/usr/bin/env -S ai --aws --opus - Saved defaults -
ai --aws --opus --set-default - Auto-detection - Current Claude subscription
Real Examples
Basic Script Execution
Provider Switching
Unix Pipeline Automation
Agent Teams
Persistent Defaults
Script Variables
Declare variables with defaults in YAML front-matter:Other Commands
Update AI Runner to the latest version:Pulls the latest version from the configured GitHub repository and re-runs the setup script.
Save current provider+model as persistent default:
Remove saved defaults:
Resume the most recent conversation:Picks up your previous conversation exactly where you left off. Works across provider switches - useful when you hit rate limits.
Enable agent teams (interactive mode only):Enables Claude Code’s agent teams feature. Multiple AI agents collaborate on tasks with one lead coordinator.Short form:
--teamsSelect the underlying AI tool:Currently only Claude Code is supported. The
--cc flag is a shortcut for --tool cc.Show version information:
Show help message:
Session Behavior
AI Runner uses session-scoped configuration:- On exit, your original Claude settings are automatically restored
- Plain
claudein another terminal is completely unaffected - No global configuration is changed
- Each invocation starts fresh (nested scripts don’t inherit parent env vars)
Passthrough Flags
Any flag not recognized by AI Runner is forwarded to Claude Code unchanged:Exit Codes
ai exits with the same code as the underlying tool (Claude Code). A non-zero exit means the tool reported an error.