Working with Autohand
Pipe Mode
Pipe Mode enables Unix-style composable workflows. Feed data into Autohand via stdin and receive structured JSON output on stdout for scripting and automation.
Overview
Pipe Mode activates automatically when Autohand detects piped input (non-TTY stdin). It reads the entire stdin stream, processes it with the LLM, and outputs structured results to stdout.
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" | jq '.response'
I/O behavior
| Stream | Behavior |
|---|---|
| stdin | Piped input is read in full and included as context in the prompt |
| stdout | Structured JSON output (NDJSON format, one object per line) |
| stderr | Progress messages, errors, and debug output |
Because stdout contains only structured data, you can safely redirect or pipe it without capturing progress noise.
NDJSON output
Output uses Newline-Delimited JSON (NDJSON) format. Each line is a valid JSON object:
{"type":"message","content":"The authentication module has..."}
{"type":"tool_use","tool":"read_file","args":{"path":"src/auth.ts"}}
{"type":"tool_result","tool":"read_file","output":"..."}
{"type":"message","content":"I found 3 potential issues..."}
Common message types:
message— Agent text responsestool_use— Tool invocations with argumentstool_result— Tool execution resultserror— Error messagesstatus— Session status updates
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" | \
jq -r 'select(.type=="message") | .content'
Batch file processing
# Add type annotations to all TypeScript files
for f in src/**/*.ts; do
cat "$f" | autohand -p "add missing type annotations" \
--output "$f"
done
CI integration
# Generate PR description from commits
git log main..HEAD --oneline | \
autohand -p "write a PR description for these commits" | \
jq -r 'select(.type=="message") | .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
Tips
- Use
jqto filter NDJSON output by message type - Combine with
--modelto use faster models for batch tasks - Use
--dry-runin pipe mode to preview what the agent would do - Pipe mode respects
--restrictedand--unrestrictedflags - Set
--timeoutto prevent runaway executions in CI
Tip: Pipe mode is perfect for CI/CD pipelines. Use --restricted to ensure the agent can only read and analyze without modifying your codebase.