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
Example: Without Progress Narration
explore-silent.md
- “print as you go”
- “step by step”
- “describe what you find”
- “narrate your progress”
- “summarize after each step”
--live something to stream.
Output Redirection
When stdout is redirected to a file,--live automatically separates narration from content:
How It Works
- Intermediate turns (narration, progress) stream to stderr in real-time
- The last turn is split at the first content marker:
- YAML frontmatter
--- - Markdown heading
#
- YAML frontmatter
- Preamble text before the marker goes to stderr
- Content from the marker onward goes to the file (stdout)
- Summary message “Done (N lines written)” appears on stderr when complete
Example: Generate Documentation
generate-docs.md
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
--live for:
Piped Content with Live Streaming
You can combine stdin piping with--live:
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
--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:
- No progress narration
- No [AI Runner] status messages
- Only the final output content
Real-World Examples
Example 1: Repository Exploration
explore-repo.md
Example 2: Test Suite Runner
run-tests.md
Example 3: Data Analysis Pipeline
analyze-pipeline.md
Example 4: Security Scan
security-scan.md
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
--liveto 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
--livewith--chromefor browser automation - Override with
--quietin CI when you want silent operation