LOW / CODEBlueprints
engineeringai

AI Pull Request Review Bot

When a PR is opened on GitHub, Claude AI reviews the diff, summarizes changes, flags potential issues like security risks or performance regressions, and posts a detailed review comment on Slack for the team.

Intermediate~20 minn8nMake.com 147 downloads 267 views

Setup Instructions

1. Create a GitHub webhook (Settings > Webhooks) pointing to your automation platform's webhook URL. Select the "Pull requests" event with action "opened" and "synchronize". 2. Add a GitHub node to fetch the PR diff using the GitHub API: GET /repos/{owner}/{repo}/pulls/{pull_number}/files. This returns the changed files with patch content. 3. Add a Code/Function node to format the diff into a concise prompt. Limit the diff to ~3,000 tokens per file to stay within Claude's context — truncate large files and note the truncation. 4. Add an HTTP Request node to call the Claude API (POST https://api.anthropic.com/v1/messages). Set headers: x-api-key to your Anthropic API key, anthropic-version to 2023-06-01. Use model "claude-sonnet-4-20250514" with max_tokens 1024. Craft a system prompt that instructs Claude to act as a senior code reviewer: summarize changes, flag bugs, security issues, and performance concerns. 5. Parse Claude's response from the JSON body (content[0].text) and format it into a readable Slack message with sections for Summary, Issues Found, and Suggestions. 6. Add a Slack node to post the review to your #code-reviews channel. Include the PR title, author, link, and Claude's analysis. 7. Optionally add a GitHub node to post Claude's review as an actual PR comment using POST /repos/{owner}/{repo}/issues/{pull_number}/comments. 8. Test by opening a small PR and verifying the review appears in Slack within 30 seconds.
Troubleshooting
**Claude response is too generic or shallow:** Improve your system prompt. Include specific instructions like "Focus on security vulnerabilities, null pointer risks, missing error handling, and performance implications. Reference specific line numbers from the diff." Providing the repository's language and framework context helps Claude give more targeted reviews. **Token limit exceeded for large PRs:** Large PRs can exceed Claude's input limits. Add a pre-processing step that prioritizes non-test files, truncates files over 500 lines, and splits the review into multiple API calls if needed. Set max_tokens to 1024 for the response to control costs. **JSON parsing errors from Claude's response:** Always access the response at content[0].text. If Claude returns markdown, parse it as-is for Slack (Slack supports basic markdown). If you need structured data, add "Respond in valid JSON with keys: summary, issues, suggestions" to your prompt. **GitHub webhook not firing:** Check the webhook delivery log under Settings > Webhooks > Recent Deliveries. Ensure the content type is application/json and the webhook URL is publicly accessible. Verify the secret matches if you configured one.

Need a custom version?

We can build a tailored automation workflow for your specific needs.

New blueprints weekly

Get notified when we publish new automation workflows.