Turn markdown files into AI-powered scripts with shebang support
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.
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:
Copy
#!/usr/bin/env aiAnalyze this codebase and summarize the architecture.
Make it executable and run:
Copy
chmod +x task.md./task.md
The AI reads the prompt from the file and executes it in your current directory, just like running ai task.md.
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:
Copy
#!/usr/bin/env aiSummarize this project.
Always use #!/usr/bin/env -S ai when your shebang includes flags like --aws, --skip, or --live.
#!/usr/bin/env -S ai --sonnet --skipSummarize the architecture of this codebase. List the main entry points,key modules, and how data flows through the system.
--sonnet: Balanced model for code analysis
--skip: Shortcut for --dangerously-skip-permissions — allows the AI to read files without prompting
#!/usr/bin/env -S ai --sonnet --skip --liveExplore this repository and write a short summary of what it does,its key features, and how to get started. Print your findings as you go.Finally, generate a concise report in markdown format.
The --live flag streams output in real-time as the AI works, showing progress incrementally.
#!/usr/bin/env -S ai --sonnet --skipRun the test suite for this project. Report which tests passed and whichfailed. If any tests fail, explain the root cause.
#!/usr/bin/env -S ai --haiku---vars: topic: "machine learning" style: casual length: short---Write a {{length}} summary of {{topic}} in a {{style}} tone.
Read-only scripts (default) can analyze code but won’t modify anything:
Copy
#!/usr/bin/env aiAnalyze the test coverage in this codebase.
Automation scripts that need to write files or run commands require permission flags:
Copy
#!/usr/bin/env -S ai --skipRun the test suite and fix any failing tests.
--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.
ai script.md # Still uses Ollama (shebang beats saved default)ai --resume # Uses Vertex (no script, so default applies)
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.