Create MR/PR
Analyze git diff against a target branch, generate a structured PR/MR with auto-title and detailed description, then submit via gh or glab CLI.
When to use
User says: "create a PR", "create an MR", "open a pull request", "make a merge request", "submit changes".
Workflow
1. Ask target branch — CRITICAL: NEVER SKIP THIS STEP
You MUST always ask the user which branch to merge into. Never guess, never default, never infer from git branch. You cannot proceed until the user explicitly provides the target branch name.
Ask: "Which branch should this merge into?"
Repeat the question if the user says something non-committal like "the usual one" or "same as always." You need the exact branch name.
2. Check diff
git diff <target_branch>...HEAD --stat
git diff <target_branch>...HEAD
If no diff, abort with error.
If uncommitted changes exist (git status --porcelain), show them and say:
"Uncommitted changes detected. Please commit first or use /commit."
3. Detect platform
git remote get-url origin
github.com→ useghgitlab.com→ useglab- Else → ask user which platform
Verify CLI is installed (gh --version or glab --version). If missing, error with install instructions.
4. Analyze diff
From the diff output, determine:
| Property | How |
|---|---|
| Type | feat/fix/refactor/chore/docs/test/style/perf |
| Scope | Module/directory name from changed files |
| Breaking | BREAKING CHANGE in commit msgs or removed public APIs |
| Migration | Presence of migration/DDL files |
| New env vars | .env.example or process.env additions |
| New deps | package.json, requirements.txt, go.mod changes |
5. Generate title
Format: <type>(<scope>): <description>
Rules:
- Imperative present tense ("add" not "added")
- Under 72 chars
- Lowercase after colon
6. Generate description
Pull from the template at references/description-template.md. Include only sections with relevant content. Omit empty sections (except Checklist).
7. Create PR/MR
# GitHub
gh pr create --title "<title>" \
--body "$(cat << 'PRBODY'
<description>
PRBODY
)" \
--base <target_branch>
# GitLab
glab mr create --title "<title>" \
--description "$(cat << 'MRBODY'
<description>
MRBODY
)" \
--target-branch <target_branch>
8. Return result
Show the URL and a summary:
Created PR: https://github.com/owner/repo/pull/123
Type: feat(auth) — implement JWT login
Target: main
Template
See references/description-template.md for the full description template.
Platform CLI Installation
- GitHub (
gh):brew install ghor https://cli.github.com - GitLab (
glab):brew install glabor https://gitlab.com/gitlab-org/cli