merge-gh-pr

Merges GitHub pull requests via gh CLI with pre-merge validation and artifact recording.

1|1|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/williamthorsen/codeassembly --skill merge-gh-pr-williamthorsen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: merge-gh-pr
Source: https://github.com/williamthorsen/codeassembly/tree/main/packages/agents/content/skills/merge-gh-pr
Command: npx skills add https://github.com/williamthorsen/codeassembly --skill merge-gh-pr-williamthorsen

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Merging a pull request safely requires checking its state, reviews, conflicts, and branch sync before executing, then recording what happened. This Skill automates that guarded merge flow through the GitHub CLI so merges fail closed instead of landing broken or unreviewed code. ## Core Features & Use Cases - Pre-merge validation: Refuses to merge when the PR is closed, draft, conflicting, blocked, or has unresolved review requirements, failing closed when state cannot be determined. - Strategy-aware merging: Maps squash, merge, and rebase strategies to the correct gh pr merge flags, verifies the merge-commit body file before publishing, and handles branch deletion per the requested deletion strategy. - Merge artifact recording: Captures the merge commit SHA, URL, and timestamp, then saves a structured merge artifact into the ticket directory for traceability. - Use Case: An orchestrating workflow calls this delegate with a fully-resolved PR number, title, body, and strategy; it validates PR #42 is open and approved, squash-merges it with the approved commit message, deletes the remote branch, and writes a merge record to the ticket directory. ## Quick Start Ask the agent to merge pull request 42 on GitHub using the squash strategy with the prepared title and body, then save the merge artifact to the ticket directory.

Frequently Asked Questions about merge-gh-pr

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I merge a GitHub pull request from the command line?

Use `gh pr merge` with a strategy flag such as `--squash`, `--merge`, or `--rebase`. This Skill wraps that command with validation of PR state, review status, and branch sync before executing the merge.

How to squash merge a PR with a custom commit message using gh?

Pass `--subject` for the title and `--body-file` pointing to a file containing the body with `gh pr merge --squash`. The body is written to a scratch file and read back for verification before the merge runs.

Why does gh pr merge fail on a blocked or draft pull request?

GitHub refuses merges when the PR is draft, has conflicts, is blocked by failing checks, or has unresolved review requirements. This Skill detects each condition up front and refuses with a specific reason instead of attempting the merge.

Can I delete only the remote branch after merging a PR?

Yes, a remote-only deletion strategy calls the GitHub refs API to delete the head branch after merging, targeting the fork's repository for cross-repository PRs. A failed deletion emits a warning without failing the completed merge.

What happens when the PR merge state cannot be determined?

The Skill fails closed: when required fields from `gh pr view` are missing or null, it refuses the merge and asks for manual verification rather than proceeding on inconclusive state.