Chain AI scripts together with stdin/stdout for automation pipelines
Andi AIRun scripts follow Unix philosophy: read from stdin, write to stdout, chain together in pipelines. This enables powerful automation workflows where AI scripts act as composable filters.
When stdout is redirected, you get only the AI’s response — no status messages, no prompts. Status information goes to stderr so you can still see progress:
Copy
$ ./analyze.md > results.txt[AI Runner] Using: Claude Code + Claude Pro[AI Runner] Model: claude-sonnet-4-6[Processing...][AI Runner] Done
This clean separation between content (stdout) and diagnostics (stderr) makes AIRun scripts perfect for automation and CI/CD pipelines.
Chained scripts run with process isolation — environment variables are cleared between nested calls, so each script starts fresh. This prevents state leakage and makes pipelines more predictable.
Combine --live with pipes to see real-time progress:
Copy
cat large-dataset.json | ai --live --skip analyze.md
Console output (stderr):
Copy
[AI Runner] Using: Claude Code + Claude Pro[AI Runner] Model: claude-sonnet-4-6I'm analyzing the dataset structure...Found 1,247 records spanning 3 categories...Detecting outliers in the price field...Generating summary statistics...
File output (stdout):
Copy
cat data.json | ./analyze.md --live > report.md
Narration streams to console (stderr), final report goes to file (stdout).
# Run a script directly from a URLcurl -fsSL https://example.com/analyze.md | ai# Override provider from shebangcurl -fsSL https://example.com/script.md | ai --aws --opus# Pipe data through a remote scriptcat data.json | curl -fsSL https://example.com/process.md | ai
Only pipe trusted remote scripts, especially when using permission flags like --skip or --bypass. Remote scripts have the same access as local scripts.
Use --cc --skip to give the AI tool access in a top-level script, then call simple prompt-mode scripts from within:
Copy
#!/usr/bin/env -S ai --cc --skip --liveRead all test files in test/ directory.For each test file, describe what it tests and verify the assertions are comprehensive.Print findings as you go.
The dispatcher has tool access and can:
Read files
Run commands
Chain to other scripts
Child scripts should be simple prompt-mode (no --cc) to avoid nested tool complexity.
See the Scripting Guide for more details on the dispatcher pattern and composable script design.