Claude Tips mascot
Claude Tips & Tricks
Claude Code intermediate

Pipe Anything into Claude Code

Use Unix pipes to feed files, command output, or data directly into Claude Code for instant analysis without an interactive session.

Claude Code works as a Unix citizen. Pipe anything into it:

# Analyze error logs
cat error.log | claude -p "What's causing these errors? Suggest fixes."

# Review a diff
git diff | claude -p "Review this diff for bugs and suggest improvements."

# Explain a file
cat src/complex-module.ts | claude -p "Explain this code in plain English."

# Analyze test failures
npm test 2>&1 | claude -p "Why are these tests failing? Give me the fix."

Combine with Other Tools

# Find and analyze all TODO comments
grep -rn "TODO" src/ | claude -p "Prioritize these TODOs by importance and suggest which to tackle first."

# Check for security issues in dependencies
npm audit 2>&1 | claude -p "Which of these vulnerabilities are critical and how do I fix them?"

# Analyze git history
git log --oneline -20 | claude -p "Summarize what's been worked on recently."

Output as JSON

git diff --staged | claude -p "List all changed functions" --output-format json

The -p flag makes Claude non-interactive. It reads stdin, processes it, and prints the result to stdout. Perfect for scripting.

Paste into Claude Code
Show me examples of piping different types of data into claude -p for quick analysis. Include error logs, git diffs, and file contents.