Overview

Pipe Mode activates automatically when Autohand detects piped input (non-TTY stdin). It reads the entire stdin stream, adds it to the prompt as context, runs the task, and exits.

This makes Autohand composable with other Unix tools:

# Pipe a file for analysis
cat src/auth.ts | autohand -p "find bugs in this code"

# Chain with other tools
git diff HEAD~1 | autohand -p "summarize these changes" --json local | jq -r '.content'

I/O behavior

StreamBehavior
stdinPiped input is read in full and included as context in the prompt
stdoutHuman-readable text by default. With --json local, one final JSON object. With --output-format stream-json or --json stream, one JSON event per line
stderrProgress messages, errors, and debug output when a JSON format is selected

When you select a JSON format, stdout contains only JSON, so you can redirect or pipe it without capturing progress output.

NDJSON output

With --output-format stream-json, output uses Newline-Delimited JSON (NDJSON). Each line is a valid JSON object:

{"type":"thinking","thought":"The user wants me to review src/auth.ts..."}
{"type":"result","content":"I found 3 potential issues..."}

Common event types:

  • thinking: the agent's reasoning, in thought
  • tool_start and tool_end: tool calls and their results
  • file_modified: a file the agent created, changed, or deleted
  • result: the agent's response, in content
  • error: an error, in message

Use --json local when you only need the final result or error object.

Usage examples

Code review pipeline

# Review staged changes
git diff --staged | autohand -p "review this diff for bugs"

# Review and extract just the response text
git diff --staged | autohand -p "review this diff" --json local | \
  jq -r '.content'

Batch file processing

# Add type annotations to each TypeScript file
for f in src/**/*.ts; do
  autohand -p "add missing type annotations to $f" --yes
done

CI integration

# Generate PR description from commits
git log main..HEAD --oneline | \
  autohand -p "write a PR description for these commits" --json local | \
  jq -r '.content' > pr-body.md

Combining with flags

# Use a specific model and generate a patch
cat buggy.ts | autohand -p "fix the bug" \
  --model anthropic/claude-4-sonnet \
  --patch --output fix.patch

--output <file> applies only with --patch.

Tips

  • Use jq to read --json local output or to filter stream events by type
  • Combine with --model to use faster models for batch tasks
  • Use --dry-run in pipe mode to preview what the agent would do
  • Pipe mode respects --restricted and --unrestricted flags
  • Set --max-duration, --max-requests, or --max-tokens to stop runaway runs in CI

Tip: Pipe mode is perfect for CI/CD pipelines. Use --restricted to deny dangerous operations so the agent can read and analyze without modifying your codebase.