Skip to main content

Overview

By default, AI scripts wait for the full response before printing anything. The --live flag enables real-time streaming, showing progress as the AI works. This is essential for long-running scripts where you want immediate feedback.

How --live Works

Turn-Level Streaming

--live streams at turn granularity — each time Claude writes a text response between tool calls, that text appears immediately. This means your prompt needs to tell Claude to narrate its progress, otherwise it may silently use tools and only output text at the end.

Example: With Progress Narration

explore.md
Run it:
Output streams incrementally:

Example: Without Progress Narration

explore-silent.md
Run it:
No intermediate output (Claude works silently):
Both produce the same final result, but only the first streams progress. The key is phrases like:
  • “print as you go”
  • “step by step”
  • “describe what you find”
  • “narrate your progress”
  • “summarize after each step”
These prompt Claude to write text between tool calls, giving --live something to stream.

Output Redirection

When stdout is redirected to a file, --live automatically separates narration from content:
Console (stderr):
File (stdout):

How It Works

  1. Intermediate turns (narration, progress) stream to stderr in real-time
  2. The last turn is split at the first content marker:
    • YAML frontmatter ---
    • Markdown heading #
  3. Preamble text before the marker goes to stderr
  4. Content from the marker onward goes to the file (stdout)
  5. Summary message “Done (N lines written)” appears on stderr when complete
This means you can watch progress on the console while capturing clean output in a file.

Example: Generate Documentation

generate-docs.md
Run it:
You see progress on console:
While ARCHITECTURE.md contains only the clean report.

When to Use --live

Use --live for:
  • Long-running scripts (>30 seconds)
  • Browser automation with Chrome
  • Multi-step workflows where you want to see each step
  • CI/CD jobs where you need progress visibility
  • Debugging to see what the AI is doing in real-time
Skip --live for:
  • Quick read-only queries (under 10 seconds)
  • Piped output where you only care about the final result
  • Silent automation where you want minimal output

Piped Content with Live Streaming

You can combine stdin piping with --live:
The AI reads from stdin and streams progress to stdout:

Browser Automation with Chrome

--live pairs perfectly with --chrome (a Claude Code flag) for browser automation where steps take time and you need real-time progress:
test-login.md
Run it:
Output streams in real-time:
Without --live, you’d see nothing until the entire test completes (which could be minutes).

Using --quiet to Suppress Live Output

Override --live with --quiet when you want silent operation:
This is useful in CI/CD where you only want the final result:
  • No progress narration
  • No [AI Runner] status messages
  • Only the final output content

Real-World Examples

Example 1: Repository Exploration

explore-repo.md
Usage:

Example 2: Test Suite Runner

run-tests.md
Usage:

Example 3: Data Analysis Pipeline

analyze-pipeline.md
Usage:

Example 4: Security Scan

security-scan.md
Usage:

Requirements

--live requires jq to be installed:

Troubleshooting

No Intermediate Output

Problem: --live flag is set but nothing streams until the end Solution: Add progress narration to your prompt:

Output Goes to Wrong Stream

Problem: Progress text ends up in the output file Solution: Ensure your final output starts with a content marker (# heading or --- frontmatter). The system splits at the first marker.

jq Not Found Error

Problem: [AI Runner] Error: jq not found Solution: Install jq:

Best Practices

Do:
  • Add --live to any script that takes >30 seconds
  • Prompt the AI to narrate progress (“print as you go”)
  • Start final output with # heading for clean file redirection
  • Use --live with --chrome for browser automation
  • Override with --quiet in CI when you want silent operation
Don’t:
  • Rely on --live for scripts that work silently (add narration prompts)
  • Forget to install jq before using --live
  • Mix --live narration with structured output (use separate turns)

Next Steps

CI/CD Automation

Use live output in continuous integration pipelines

Writing Scripts

Learn script basics and common patterns

Script Variables

Make scripts reusable with CLI overrides

Permissions

Control what scripts can do