skills/gitlab-mr-review/SKILL.md
Review a GitLab Merge Request and provide findings, and post structured review comments with issue explanation plus code fixes. Use this skill when asked to review a Gitlab Merge request.
npx skillsauth add ibuildingsnl/reusable-ai-prompts gitlab-mr-reviewInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
The purpose of this skill is to provide constructive and comprehensive feedback on code changes. The primary goals are:
This workflow is read-first and non-invasive:
{project_id, merge_request_iid}Follow these steps in order. Do not skip a step.
Before proceeding, verify you have GitLab integration capabilities available (reading MRs, reading discussions, fetching diffs, leaving review notes, executing GraphQL). You also require terminal access to checkout git worktrees.
Retrieve all MR metadata needed for the review.
base_sha, start_sha, head_sha).Use run_in_terminal to create an isolated worktree — even if the source branch is already checked out locally. The purpose of this isolated worktree is to allow you to understand the full codebase, thoroughly trace control logic across files, and evaluate the true architectural impact of the proposed changes.
git fetch origin {source_branch}
git worktree add .worktrees/mr-review-{merge_request_iid} {source_branch}
Store worktree_path = ".worktrees/mr-review-{merge_request_iid}" for Steps 3–5. Read-only enforced — do not modify files in the worktree.
With the MR branch checked out, use runSubagent (Explore agent) to analyze the project conventions relevant to the proposed changes. To avoid wasting time on large monorepos, direct the subagent specifically. Use a prompt similar to:
"Explore the
.worktrees/mr-review-{merge_request_iid}directory. Focus primarily on the modules and adjacent dependencies affected by the MR diff, while briefly checking for global configs (e.g., framework config,README, linting configs,.github/copilot-instructions.md). Report: language, framework, architectural patterns, naming conventions, and test strategy relevant to the changed files."
Store the subagent's full response as your review baseline for code analysis.
Fallback if conventions are unclear: Infer standards from the detected language/framework:
gofmt, idiomatic Go patterns.Explore subagent).Evaluate the diff against these four lenses using your analytical capabilities:
Finding Schema & Rules: Only report findings with tangible evidence (do not report without validation). To ensure strict adherence to the schema, organize your findings internally using the following schema. CRITICAL: Do NOT print this JSON schema to the chat. Use it purely as an internal data structure to ensure you have collected all required fields, then proceed to format the output as requested in Step 6.
[
{
"id": "<file-path>:<new_line>:<rule-slug>",
"file": "path/to/file.ext",
"line": "<precise line number from diff>",
"severity": "optional | request-for-change | security-violation",
"category": "<one of the 4 lenses>",
"title": "<short constructive label>",
"observation": "<1-2 sentences>",
"suggestion": "<code block or instruction>"
}
]
Present the grouped findings report to the user before taking any action.
The report must include:
**Finding #1 — src/Auth.php:88:sql-injection**).HARD STOP: Pause here and ask the user how they would like to proceed. Provide options naturally: discussing/refining findings, posting comments, approving the MR or requesting changes. Do NOT proceed until the user issues a clear directive.
Based on the user's instructions from Step 6, take the appropriate action:
Post all approved findings as visible inline notes on the MR. First, create them using create_draft_note in a loop, and then IMMEDIATELY publish the batch using bulk_publish_draft_notes.
base_sha, start_sha, and head_sha in the position object.new_line and new_path. For deleted lines, use old_line and old_path. Set position_type: "text".bulk_publish_draft_notes. The user expects published notes, not drafts.create_merge_request_discussion_note) that indicates the target file and line.If the user requests approval, approve the MR via the GitLab MCP. If there are security violations, confirm the user explicitly wants to approve despite the risks.
If the user wishes to formally request changes, proceed in two distinct steps.
Step 1 — Verify reviewer assignment (separate check)
Query the MR to get the current user's username and the existing reviewers list:
query getMRReviewers($projectPath: ID!, $iid: String!) {
currentUser {
username
}
project(fullPath: $projectPath) {
mergeRequest(iid: $iid) {
reviewers {
nodes {
username
}
}
}
}
}
If the current user is not in the reviewers list, add them using APPEND to preserve existing reviewers:
mutation addSelfAsReviewer(
$projectPath: ID!
$iid: String!
$username: String!
) {
mergeRequestSetReviewers(
input: {
projectPath: $projectPath
iid: $iid
reviewerUsernames: [$username]
operationMode: APPEND
}
) {
mergeRequest {
id
}
errors
}
}
Step 2 — Request changes
Once reviewer assignment is confirmed, submit the request-changes state:
mutation requestChanges($projectPath: ID!, $iid: String!) {
mergeRequestRequestChanges(input: { projectPath: $projectPath, iid: $iid }) {
mergeRequest {
id
}
errors
}
}
Note: mergeRequestRequestChanges requires GitLab 17.10+ (added February 2026). On older instances it may not exist — inspect the errors array and inform the user if the mutation fails. Pass the full project path and MR IID as GraphQL variables.
If the user wants no action taken, proceed to step 8 - cleanup. If they want to refine, discuss the findings, update them, and repeat Step 6.
This step is always executed, regardless of which option was chosen in Step 6.
Remove the git worktree with verification:
git worktree remove .worktrees/mr-review-{merge_request_iid} --force
Report back to the user:
git worktree prune manually.Keep finding descriptions simple, conversational, and direct. Do not use structural headers (like "Observation:" or "Impact:"). Use the following flow for every finding:
**Avoid repeated magic string**).Do not invent alternative formats or omit any field. In the chat report, prefix with **Finding #N — <id>** (strip the prefix when posting to GitLab).
Example:
**Avoid repeated magic string**
I noticed that `"pending"` is hardcoded in multiple places. If the status name changes, missing a spot would cause inconsistent behavior.
*Relevant lines: `src/Service/OrderService.php` around line 42 and `src/Handler/CheckoutHandler.php` around line 17*
Could we extract it to a constant? Something like:
```php
// define once
const STATUS_PENDING = 'pending';
// use everywhere
if ($order->getStatus() === self::STATUS_PENDING) {
// handle pending state
}
```
_Use the same language as the changed file in the suggestion block._
curl or git CLI commands for GitLab API interactions; use MCP tools only.git worktree prune to clean orphaned entries and recover disk space..worktrees/mr-review-{merge_request_iid}tools
Create technical implementation plan and time estimation. Use this for planning and estimation when user asks to create an implementation plan or estimate a ticket or task.
tools
Creates a new feature branch from current git changes, commits them, pushes to the remote, and opens a GitLab Merge Request using the GitLab MCP server. Use this skill when asked to create a gitlab merge request
testing
OWASP ASVS 5.0 Level 1 security audit with deterministic, evidence-based findings. Use this when asked for a security audit or asvs audit.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.