Pull Request Review Agent
Reviews a diff for correctness, security and test coverage, then posts comments as suggestions rather than blocking automatically.
Read the warnings first
- • Never let the agent approve or merge
- • Treat generated security advice as a prompt for human review
- • Do not post comments on forks from untrusted sources without sandboxing
Review the change, not the whole repository
Diff-scoped review is more accurate and cheaper. The agent sees changed lines plus a small amount of surrounding context, and it must cite the line it is discussing. Comments without a line reference are dropped.
Deterministic checks first
Run linters, type checks, tests and secret scanners before the model. There is no reason to ask a language model to find a trailing whitespace error or a committed API key. Spend model attention on logic and design.
Keep the human accountable
The agent posts suggestions. A human approves the pull request. This is both a quality control and a clear ownership boundary.
Inputs, outputs and integrations
Inputs
- • A pull request diff
- • Repository conventions
- • Test results
- • A list of protected paths
Outputs
- • Prioritised review comments
- • Missing-test suggestions
- • Security flags
- • A summary for the human reviewer
Integrations
- • GitHub or GitLab API
- • CI results
- • An LLM
- • A project management tool
Technologies
Architecture
The control flow and where it stops.
The agent receives a webhook, fetches the diff and CI status, runs deterministic linters and secret scanners, then asks the model to review only the changed lines. Comments are posted as a review with a clear note that a human must approve.
Example run
A pull request adds a file upload endpoint. The agent flags missing file-type validation, notes that the size limit is enforced only on the client, and asks for a test covering an oversized file. A human reviewer confirms and requests changes.
Setup steps
- 1
Connect the repository webhook
Subscribe to pull request events and verify the webhook signature.
- 2
Run deterministic checks
Execute linters, tests and a secret scanner. Pass the results to the agent as context.
- 3
Review only changed lines
Parse the diff and restrict comments to added or modified lines.
- 4
Post as a review
Use the provider API to create review comments with file and line references. Never auto-approve.
- 5
Track acceptance
Record how many comments were accepted. If acceptance is low, refine the prompt or reduce scope.
Limitations
- Cannot understand full system context from a diff alone
- May miss runtime behaviour
- Can be noisy on large refactors
- Does not replace a security review
Privacy notes
Code may be proprietary. Use a provider with appropriate terms or a self-hosted model, and exclude repositories with regulated data unless approved.