Skip to main content
Pipe data directly into AI scripts for analysis and transformation. This example shows how AIRun handles stdin like any Unix command.

The Script

From examples/analyze-stdin.md. Uses Haiku for fast, cheap data analysis.

How It Works

Stdin Support

AIRun scripts accept stdin like any Unix command:
The piped data is automatically prepended to your prompt:

Why Use Haiku?

This script uses --haiku because:
  • Fast - Data analysis doesn’t need deep reasoning
  • Cheap - Processing lots of files costs less
  • Sufficient - Haiku can summarize and identify patterns
Model selection for data tasks:

Running the Script

Pipe from File

Pipe from Command

Pipe from API

Save Output

Real-World Usage

Process JSON Data

Input (metrics.json):
Output:

Analyze CSV Files

Input (sales.csv):
Output:

Process Log Files

With a custom prompt:

Analyze Git History

Custom prompt:

Chaining Scripts Together

Pipe output from one AI script to another:
extract-data.md:
analyze-stdin.md:
format-report.md:

Process Multiple Files

Controlling Stdin Position

By default, piped data is prepended to your prompt. You can control this:
Example use case for append:
Result:

Data Processing Patterns

Transform JSON to CSV

Filter and Aggregate

Detect Anomalies

Enrich Data

Stdin vs File Arguments

When to Use Stdin

Use stdin when:
  • Piping from commands (git log | ./script.md)
  • Chaining scripts together
  • Processing streams
  • Keeping scripts generic (don’t hardcode filenames)

When to Use File Arguments

Use file arguments when:
  • The script needs to read multiple files
  • The script needs to know the filename
  • You want to be explicit about what’s being processed
Example with file argument:
Vs stdin approach:

Combining Stdin with Other Flags

Stdin + Live Output

Stdin + Provider Override

Stdin + Variables

CI/CD Examples

GitHub Actions

Process Database Dumps

Troubleshooting

No Stdin Detected

Problem: Script doesn’t see piped data. Solution: Make sure you’re actually piping:

Stdin Data Not in Prompt

Problem: AI says “no data provided.” Solution: Check that stdin isn’t empty:

Binary Data Issues

Problem: Piping binary files causes errors. Solution: AIRun expects text data. Convert binary first:

Next Steps

Data Processing

Complete data pipeline patterns

Chaining Scripts

Build multi-stage pipelines

CI/CD Integration

Automate data analysis in CI/CD

Live Output

Stream processing for large datasets