| name | create-mr |
| description | Create or update a GitLab merge request from a pushed branch after local review, base-branch sync, validation, and issue linking. |
create-mr
Use this after git-push when the user asks to create, update, or open a GitLab merge request.
Goal
Create or update a review-ready MR from the current branch after syncing the base branch, reviewing the diff locally, and linking the related task.
Workflow
-
Inspect and choose base
Run:
git status --short
git branch --show-current
git status -sb
Prefer the repo's default MR base. If repo guidance names a different base, use that.
If the worktree is dirty, pause unless the changes are intentionally excluded from the MR.
-
Review and sync locally
Run:
git diff --stat <base>...HEAD
git diff <base>...HEAD
Review the diff for accidental files, secrets, conflict markers, generated churn, and missing tests or docs.
Fetch the base branch and make sure it has been merged or rebased into the current branch before creating or updating the MR.
If conflicts occur, resolve them locally, rerun relevant validation, commit the resolution, and push through git-push so any configured pre-push hook runs.
-
Build title, body, and issue link
Default the title from the issue title or the main commit subject.
Infer issue links from the user request, branch name, or commits. Do not invent issue IDs.
Keep the body concise and include:
- summary
- validation performed
- issue link such as
Closes #123, Fixes #123, or Refs #123 when known
-
Create or update MR
Use GitLab CLI when available. If a MR already exists for the current branch, update it instead of creating a duplicate:
glab mr view <branch> --output json
glab mr update <branch> --title "<title>" --description "<body>"
Before editing an existing MR, read the current body and preserve user-authored content that is not clearly generated by this CI job. Do not overwrite manual notes, review context, checklist items, or release details just to apply the generated summary.
If no MR exists, create one:
glab mr create --target-branch <base> --source-branch <branch> --title "<title>" --description "<body>"
If glab is unavailable or not authenticated, report the exact title/body/base/head needed to create or update the MR manually.
Reporting
After creating or finding a MR, report:
- MR URL
- base branch
- head branch
- title
- validation included in the body
- whether the base branch was merged or rebased locally
- remind the user to watch CI, respond to review comments, and keep the MR current by regularly merging or rebasing the base branch