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.
The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.
The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.
Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.