`tail -f | claude -p` hangs forever — official docs example doesn't work (stdin waits for EOF indefinitely)
Description
The official documentation includes this example:
tail -f app.log | claude -p "Slack me if you see any anomalies"
However, this does not work. claude -p waits for EOF on stdin before processing, but tail -f never sends EOF, so the command hangs indefinitely — even after all log lines have been written.
Steps to Reproduce
- Create a log file and start appending lines to it:
``bash``
# Terminal 1: simulate log output
for i in $(seq 1 100); do echo "$(date -Iseconds) INFO line $i" >> app.log; sleep 0.5; done
- In another terminal, pipe with
tail -f:
``bash``
# Terminal 2: this hangs forever
tail -f app.log | claude -p "Summarize any errors in this log"
- Wait — even after Terminal 1 finishes, Terminal 2 never produces output.
- Using
timeoutto force-killtail -falso doesn't help:
``bash``
timeout 180s tail -f app.log | claude -p "Summarize any errors"
# exit code 143 (SIGTERM), no output from claude
Expected Behavior
claude -p should be able to process streaming stdin incrementally, or at minimum provide a mechanism (e.g., --stdin-timeout, --stdin-delimiter) to start processing after a period of inactivity or upon receiving a specific marker.
Actual Behavior
claude -p blocks on stdin read until EOF. Since tail -f never sends EOF, the pipeline hangs forever with no output.
Workaround
Use commands that send EOF after completing output:
# Works — cat sends EOF after reading the file
cat app.log | claude -p "Summarize any errors in this log"
# Works — gh sends EOF after output
gh run list -L 10 | claude -p "Any failed workflows?"
Environment
- Claude Code v2.1.76
- macOS Sequoia / Ubuntu 24.04 LTS
- Tested with Opus 4.6
Additional Context
The gap between the documented example and actual behavior is confusing for users trying to adopt pipe mode for log monitoring. Even if full streaming support is complex, updating the docs to note this limitation or providing a --stdin-timeout flag would significantly improve the experience.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗