Run Claude Code without a driver in the seat.
Headless mode (claude -p / --print) takes an interactive
agent and turns it into something you can pipe, cron, and CI. One shot, one prompt,
one machine-readable answer — perfect for the parts of the job that don't need a
human in the loop: triaging a stack trace at 02:00, summarising a PR diff into the
release notes, classifying overnight Sentry errors, or generating an SBOM diff and
posting it back to the issue.
Pair it with --output-format stream-json and you get structured events
you can hand straight to a downstream job. Pair it with --allowed-tools
and you get a tightly-scoped agent that can only do what the job needs. Pair it with
a GitHub Action and your repo has a pit crew that never sleeps.
# 1. Triage an overnight error and post the summary to the issue. cat sentry-error.json | claude \ -p "Read this Sentry payload, find the most likely culprit file in this repo, and draft a one-paragraph triage note." \ --allowed-tools "Read,Grep,Glob" \ --output-format stream-json \ | jq -r 'select(.type=="result") | .result' \ | gh issue comment $ISSUE --body-file - # 2. CI gate: ask Claude to review the diff before merge. git diff origin/main...HEAD | claude \ -p "Review this diff. Fail with exit code 1 if you find SQL injection, hardcoded secrets, or N+1 queries. Otherwise approve." \ --allowed-tools "Read,Grep" \ || exit 1 # 3. Cron the boring stuff. Resume the same session every morning. claude -p --resume standup-thread \ "Pull yesterday's merged PRs and draft my standup. Yesterday / today / blockers."
- Scriptable. stdin in, stdout out — pipes, cron, CI all work.
- Scoped.
--allowed-toolskeeps the agent in its lane. - Resumable.
--resumethreads context across runs. - Structured.
stream-jsongives downstream jobs real data.