Automate GitLab MR Reviews with n8n and Claude AI

This workflow automates merged request reviews on GitLab by analyzing code diffs with Claude AI, generating risk assessments and actionable reports. Save hours in code review and reduce errors with automated notifications to your team.
gitlabTrigger
httpRequest
agent
+6
Workflow Identifier: 1285
NODES in Use: gitlabTrigger, merge, httpRequest, if, agent, outputParserAutofixing, outputParserStructured, code, gmail

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Automation Does

This workflow watches for new or updated merge requests in GitLab.

When it sees one, it gets the code changes and asks Claude AI to check them for risk and give advice.

It also finds who should get a notification email and sends a clear report with the AI review.

Then it adds the AI’s comments right inside the GitLab merge request.

This saves many hours of manual checking and helps teams find issues sooner.


Tools and Services Used


Inputs, Processing Steps, and Outputs

Inputs

  • GitLab merge request create or update events via webhook trigger.
  • GitLab API token for authenticating requests.
  • Anthropic Claude AI API key for sending code diffs to the AI.
  • Gmail OAuth2 credentials for sending emails.

Processing Steps

  1. Trigger: The workflow starts when a MR is created or updated in GitLab using the GitLab Trigger node.
  2. Data Merge: The Merge node combines webhook data streams, ensuring a single source for processing.
  3. Fetch Diffs: The HTTP Request node calls GitLab API to get the detailed changed files and diffs for the MR.
  4. Check for Changes: An If node confirms if the MR has any real code changes to analyze.
  5. Analyze Diff: The Langchain Agent node sends the diff to Claude AI with a prompt asking for risk evaluation, issues, improvement suggestions, test cases, and code snippets in HTML.
  6. Parse AI Output: Two Langchain Output Parser nodes correct and format the AI’s response into clean JSON.
  7. Generate Email List: The Code node creates a list of developer, QA, admin, and MR author emails based on project mapping, avoiding duplicates.
  8. Send Email: The Gmail node sends a rich HTML email summarizing the AI’s findings to the generated list.
  9. Comment on MR: Another HTTP Request posts the AI review as a comment inside the GitLab MR.

Outputs

  • Email notifications with detailed AI review reports.
  • Inline comments inside GitLab merge requests summarizing risks and recommendations.

Beginner Step-by-Step: How to Use This Workflow in n8n

1. Download and Import the Workflow

  1. Use the Download button on this page to get the workflow file.
  2. Open your n8n editor (including self-host n8n if applicable).
  3. Choose Import from File and pick the downloaded workflow.

2. Configure Required Credentials and Settings

  1. Add your GitLab API Key in the GitLab Trigger and HTTP Request nodes that talk to GitLab.
  2. Insert your Anthropic Claude AI API Key in the Langchain Agent node.
  3. Set up Gmail OAuth2 credentials in the Gmail node to enable email sending.
  4. Update the Code node called Distribution List Generator if you want to add your own project email mappings or contacts.

3. Test the Workflow

  1. Trigger a test merge request or update in your GitLab project.
  2. Watch the workflow run inside n8n and confirm the AI review executes.
  3. Check for an email in your inbox if you are in the distribution list.
  4. Verify the AI comment appears on the GitLab MR.

4. Activate for Production Use

  1. After testing, activate the workflow by toggling the switch at the top right in n8n.
  2. Ensure the GitLab webhook is set up to call this workflow on MR changes.
  3. Monitor for errors in the n8n execution dashboard as your team uses it.

Customization Ideas

  • Change developer or QA email lists by editing the Code node named Distribution List Generator.
  • Tweak the AI prompt in the Langchain Agent node to focus on specific code style rules or security checks.
  • Edit the HTML email template in the Gmail node to match company branding or to add extra info.
  • Add rules to block merge requests or alert when AI gives a high risk score.

Handling Edge Cases and Failures

  • GitLab API errors: Happens if API Key is wrong or expired. Regenerate key and check scopes including reading code and writing comments.
  • AI response issues: May happen if API quota is reached or prompt is malformed. Check API usage, refine prompt, and review parser nodes.
  • Email not sending: Verify the email list generation code and Gmail OAuth2 setup. Test sending emails separately.

Summary

✓ Saves 4+ hours weekly by automating merge request reviews.

✓ Reduces human errors in spotting code risks.

✓ Quickly informs developers, QA, and admins by email and comments.

→ Gets fast, structured AI feedback on code diffs.

→ Helps keep code quality high and speeds up release cycles.


Frequently Asked Questions

The workflow triggers on new or updated merge requests detected via GitLab webhook events.
It uses Anthropic Claude AI to evaluate code diffs, giving risk levels, issues, and recommendations.
The AI report is emailed to developers, QA, admins, and the merge request author, and also posted as a comment in GitLab.
Edit the code node to update developer, QA, admin emails based on project mappings.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free