code-pull-request · diff
git:20260714.73d48c6 to git:20260717.53e8957
22 added, 138 removed. Audit A to A.
---
name: code-pull-request
description: >
- Create GitHub pull requests or GitLab merge requests using gh or glab. Triggers on
- "open a PR", "make a PR", "submit for review", "ship this", or when a feature branch
- is ready for review.
+ Manage GitHub pull requests or GitLab merge requests: create, read/leave/respond to
+ comments, and merge. Triggers on "open a PR", "make a PR", "merge this PR", "merge the
+ MR", "read PR comments", "leave a comment on the PR", "respond to a comment", "ship this",
+ or when a feature branch is ready for review.
user-invocable: true
---
- # Pull Request Skill
-
- Create a pull request (GitHub) or merge request (GitLab) for the current branch.
- Assumes the relevant CLI (`gh` or `glab`) is installed and authenticated.
-
- This skill is **create-only**. It does not update existing PRs, monitor CI, or
- respond to review feedback.
-
- ---
-
- ## Step 1: Detect Platform and Base Branch
-
- ```bash
- git remote get-url origin
- ```
-
- - Contains `github.com` → use `gh` (GitHub PR)
- - Contains `gitlab` → use `glab` (GitLab MR)
-
- Determine the base branch:
-
- ```bash
- base=$(git symbolic-ref --quiet refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
- [ -n "$base" ] || base=main
- echo "$base"
- ```
-
- Otherwise ask the human what the base branch is.
-
- Refuse to create a PR from the default branch — that's almost always a mistake.
- Ask the human to switch to a feature branch first.
-
- ---
-
- ## Step 2: Check for Existing PR
-
- GitHub:
- ```bash
- gh pr view --json state,number,url
- ```
-
- GitLab:
- ```bash
- glab mr view --json state,iid,web_url
- ```
-
- - **Open** → show the URL, stop. Don't create a duplicate.
- - **Closed/merged** → check for new commits since the PR was closed:
- ```bash
- git log --oneline origin/<base>..HEAD
- ```
- New commits exist → proceed to create a new PR.
- No new commits → tell the human, stop.
- - **None** → proceed to create.
-
- ---
-
- ## Step 3: Find a Template
-
- Look for the repo's PR/MR template:
-
- GitHub:
- ```bash
- ls .github/PULL_REQUEST_TEMPLATE.md 2>/dev/null
- ls .github/PULL_REQUEST_TEMPLATE/*.md 2>/dev/null
- ```
-
- GitLab:
- ```bash
- ls .gitlab/merge_request_templates/*.md 2>/dev/null
- ls .gitlab/merge_request_template.md 2>/dev/null
- ```
-
- Also check common locations:
- ```bash
- ls docs/PULL_REQUEST_TEMPLATE.md 2>/dev/null
- ls PULL_REQUEST_TEMPLATE.md 2>/dev/null
- ```
-
- - **Template found** → use it. The CLI will auto-apply it in interactive mode, or
- fill each section from the commits and diff for inline mode.
- - **No template** → use the fallback template at
- [references/default-template.md](references/default-template.md).
-
- ---
-
- ## Step 4: Generate Title and Body
-
- ```bash
- git log --oneline origin/<base>..HEAD # commit list
- git log origin/<base>..HEAD --format='%H %s%n%b' # full commit messages
- git diff --stat origin/<base>...HEAD # changed files summary
- ```
-
- Derive the title from the most significant conventional commit. If commits are
- messy, synthesize from the diff:
+ # Pull Request / Merge Request Skill
- ```
- <type>(<scope>): <description>
- ```
+ Create, comment on, and merge GitHub pull requests or GitLab merge requests for the
+ current branch. Assumes the relevant CLI (`gh` or `glab`) is installed and authenticated.
- Fill the body (template sections or fallback) from the commits and diff:
- - **Summary** — what and why, one or two sentences
- - **Changes** — bulleted, grouped by area
- - **Testing** — how it was verified (if known)
- - **Checklist** — tests pass, conventional commits, docs updated
- - **Linked issues** — extract `Closes #N`, `Fixes #N`, `Relates to #N` from commit
- footers
+ This skill is **create/read + write-gated**. Every write action (create PR, leave
+ comment, respond to comment, merge) requires explicit human confirmation before running.
---
- ## Step 5: Create the PR
-
- Push the branch first if it isn't on the remote:
-
- ```bash
- git push -u origin <branch-name>
- ```
-
- Show the human the generated title and body before creating. Ask for confirmation,
- or proceed if they said "just do it" up front.
-
- ### GitHub
-
- | Mode | Command |
- |------|---------|
- | Auto-fill | `gh pr create --fill` |
- | Inline | `gh pr create --title "<title>" --body "<body>"` |
- | Draft | `gh pr create --draft --title "<title>" --body "<body>"` |
-
- ### GitLab
-
- | Mode | Command |
- |------|---------|
- | Auto-fill | `glab mr create --fill` |
- | Inline | `glab mr create --title "<title>" --description "<body>"` |
- | Draft | `glab mr create --draft --title "<title>" --description "<body>"` |
+ ## Start Here
- Default to inline with the generated body. Use `--fill` when commits are clean and
- the body would be redundant. Use `--draft` when the human signals work in progress.
+ 1. Detect the platform and find the current branch's open PR/MR — see
+ [references/common.md](references/common.md).
+ 2. Pick a workflow:
- After creation, show the PR/MR URL to the human. Done.
+ | Workflow | Reference | Trigger phrases |
+ |----------|-----------|------------------|
+ | Create PR/MR | [create-pr.md](references/create-pr.md) | "open a PR", "make a PR", "submit for review" |
+ | Read comments | [read-comments.md](references/read-comments.md) | "read PR comments", "show MR comments" |
+ | Leave a comment | [leave-comment.md](references/leave-comment.md) | "leave a comment", "comment on the PR" |
+ | Respond to a comment | [respond-to-comment.md](references/respond-to-comment.md) | "respond to a comment", "reply on the PR" |
+ | Merge PR/MR | [merge-pr.md](references/merge-pr.md) | "merge this PR", "ship it", "merge the MR" |
+ Both GitHub (`gh`) and GitLab (`glab`) are first-class. Every write step pauses for
+ human approval before running the CLI command.