Pipe Commands to Claude for Quick Analysis
The -p flag lets you run Claude as a non-interactive one-shot command — no session, no back-and-forth, just an instant answer piped straight back to your terminal.
# Feed a file directly to Claude
cat app/Models/User.php | claude -p "review this model for security issues"
# Explain a git diff
git diff HEAD~3 | claude -p "summarise these changes in plain English"
# Diagnose test failures
php artisan test 2>&1 | claude -p "explain why these tests are failing and what to fix"
You can also skip the pipe entirely for quick standalone questions:
claude -p "what's the difference between git rebase and git merge --no-ff?"
claude -p "what npm command removes unused packages from node_modules?"
Combine it with other shell tools to build powerful one-liners:
# Prioritise TODO comments across the codebase
grep -rn "TODO" src/ | claude -p "prioritise these TODOs by impact and complexity"
# Redirect from a file instead of piping
claude -p "summarise the key changes in this changelog" < CHANGELOG.md
# Pipe the output into a file
git log --oneline -20 | claude -p "write a release summary" > release-notes.md
The output lands on stdout, so you can pipe it further, redirect it to a file, or combine it with other commands in a script.
-p turns Claude into a shell tool — pipe in, answer out, no session required.
Log in to leave a comment.
Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.
Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.
Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.