/github-workflows:merge-prfrom github-workflows
Merge a PR into its base branch. Defaults to a merge commit; pass --squash or -s to squash instead. Falls back to squash when the repo disallows merge commits. Single PR by number or current branch. Refuses to squash/rebase into main on a git-flow repo — use /promote-release there instead.
Ships in github-workflows. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Validates readiness, invokes /finalize-pr for soft blocks, then merges.
Hard stops abort immediately. Some cases require human action: closed/merged PR,
draft, unresolvable conflicts, unrecoverable CI, or more than 100 review threads.
State warning: Branch state, remote tracking, and PR status change between invocations. Re-run all git/gh commands from Step 1.
/finalize-pr's responsibility/finalize-pr for soft blocks; abort on hard stops with reason--squash/-s opts into a squash mergemain on a git-flow repo —
Step 0 guards this. Plain merge commit into main on a git-flow repo IS
allowed — that's the /promote-release path./pr-stacks.Resolve the PR's base branch and the repo's default branch:
BASE_BRANCH=$(gh pr view <PR_NUMBER> --json baseRefName --jq '.baseRefName')
DEFAULT_BRANCH=$(gh repo view --json defaultBranchRef --jq '.defaultBranchRef.name')
If BASE_BRANCH == main AND DEFAULT_BRANCH == develop (repo is on git-flow —
see /gh-cli-patterns Canonical Default-Branch Detection):
--squash/-s was passed → abort immediately, no finalize:
"This is a
promote/<version>→mainpromotion PR on a git-flow repo.mainaccepts merge commits only — squash and rebase are banned by ruleset, no exceptions. Run/promote-releaseinstead, or merge manually withgh pr merge --merge."
No --squash (default merge commit) → this is a legitimate promotion.
Continue to Step 1, but note in the final report that /promote-release is
the normal entry point for this (it also opens the PR and explains
release-please) — this invocation may be a manual equivalent of that.
Otherwise (trunk repo, or a git-flow repo's ordinary feature PR into develop),
continue to Step 1 with the requested (or default) merge method.
gh repo view --json mergeCommitAllowed,squashMergeAllowed,rebaseMergeAllowed
Decide before attempting any merge — never retry after a failed gh pr merge:
--squash/-s was passed → use squash. If squashMergeAllowed == false,
abort: "Repo does not allow squash merges."mergeCommitAllowed == false and
squashMergeAllowed == true, fall back to squash and say so in the final
report ("repo disallows merge commits — squashed instead").mergeCommitAllowed nor squashMergeAllowed (and no explicit
--squash) → abort, reporting what the repo does allow.Carry the resolved method (merge or squash) into Step 2 and Step 3.
Run the canonical PR-readiness gate
and canonical code-scanning alert count from /gh-cli-patterns. The readiness
gate includes all items in the PR feedback ledger.
Replace <OWNER>, <REPO>, <PR_NUMBER> per the
placeholder convention. CodeQL is separate from CI — check both.
| Condition | Message |
|---|---|
state != OPEN | "PR is closed or merged — nothing to do" |
isDraft == true | "PR is a draft — mark it ready for review first" |
reviewThreads.pageInfo.hasNextPage == true | ">100 review threads — paginate manually and re-verify before merging" |
If any of the following fail, proceed to Step 1.3 (auto-finalize), then re-run the full gate. If the gate still fails after finalization, abort with the specific reason.
| Check | Must be | Abort message (if still failing after finalize) |
|---|---|---|
mergeable | MERGEABLE | "PR has git conflicts — unresolvable" |
mergeStateStatus | CLEAN or HAS_HOOKS | "PR merge state is {value} — still blocked after finalize" |
reviewDecision | APPROVED or null | "Review decision is {value}" |
statusCheckRollup.state | SUCCESS | "CI is {state} — unrecoverable" |
| PR feedback ledger | Zero unaddressed feedback items | "Unaddressed PR feedback remains" |
| Required status-check contexts | Every required context was reported in statusCheckRollup.contexts | "required check never reported: <context> — see github-actions-silent-failures" |
All reviewThreads.isResolved | true | "Unresolved review threads remain" |
| CodeQL alert count | 0 | "Open CodeQL alerts remain — run /resolve-codeql manually" |
Invoke /finalize-pr <PR_NUMBER>. If it reports human intervention needed, abort with
its reason. Then re-run the full gate (Steps 1.1 + 1.2); if any soft block persists,
abort with the specific failing field.
Merge commits use GitHub's default subject — skip this step entirely when
Step 0.5 resolved to merge.
For a squash, analyze the full changeset to generate a release-note-friendly
commit message. Replace <PR_NUMBER> and <BASE_BRANCH> (from Step 0) before
running:
git fetch origin <BASE_BRANCH>
git diff origin/<BASE_BRANCH>...HEAD
git log --oneline origin/<BASE_BRANCH>..HEAD
Generate:
<type>: <description>, under 70 chars)Types: feat, fix, refactor, docs, test, chore
Store the title in a shell variable:
SQUASH_TITLE="<generated title>"
Capture the branch name before merging (needed for cleanup). Replace <PR_NUMBER> before running:
BRANCH=$(gh pr view <PR_NUMBER> --json headRefName --jq '.headRefName')
Merge without --delete-branch (avoids git switch failure in bare+worktree repos).
Use the heredoc body pattern from /gh-cli-patterns.
Squash (Step 0.5 resolved to squash, whether by --squash/-s or fallback):
gh pr merge <PR_NUMBER> --squash --subject "$SQUASH_TITLE" --body "$(cat <<'EOF'
... generated body ...
EOF
)"
Merge commit (default):
gh pr merge <PR_NUMBER> --merge
Single-quoted 'EOF' prevents shell expansion. Closing EOF must be alone on its own line with no leading whitespace.
Delete the remote branch (GitHub may have auto-deleted it on merge — || true handles that):
git push origin --delete "$BRANCH" || true
Find and remove the local worktree by branch name (works in any repo layout):
WORKTREE_PATH=$(git worktree list --porcelain | awk -v b="refs/heads/$BRANCH" '/^worktree/{p=$2} $0=="branch "b{print p}')
[ -n "$WORKTREE_PATH" ] && git worktree remove "$WORKTREE_PATH" || true
Delete the local branch ref (safe no-op if absent):
git branch -d "$BRANCH" || true
git switch <BASE_BRANCH>
git pull origin <BASE_BRANCH>
git worktree prune
Invoke at any time — auto-finalizes if needed:
/merge-pr # Current branch PR, merge commit
/merge-pr 42 # Specific PR number, merge commit
/merge-pr 42 --squash # Specific PR number, squash merge
/merge-pr -s # Current branch PR, squash merge
promote/<version> → main promotion path; calls this skill directly and never squashesWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub jacobpevans-ai/claude-code-plugins --plugin github-workflows18 skills in this plugin
/finalize-prAutomatically finalize pull requests for merge by resolving CodeQL violations, PR feedback, merge conflicts, and CI failures. Handles single PR (current branch or by number), all open PRs in the repo, or all open PRs across the org. Includes bot-authored PRs in all modes./gh-cli-patternsCanonical reference for all gh CLI command shapes used by skills in this plugin. Defines the placeholder convention, default-branch (trunk vs git-flow) detection, allowed --json fields, GraphQL fallback rules, -f/-F/--raw-field flag semantics, the PR-readiness gate, required status contexts, the feedback ledger, code-scanning alert query, review-thread fetch/count/resolve mutations, and heredoc bodies. Prevents Unknown JSON field errors and divergent query shapes./