Stdin/Stdout Handling
Executable markdown scripts have proper Unix stream semantics:- Stdin support: Pipe data directly into scripts
- Clean stdout: AI responses go to stdout when redirected
- Diagnostic stderr: Status messages and progress go to stderr
- Chainable: Connect scripts in pipelines like standard Unix tools
Basic Piping
Pipe data into a script:Output Redirection
Redirect AI output to a file:This clean separation between content (stdout) and diagnostics (stderr) makes AIRun scripts perfect for automation and CI/CD pipelines.
The stdin-position Flag
By default, piped input is prepended to the prompt (added before the script content). Use--stdin-position to control where stdin appears:
Chaining Scripts Together
Chain multiple AI scripts in a pipeline:- Reads from stdin (previous script’s output)
- Processes with AI
- Writes result to stdout (next script’s input)
test/automation/):
Real Examples from the Repository
Analyze Piped Data
Fromexamples/analyze-stdin.md:
Generate and Process
Fromtest/automation/generate-report.md and format-output.md:
Git Workflow Integration
Log Analysis
Live Streaming with Pipes
Combine--live with pipes to see real-time progress:
Output Redirection with Live Mode
When stdout is redirected with--live, AIRun intelligently splits the output:
- Intermediate turns (narration) → stderr
- Final turn preamble (before first
---or#) → stderr - Final turn content (from first marker onward) → stdout
This behavior makes
--live ideal for long-running scripts where you want to see progress but only capture the final result in a file.Shell Script Integration
Use AIRun scripts in traditional shell scripts:CI/CD Pipeline Integration
GitHub Actions example:Running Scripts from the Web
AIRun supportsinstallmd.org style execution:
Composable Design Patterns
Single-Purpose Scripts
Follow Unix philosophy — each script does one thing well:The Dispatcher Pattern
Use--cc --skip to give the AI tool access in a top-level script, then call simple prompt-mode scripts from within:
- Read files
- Run commands
- Chain to other scripts
--cc) to avoid nested tool complexity.
stdin Position Examples
Instructions + Data (append)
Data + Question (prepend, default)
Process Isolation
When chaining scripts, AIRun clears inherited environment variables between nested calls:- Gets a fresh environment
- No leaked state from previous scripts
- Predictable, reproducible behavior
Executable Markdown
Learn about shebang support and script structure
Scripting Guide
Complete guide to writing AI automation scripts