create-mr-gitlab-gitlisted
Install: claude install-skill ForeverAProgrammer/claude-devflow
Create a GitLab merge request from the current branch, deriving the title and description from the branch's git history.
Steps:
1. Check that `glab` is installed and authenticated by running `glab auth status`. If not, tell the user and stop.
2. Determine the target branch:
- If the user passed an explicit target branch in $ARGUMENTS (e.g. `--target-branch <name>` or `--target <name>`), use `<name>` directly as `<base>` and skip the rest of this step.
- Otherwise, find the closest remote ancestor of the current branch — i.e. the branch this feature branch was actually created from, not necessarily the repository's default branch. Run the following to score each remote branch by how many commits HEAD is ahead of the merge-base with that branch (lower = closer ancestor), then list every branch tied for the lowest score:
```bash
scored=$(git for-each-ref --format='%(refname:short)' refs/remotes/origin/ \
| grep -v 'origin/HEAD' \
| grep -v "origin/$(git branch --show-current)" \
| while read branch; do
base=$(git merge-base HEAD "$branch" 2>/dev/null) || continue
echo "$(git rev-list --count "$base"..HEAD) $branch"
done | sort -n)
min=$(echo "$scored" | head -1 | awk '{print $1}')
echo "$scored" | awk -v m="$min" '$1==m {print $2}' | sed 's|origin/||'
```
- If exactly one branch is returned, use it as `<base>`.
- If multiple branches tie for the lowest score (e.g. several release branches