Merge request

From bendrucker/claude · View interactive version

Merge request is an AI agent skill from the GitHub repository bendrucker/claude. Working with GitLab merge requests via glab. Use when creating, updating, reviewing, or merging MRs, enabling auto-merge or merge trains, requesting or re-requesting reviewers, handling approvals, or working review threads, discussions, and draft notes. Load before running any `glab mr` or MR-mutati

How to use this skill

Skill file

Merge Requests

Scripts directory (absolute, for invocations from other skills where ${CLAUDE_SKILL_DIR} points elsewhere): !mkdir -p /tmp/claude/gitlab-skill 2>/dev/null; touch /tmp/claude/gitlab-skill/${CLAUDE_SESSION_ID} 2>/dev/null; echo "${CLAUDE_SKILL_DIR}/scripts"

Arguments

$0 (optional verb) routes to a section below. With no verb, infer the operation from the request.

Merging

Merge only through merge.ts, which handles merge trains, auto-merge, and squash. A bare glab mr merge silently enables auto-merge while a pipeline runs.

bun ${CLAUDE_PLUGIN_ROOT}/scripts/merge.ts
bun ${CLAUDE_PLUGIN_ROOT}/scripts/merge.ts feature-branch --auto-merge --squash
bun ${CLAUDE_PLUGIN_ROOT}/scripts/merge.ts --status 1298 1299 1300

--status prints a read-only readiness line per MR. Use it after a push or rebase, and trust its git-computed rebased_on_target over the API's conflict fields, which lag.

Re-Arm After a Push

A push cancels queued auto-merge and drops the MR from the merge train. Re-run merge.ts --auto-merge after every push to an MR meant to auto-merge. It is idempotent and retries through the approvals_syncing window after a push. When reset_approvals_on_push is on, also re-request reviewers in the same pass.

To inspect the active train or clear a stuck entry, see merge-trains.md.

Stacked MRs

Merging one layer of a stack leaves the layer above it targeting the merged branch, and GitLab does not retarget it. After every layer merges, retarget, rebase, and verify the next one per stacked-mrs.md.

Creating

glab api "projects/:id/members/all?query=<name>" | jq '.[] | {name, username}'

Reviews

Review feedback goes out as draft notes published together, per review.md, which also covers the review base, code suggestions, and approvals.

review-queue.ts lists MRs awaiting your first review across all projects as [{ url, reference, title }]:

bun ${CLAUDE_SKILL_DIR}/scripts/review-queue.ts

For the underlying GraphQL, reading review state, and grouping every review-requested MR by next actor, see review-state.md.

Re-Request Reviewers

After a push resets approvals, a note holding only /request_review @user sets that reviewer's reviewState back to UNREVIEWED. See Re-Request Review.

Discussions

# Open threads, one line each
bun ${CLAUDE_SKILL_DIR}/scripts/discussions.ts list <iid> --resolvable --unresolved --format digest

# Only review-bot threads
bun ${CLAUDE_SKILL_DIR}/scripts/discussions.ts list <iid> --bots --reviewers=${user_config.reviewers}

# Reply in a thread, then resolve it
glab mr note create <iid> --reply <discussion-id> < tmp/reply.md
glab mr note resolve <iid> <discussion-id>

See discussions.md for the other commands, the JSON schema, and API pitfalls.

Notes and Raw API

The glab mr note commands (create, draft, list, resolve, reopen) need glab 1.128 or later. Check glab --version before relying on them. Every script here takes -R group/project to target an MR outside the current checkout.

For any glab api call, read api.md first. It covers jq, error bodies, pagination, path encoding, field types, uploads, and GraphQL.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.