Back to the blog
TutorialsOctober 18, 20266 min read

GitLab AI Code Review: How to Review Merge Requests Locally with AI

Review GitLab merge requests with AI on your own machine: glab mr checkout, view and diff, a copy-ready review prompt for Claude Code, Cursor, Codex or Copilot CLI.

Most AI review guides assume GitHub. Teams on GitLab, especially those with private or sensitive code, often prefer not to send merge requests to another cloud service. The good news: glab gives a coding agent everything it needs in a few commands.

What you need

  • The GitLab CLI glab, authenticated with glab auth login.
  • A local clone of the project.
  • One coding agent signed in on your machine (Claude Code, Cursor CLI, Codex CLI or Copilot CLI).

Step 1: Check out the merge request

Reading the full code, not only the patch, is what lets the agent find problems outside the diff.

Terminal
glab mr checkout 123

Step 2: Save the intent and the changes

The description tells the agent what the MR should do; --comments includes the existing discussion. --raw outputs an unmodified patch that tools can read.

Terminal
glab mr view 123 --comments > /tmp/mr-123.md
glab mr diff 123 --raw > /tmp/mr-123.diff

Step 3: Ask the agent for a review

Use the same prompt with any agent. Keep it read-only and ask for a fixed format.

Review prompt
Read /tmp/mr-123.md for the intent and discussion,
and /tmp/mr-123.diff for the changes.
Check that the code does what the description says.
For each changed function, read its callers and tests.
Report findings as: severity, file:line, problem, suggested fix.
Do not edit files.

Example with Claude Code

Terminal
claude "$(cat review-prompt.txt)"

Step 4: Post only what you agree with

Read the findings, drop the false positives and post the useful ones yourself, for example with glab mr note. The agent assists; the reviewer decides.

Terminal
glab mr note 123 -m "The new endpoint does not check project membership."

Where the manual flow gets slow

  • Checkout, diff, prompt and cleanup repeat for every merge request.
  • No history: findings disappear with the terminal session.
  • Subgroups and self-managed instances need extra --repo and host setup.

How CodeCrab automates it

CodeCrab connects your gitlab.com projects (including subgroups) through glab, prepares each merge request in an isolated copy, runs the review with your agent and repository skills, and keeps every finding and investigation on your laptop. Follow the GitLab merge requests guide to set it up, or see pre-push code review to catch issues before the MR exists.

Try it on your next Pull Request

Free Public Beta — runs 100% on your machine. No code leaving your laptop.

Download CodeCrab

KEEP READING