Overview
Run Claude Code non-interactively over each queued pull request diff, save its findings as editable draft files in one review folder, and post only the comments a person has checked.
Problem or Objective
More in Coding and Code Review
AI Agents and Models
Tools and Integrations
- Tools
- Claude Code · Git
- Prerequisites
- Claude Code installed with a plan or API key, a local clone of the repository, and a small script that exports diffs and saves the JSON results.
How It Works
List the pull requests waiting for review and, for each one, export its diff against the base branch into a text file. Pipe each diff into claude -p with a short reviewer prompt and --output-format json with a --json-schema that asks for findings as file, line, severity and comment. Save every result as its own draft file in a single review folder, which works as the inbox. Open each draft, delete weak findings, rewrite the wording in your own voice, and check any claim against the source code before you rely on it. Only after that does a person paste or post the edited comments on the pull request. The script never posts anything itself.
Implementation Workflow
Steps assembled from the agents, tools and prompt of this entry. Adapt them to your own setup.
- Choose the agentSet up Claude Code.
- Connect the toolsConnect the tools this workflow relies on: Claude Code, Git.
- Check the prerequisitesClaude Code installed with a plan or API key, a local clone of the repository, and a small script that exports diffs and saves the JSON results.
- Gather your detailsCollect what the prompt asks for: Pull request number, Repository name, What to look for.
- Run the starter promptPaste the starter prompt below into Claude Code and adapt it to your case.
- Check against the documentationCompare what you get with the documentation at code.claude.com before you rely on it.
Practical Starter Prompt: Draft review findings for one pull request
Fill the fields to adapt the prompt. Empty fields stay as visible [placeholders].
You are reviewing the diff of pull request [Pull request number] in [Repository name], piped in below. Focus on [What to look for]. Return findings as JSON with file, line, severity and a short comment for each. Only report problems you can point to in the diff, say when you are unsure, and do not suggest posting anything. A person will edit these drafts and decide what to post.Save each result as a draft file in your review folder. Read the code behind every finding, edit or delete it, and post the remaining comments on the pull request yourself.
Expected Results and Benefits
This is a suggested workflow, not a reported result. The points below are what the cited documentation says the tools can do.
This is a suggested workflow, not a reported outcome. The Claude Code headless documentation shows Claude run with claude -p from a script as a project-specific linter or reviewer, with a diff piped in, and shows --output-format json with --json-schema for structured output. It does not describe a review inbox or any interface for editing drafts; that part is your own folder or tool. The pages do not say how accurate the findings will be.
Limitations and Considerations
Keep posting in human hands: the script should only write local files. The headless page notes that a -p session shows no trust dialog, so set tool permissions explicitly with --allowedTools or leave tools off; piping the diff in means Claude does not need Bash permission to read it. Each run uses your Claude plan or API credits, and the JSON output reports total_cost_usd so you can track spend. Findings can be wrong or miss problems, so read the changed code before agreeing with a comment. Results depend on your setup and were not independently reproduced by Top 200 Repos.
GitHub Repositories
AI Agent Repository
Source code of the agent that does the work.
Official Website
The official site of the main tool or project in this use case.
Visit Website (opens in a new tab)code.claude.com
Related Videos
About anthropics/claude-code
The SECRET Claude Code Upgrade That Has Everyone Going Nuts (Full Guide) (opens in a new tab)
The title names the project, the description links the project website.
Watch on YouTube (opens in a new tab)About anthropics/claude-code
The only Claude Code guide you'll ever need (Opus 4.5) (opens in a new tab)
The title names the project, the description links the project website.
Watch on YouTube (opens in a new tab)Independent creators. Listing a video implies no endorsement, sponsorship or partnership.
Sources
- Run Claude Code programmatically - Claude Code Docs (opens in a new tab)
Project documentation · code.claude.com · Undated · Source checked 26 Nov 2026, 17:27 UTC
What this source supports
- You can wrap a non-interactive call in a script to use Claude as a project-specific linter or reviewer.
- Piping the diff means Claude does not need Bash permission to read it.
- To get output conforming to a specific schema, use --output-format json with --json-schema and a JSON Schema definition.
- With --output-format json, the response payload includes total_cost_usd and a per-model cost breakdown.

