| name | pr-merge-dev |
| description | Merge the current branch's open PR into dev on GitHub — verifies CI is green and no conflicts exist, merges via gh, deletes the remote branch, then cleans up locally (switch to dev, pull, delete local branch). Use when the PR is open and all checks have passed and you want to land it. |
PR merge to dev — land a green PR and clean up
Take the open PR for the current branch, confirm it is truly ready to land (CI green,
no conflicts, not a draft), merge it into dev on GitHub, delete the remote branch,
then clean up locally: switch to dev, pull, and delete the local branch.
This is the step that follows pr-check-release in the
docs/process/06-release-and-deploy.md
release flow. Read AGENTS.md and the applicable .agents/rules/ first, as always.
Where this sits — distinct git skills, no overlap
definition-of-done answers "is the work done?" — before the PR.
pr-check-release answers "is this branch ready to land on dev, and if so, put
it on GitHub as a PR?" — pushes the branch and opens/updates the PR.
- This skill (
pr-merge-dev) answers "is the open PR green? if so, merge it and
clean up" — it is the only skill that merges and deletes branches.
release-check answers "is dev ready to promote to main?" — the later
dev → main gate. This skill never promotes dev → main.
Outward actions require care
Merging a PR and deleting branches are irreversible and visible to the team. Before
any outward action, state the PR number, title, and source → target, and get a
go-ahead — unless the caller already said "merge it" in this session. Never merge a
draft PR or one with failing/pending checks. If gh is unavailable or unauthenticated,
run the read-only gates, then stop and hand the engineer the exact commands rather
than claiming a merge happened.
The gates — run in order, stop on any failure
Unlike the review skills, this skill stops at the first ❌ in the pre-merge gates
(1–5). A partial merge is worse than no merge. The post-merge steps (6–8) run only after
a successful merge.
| # | Gate | How |
|---|
| 1 | On a work branch, not main/dev | git branch --show-current; must be feat/, fix/, doc/, chore/, or refactor/. If on a protected branch, stop. |
| 2 | An open PR exists targeting dev | gh pr view --json number,title,state,isDraft,baseRefName — must be open, not a draft, and targeting dev. |
| 3 | All CI checks are green | gh pr checks — every required check must show ✅ pass. Any failing or pending check is a stop: do not merge. Report which checks are red/pending. |
| 4 | No merge conflicts | gh pr view --json mergeable — MERGEABLE. If CONFLICTING, stop and list the conflicting paths (from git merge-tree or the PR's conflict report). If UNKNOWN, wait briefly and recheck once. |
| 5 | Go-ahead received | Summarize: PR number, title, branch → dev, merge strategy (squash). Require explicit confirmation before continuing. |
| 6 | Merge the PR | gh pr merge <number> --squash --delete-branch — squash-merge and delete the remote branch in one atomic step. Confirm the merge SHA. |
| 7 | Switch to dev locally | git checkout dev |
| 8 | Pull and delete local branch | git pull origin dev to bring the merged commit in; then git branch -d <branch> to delete the local branch (use -d, not -D — if it was not fully merged the delete will fail and that is the right outcome). |
Merge strategy
Always use squash merge (--squash). This keeps dev history linear and makes
reverting a feature atomic. Never use --rebase or a plain merge commit unless the
caller explicitly overrides — and note the deviation in the report if so.
Branch deletion
--delete-branch in gate 6 deletes the remote branch on GitHub atomically with the
merge. Gate 8 deletes the local branch separately. If the local delete fails (e.g.
the branch has unpushed commits), report the error and the exact command; do not force-
delete (-D) without explicit instruction.
Linked issues
This skill does not automate issue/board transitions. A Closes #N / Fixes #N link in
the PR body auto-closes the issue on merge — no action needed. If you want linked
issues closed and the PR used only Refs #N (which does not auto-close), close them
manually: gh issue close N --reason completed.
Step-by-step
- Orient. Read
AGENTS.md + the applicable .agents/rules/. Confirm the current
branch (gate 1); if on main/dev, stop immediately.
- Find the PR. Run
gh pr view (gate 2). If no open PR exists, stop and tell the
engineer to run pr-check-release first.
- Check CI. Run
gh pr checks (gate 3). Stop if any check is red or pending — list
which ones and their status.
- Check mergeability. Query
mergeable (gate 4). Stop if CONFLICTING — list the
paths; the engineer must resolve them locally and push.
- Gate the action. If gates 1–4 are all ✅, state the PR and the merge plan, and get
the go-ahead (gate 5). If any gate failed, stop here — report, do not merge.
- Merge. Run
gh pr merge <number> --squash --delete-branch (gate 6). Capture and
report the merge commit SHA.
- Clean up locally.
git checkout dev (gate 7), then git pull origin dev && git branch -d <branch> (gate 8). Report any failures without force-deleting.
- Report (below).
Output
Emit a single verdict table, one row per gate, with an explicit status:
- ✅ pass — ran and green.
- ❌ fail — ran and failed; include the command and key output.
- ⚠️ manual / not run — could not run (no
gh, pending state, or human-only); say
which and why. Never green-by-default.
Distinguish failed from not run from assumed
(.agents/rules/03-surfacing-gaps-and-incomplete-work.md). End with a one-line verdict:
- MERGED — gates 1–8 green; include the merge commit SHA, confirm the remote
branch was deleted, confirm the local branch was deleted, and confirm the local
dev
is up to date.
- NOT MERGED — otherwise, followed by the concise list of what is red or blocked and
what/who must resolve it. If the pre-merge gates passed but the merge was not done
(no go-ahead, or no
gh), say so and give the exact commands.
Never soften a ❌ or ⚠️ into a merged-sounding summary. This skill merges into dev;
it never promotes dev → main.