Pipe command output into Claude
cli flags & headless
// what it does
Print mode reads stdin, so you can pipe a log, diff, or file into claude -p and redirect the answer like any Unix tool. Piping the diff means Claude needs no Bash permission to fetch it. This is the pattern behind using Claude as a linter in a package.json script or explaining a build error inline.
// shell
$ cat build-error.txt | claude -p "explain the root cause of this error"$ git diff main | claude -p "review these changes for issues"$ tail -200 app.log | claude -p "summarize anomalies" > summary.txt// gotcha
As of v2.1.128 piped stdin is capped at 10MB; exceed it and Claude Code exits with a non-zero status and a clear error. For larger inputs, write the content to a file and reference the path in your prompt instead of piping.