Overview
Andi AIRun scripts are executable markdown files that can read code, run commands, write files, and automate complex workflows. Scripts use a shebang to specify the AI model and permissions, then contain natural language instructions that the AI executes.Basic Script Structure
A minimal script looks like this:The -S Flag (Essential for Shebangs)
Standard env only passes a single argument. To pass flags to ai in a shebang, you need env -S (split string):
-S tells env to split the string into separate arguments. Use it whenever your shebang has flags.
Permission Modes
By default, scripts run with limited permissions — they can read code but won’t write files or run commands without approval. For scripts that need to take actions, set a permission mode.Available Modes
| Mode | Shebang Flag | Shortcut | Behavior |
|---|---|---|---|
| Default | (none) | — | Read-only — can analyze code but won’t modify anything |
| Bypass Mode | --permission-mode bypassPermissions | --bypass | Full access via permission mode system — composable with other settings |
| Skip Permissions | --dangerously-skip-permissions | --skip | Nuclear — bypasses ALL permission checks, overrides --permission-mode |
| Allowed Tools | --allowedTools 'Bash(npm test)' 'Write' | — | Granular — only specified tools allowed |
--bypass and --skip both result in no permission prompts, but --skip is more aggressive — it overrides any --permission-mode flag. Use --bypass when you may want to compose with other permission settings in the future.Examples
Read-only script (no permission flags needed):#!/usr/bin/env -S ai --bypass
Granular permissions (only allow specific tools):
Common Patterns
Run Tests and Report Results
Generate Documentation
Pipe Data In, Get Results Out
Read-only analysis of piped input doesn’t need permission flags.
Code Review with Provider Selection
Composable Script Chains
Chain scripts together like Unix programs:--cc). Only the top-level dispatcher should have tool access.
Security Warnings
Quick Reference
| I want to… | Shebang | |--------------|---------|| | Analyze code (read-only) |#!/usr/bin/env ai |
| Use a specific provider | #!/usr/bin/env -S ai --aws |
| Run commands and write files | #!/usr/bin/env -S ai --skip |
| Restrict to specific tools | #!/usr/bin/env -S ai --allowedTools 'Bash(npm test)' 'Read' |
| Full automation with provider | #!/usr/bin/env -S ai --aws --opus --skip |