Pipe Files and Command Output Directly into Claude Code via stdin
Instead of copying error logs or command output into your prompt, just pipe it in. Claude Code reads stdin and uses it as context alongside whatever you ask.
cat error.log | claude -p "what's causing these failures?"
This works with any command that produces output. Pipe a git diff for a quick review:
git diff | claude -p "review this diff for issues"
Or feed in a config file you want explained:
cat nginx.conf | claude -p "explain what this config does"
The real power comes from chaining Unix tools together before handing off to Claude:
# Only show Claude the relevant log lines
grep "ERROR" app.log | tail -50 | claude -p "categorize these errors"
# Feed in test output
npm test 2>&1 | claude -p "fix the failing tests"
# Pipe in a specific function for review
sed -n '45,90p' src/auth.ts | claude -p "find security issues in this code"
A few practical patterns:
- Debug crashes:
journalctl -u myapp --since "1 hour ago" | claude -p "why is this service crashing?" - Understand configs:
kubectl get deployment myapp -o yaml | claude -p "explain this deployment" - Triage alerts:
curl -s monitoring-api/alerts | claude -p "which of these need immediate attention?"
The -p flag is key here — it makes Claude run non-interactively, process the piped input with your prompt, print the answer, and exit. Perfect for scripting.
If you can cat it or curl it, you can pipe it to Claude.
via Claude Code
Log in to leave a comment.
When typing feels slow — describing a complex bug, explaining architecture, or thinking through a problem out loud — press Option+V to switch to voice input. Speak naturally and Claude Code transcribes your words into a prompt, so you can describe what you need at the speed of thought.
When Claude is heading down the wrong path — editing the wrong file, writing code you don't want, or giving a long explanation you don't need — press Escape to stop it immediately. You keep everything it did up to that point and can redirect with a new prompt.
Closed a session and realized you weren't done? Pass --continue (or -c) when launching Claude Code to pick up exactly where you left off — same context, same files, same conversation history — without re-explaining what you were working on.