Use --output-format for Structured JSON Responses
Need Claude to return data in a format you can pipe into another tool? The --output-format flag forces structured JSON output.
claude -p "list all TODO comments in this project" --output-format json
Instead of a conversational response, you get clean, parseable JSON that you can feed directly into jq, a script, or another command.
This is essential for building automation on top of Claude Code. A few examples:
# Extract function names and pipe to another tool
claude -p "list all exported functions in src/utils/" \
--output-format json | jq '.result'
# Generate a structured changelog
claude -p "summarise changes since last tag as JSON with
fields: type, scope, description" --output-format json
# Chain Claude into a shell pipeline
claude -p "analyse this error log" --output-format json \
< /var/log/app.log | jq '.suggestions[]'
Combine this with the -p (print/pipe) flag for non-interactive usage. Together they turn Claude Code from a conversational tool into a programmable one.
# Non-interactive + structured output = scriptable Claude
claude -p "what dependencies are outdated?" \
--output-format json > outdated.json
When you need data, not conversation — --output-format json makes Claude Code scriptable.
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.