How to review GitHub pull requests automatically with an n8n AI agent
The problem
Small teams want a first review pass on every pull request, checked against their own coding conventions, before a human looks.
Tools needed
- n8n
- GitHub (trigger, API and nodes)
- OpenAI chat model
- Google Sheets (team best practices)
Step-by-step recipe
- Add a GitHub Trigger node that fires when a PR is opened.
- Call GitHub's pull-request files API with an HTTP Request node to get filenames and diffs.
- Merge them into one prompt in a Code node, casting the model as a senior developer for your stack.
- Give the agent a Google Sheet of team best practices as a tool.
- Post the review as a PR comment and add a label (ReviewedByAI in the source).
Copyable prompt
You are a senior [LANGUAGE/STACK] reviewer. Review this pull request diff against our team rules: {{best_practices}}.
Report at most 5 findings, most important first. For each: file, approximate line, problem, why it matters, suggested fix. Skip style nitpicks a linter would catch. If the PR looks fine, say so in one sentence. Keep the whole review under 250 words.
Diff: {{diff}}Original template written by AgentRecipes, not copied from the source. Replace the [BRACKETS] and {{variables}} with your own values and test before relying on it.
What the builder reported
On a test PR the agent posted a comment and applied the label, but as one general comment rather than line-level feedback. The author found reviews often too verbose and sometimes missing the core problems.
These are the source author's own claims. AgentRecipes has not tested or verified them.
Watch out for
- Validate each node's output as you build.
- Inline comments need a loop over each file's diff and line numbers, which the author hadn't built yet.
Source
Original write-up: Medium ↗
Found via Agent Use Cases: “Review GitHub pull requests automatically”. This recipe summarises the source in our own words; read the original for the full details. Link last checked 2026-10-15.
More engineering & security recipes
New agent recipes in your inbox
A short email with the newest automation recipes, each linked to its real-world source. No spam, unsubscribe anytime.