open-mr
Install
npx skills@latest add abijith-suresh/skills --skill open-mrDescription
Pushes the current branch and opens a new GitLab MR via glab CLI. Invoke when opening a merge request on GitLab. Requires a ticket number. The user may also name this skill explicitly.
SKILL.md
Push the current branch and create a new merge request on GitLab.
Prerequisites
glabCLI must be installed and authenticated — verify withglab auth status.- If
glabis missing: “glab CLI is required. Install it from https://gitlab.com/gitlab-org/cli#installation.” - Ticket number required in the branch name or conversation.
Steps
1. Check branch state
git branch --show-currentgit remote show origin | grep "HEAD branch"git status --porcelain- If current branch is
main,master, or the remote default branch — stop: “Cannot open an MR from the default branch. Switch to a feature branch first.” - If
git status --porcelainreturns any output — stop: “Uncommitted changes detected. Commit or stash them before opening an MR.”
2. Check for existing MR
glab mr list --source-branch <branch-name> -F jsonParse the JSON output. If the array is non-empty — stop: “An MR already exists for this branch. Use update-mr to modify it.”
3. Push the branch
git push -u origin <branch-name>- If push fails — stop and show the exact error.
4. Derive title and body
Run the following to gather branch data:
git log origin/<default-branch>..HEAD --onelinegit log origin/<default-branch>..HEAD --format="%s %b"git diff origin/<default-branch>..HEAD --statTitle format:
TICKET-123: Short descriptionExamples:
PROJ-214: Add investigation workflowPROJ-214: Fix target branch detection
MR body template:
## Summary[What changed and why. 2–3 concise sentences.]
## Changes- [Specific action taken]- [Specific action taken]
## Testing- [ ] [Specific verification step]- [ ] [Edge case or regression check]
## Notes[Risks, follow-ups, rollout notes, or reviewer context. Omit this section ifthere is nothing useful to say.]Rules:
- Derive the Testing checklist from the real changes, not a generic template
- Each Changes bullet describes an action, not just a file name
- Omit
Notesif there is nothing useful to say - No References section — the ticket is already in the title
5. Create the MR
glab mr create \ --title "<title>" \ --description "<body>" \ --push \ --yesNote: --push pushes the branch first, then creates the MR. --yes skips the confirmation prompt.
6. Report
Print the MR URL returned by glab mr create. Note any follow-up the user still needs to do manually.
Failure Conditions
| Condition | Message |
|---|---|
glab CLI not installed |
“glab CLI is required. Install it from https://gitlab.com/gitlab-org/cli#installation.” |
| Not authenticated | “glab CLI is not authenticated. Run glab auth login first.” |
| On default branch | “Cannot open an MR from the default branch. Switch to a feature branch first.” |
| Uncommitted changes | “Uncommitted changes detected. Commit or stash them before opening an MR.” |
| MR already exists | “An MR already exists for this branch. Use update-mr to modify it.” |
| Push failed | Show the exact git error and stop. |