Skip to main content
Andi AIRun makes markdown files executable using Unix shebang syntax. Add a shebang line to any markdown file, make it executable, and run it directly as a command.

How Shebang Scripts Work

A shebang (#!) at the start of a file tells the operating system which interpreter to use. AIRun uses #!/usr/bin/env ai to run markdown files as AI prompts:
Make it executable and run:
The AI reads the prompt from the file and executes it in your current directory, just like running ai task.md.

The -S Flag Requirement

Standard env only accepts one argument. If you want to pass flags to ai in your shebang, you must use env -S to split the string into multiple arguments:
Always use #!/usr/bin/env -S ai when your shebang includes flags like --aws, --skip, or --live.

Shebang Examples from the Repository

Basic Hello World

From examples/hello.md:
The --haiku flag selects a fast, cost-effective model for simple tasks.

Code Analysis

From examples/analyze-code.md:
  • --sonnet: Balanced model for code analysis
  • --skip: Shortcut for --dangerously-skip-permissions — allows the AI to read files without prompting

Live Streaming Report

From examples/live-report.md:
The --live flag streams output in real-time as the AI works, showing progress incrementally.

Test Automation

From examples/run-tests.md:

Stdin Processing

From examples/analyze-stdin.md:
Run with piped input:

Script with Variables

From examples/summarize-topic.md:
Override variables from the command line:

Permission Modes for Automation

Read-only scripts (default) can analyze code but won’t modify anything:
Automation scripts that need to write files or run commands require permission flags:
--skip and --bypass give the AI full system access. Only run trusted scripts in trusted directories. For granular control, use --allowedTools to specify exactly which operations are allowed.

Flag Precedence

When you run a script, flags are resolved in this order (highest priority first): Example precedence in action: Given a script with this shebang:
If you’ve also run ai --vertex --set-default:
CLI flags always override shebang flags, and shebang flags always override saved defaults. This lets you keep scripts with sensible defaults while overriding them when needed.

Passthrough Flags

AIRun handles its own flags (--aws, --opus, --live, --skip, etc.) and passes unrecognized flags directly to Claude Code:
  • --skip: AIRun flag (permission mode)
  • --chrome: Claude Code flag (browser automation)
  • --max-turns 10: Claude Code flag (limit iterations)

Running Scripts

There are three ways to run executable markdown:
Uses shebang flags exactly as written.

Combining with Other Features

Shebang scripts work seamlessly with other AIRun features: Provider switching:
Live streaming:
Agent teams:
Custom models:

Unix Pipes

Chain scripts together and process data streams

Provider Switching

Switch between cloud providers and models