Automated code review assistant that analyzes pull requests and provides detailed feedback using GPT-4.
Supercharge your code review process with an AI-powered GitHub PR reviewer. This workflow triggers on new pull requests, fetches the diff, analyzes code changes using GPT-4, and posts detailed review comments directly on the PR. It checks for code quality, potential bugs, security issues, and suggests improvements. Perfect for teams looking to maintain high code standards while reducing review bottlenecks.
{
"name": "AI GitHub PR Reviewer",
"nodes": [
{
"parameters": {
"content": "## Template by Harshith Vaddiparthy\n\n\n**Learn to Build AI Automations**\nMaster n8n, AI agents, and no-code automation in my comprehensive course.\nā harshith.com/vibecode\n\n\n**Content Automation Consulting**\nI help businesses automate video creation, social media, blogs, and newsletters.\nā harshith.com/meet\n\n\n**Connect with me**\nā linkedin.com/in/harshith-vaddiparthy",
"height": 420,
"width": 400,
"color": 4
},
"id": "promo-sticky",
"name": "Sticky Note - Credits",
"type": "n8n-nodes-base.stickyNote",
"position": [
-500,
-200
],
"typeVersion": 1
},
{
"parameters": {
"events": [
"pull_request"
],
"owner": "={{ $json.repository.owner.login }}",
"repository": "={{ $json.repository.name }}"
},
"id": "github-trigger",
"name": "GitHub Trigger",
"type": "n8n-nodes-base.githubTrigger",
"position": [
0,
100
],
"webhookId": "github-pr-webhook",
"credentials": {
"githubApi": {
"id": "YOUR_GITHUB_CREDENTIAL_ID",
"name": "GitHub"
}
},
"typeVersion": 1
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "action-check",
"leftValue": "={{ $json.action }}",
"rightValue": "opened",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "or"
}
},
"id": "check-action",
"name": "Check PR Action",
"type": "n8n-nodes-base.if",
"position": [
200,
100
],
"typeVersion": 2.2
},
{
"parameters": {
"url": "=https://api.github.com/repos/{{ $('GitHub Trigger').item.json.repository.full_name }}/pulls/{{ $('GitHub Trigger').item.json.number }}/files",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Accept",
"value": "application/vnd.github.v3.diff"
}
]
}
},
"id": "get-pr-diff",
"name": "Get PR Diff",
"type": "n8n-nodes-base.httpRequest",
"position": [
400,
100
],
"credentials": {
"httpHeaderAuth": {
"id": "YOUR_GITHUB_TOKEN_CREDENTIAL_ID",
"name": "GitHub Token"
}
},
"typeVersion": 4.2
},
{
"parameters": {
"text": "=Review this pull request diff and provide constructive feedback:\n\nPR Title: {{ $('GitHub Trigger').item.json.pull_request.title }}\nPR Description: {{ $('GitHub Trigger').item.json.pull_request.body }}\n\nDiff:\n{{ $json.data }}\n\nProvide feedback on:\n1. Code quality and readability\n2. Potential bugs or edge cases\n3. Security concerns\n4. Performance implications\n5. Suggestions for improvement\n\nFormat your response as a professional code review comment.",
"modelId": {
"__rl": true,
"value": "gpt-4o",
"mode": "list"
},
"options": {
"temperature": 0.3
}
},
"id": "analyze-code",
"name": "Analyze with GPT-4",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
600,
100
],
"credentials": {
"openAiApi": {
"id": "YOUR_OPENAI_CREDENTIAL_ID",
"name": "OpenAI"
}
},
"typeVersion": 1.8
},
{
"parameters": {
"method": "POST",
"url": "=https://api.github.com/repos/{{ $('GitHub Trigger').item.json.repository.full_name }}/issues/{{ $('GitHub Trigger').item.json.number }}/comments",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\"body\": \"## š¤ AI Code Review\\n\\n{{ $json.content }}\\n\\n---\\n*This review was generated by an AI assistant. Please use your judgment when applying suggestions.*\"}"
},
"id": "post-comment",
"name": "Post Review Comment",
"type": "n8n-nodes-base.httpRequest",
"position": [
800,
100
],
"credentials": {
"httpHeaderAuth": {
"id": "YOUR_GITHUB_TOKEN_CREDENTIAL_ID",
"name": "GitHub Token"
}
},
"typeVersion": 4.2
},
{
"parameters": {
"content": "## AI GitHub PR Reviewer\n\n### Setup:\n1. Create a GitHub App or use a personal access token\n2. Configure the webhook in your repository\n3. Set up OpenAI credentials\n\n### Flow:\n1. Triggers on new PRs\n2. Fetches the code diff\n3. Analyzes with GPT-4\n4. Posts review comment on PR\n\n### Customization:\n- Adjust the AI prompt for your coding standards\n- Add file type filtering\n- Integrate with your CI/CD pipeline",
"height": 340,
"width": 400,
"color": 7
},
"id": "info-sticky",
"name": "Info",
"type": "n8n-nodes-base.stickyNote",
"position": [
-500,
40
],
"typeVersion": 1
}
],
"connections": {
"GitHub Trigger": {
"main": [
[
{
"node": "Check PR Action",
"type": "main",
"index": 0
}
]
]
},
"Check PR Action": {
"main": [
[
{
"node": "Get PR Diff",
"type": "main",
"index": 0
}
]
]
},
"Get PR Diff": {
"main": [
[
{
"node": "Analyze with GPT-4",
"type": "main",
"index": 0
}
]
]
},
"Analyze with GPT-4": {
"main": [
[
{
"node": "Post Review Comment",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"pinData": {},
"meta": {
"instanceId": "template-github-pr-reviewer"
}
}Copy this JSON and import it into n8n via Settings ā Import from File/URL ā Paste JSON