Get the FREE Ultimate OpenClaw Setup Guide →

gh-pr-merge

npx machina-cli add skill dceoy/github-cli-agent-skills/gh-pr-merge --openclaw
Files (1)
SKILL.md
1.2 KB

GitHub PR Merge

When to use

  • The user asks to merge an approved PR.
  • You need to enable auto-merge.

Inputs to confirm

  • PR number/URL/branch (or use current branch PR).
  • Merge strategy: --merge, --squash, or --rebase.
  • Whether to delete the branch, use auto-merge, or use admin override.

Workflow

  1. Verify auth and PR status:
    gh --version
    gh auth status
    gh pr view 123
    
  2. Merge:
    gh pr merge 123 --squash
    gh pr merge 123 --merge --delete-branch
    
  3. Enable auto-merge if required checks are pending:
    gh pr merge 123 --auto --squash
    

Examples

# Squash merge and delete branch
~ gh pr merge 123 --squash --delete-branch

Notes

  • If a merge queue is required, gh pr merge will use it automatically.
  • Use --admin only when you have permission to bypass requirements.

References

Source

git clone https://github.com/dceoy/github-cli-agent-skills/blob/main/skills/gh-pr-merge/SKILL.mdView on GitHub

Overview

gh-pr-merge enables merging GitHub pull requests via the gh CLI using merge, squash, or rebase strategies. It supports optional auto-merge and guides you through PR identification, strategy selection, and post-merge options like branch deletion. This helps enforce consistent merge practices and speeds up PR completion.

How This Skill Works

The skill runs gh pr merge with the chosen flags (--merge, --squash, or --rebase) and optional --auto and --delete-branch. It accepts PRs by number, URL, or branch (or uses the current branch PR if available), then verifies authentication and PR status before executing the merge.

When to Use It

  • When a user asks to merge an approved PR
  • When you need to enable auto-merge after pre-checks pass
  • When you want a specific history shape using --squash or --rebase
  • When you want to delete the branch after merging
  • When you must bypass requirements with --admin (if you have permission)

Quick Start

  1. Step 1: Confirm PR details (number/URL/branch) or use the current branch PR
  2. Step 2: Choose a strategy and optional flags (--delete-branch, --auto, --admin)
  3. Step 3: Run gh pr merge <PR> with the chosen flags

Best Practices

  • Confirm the PR is approved and related checks are satisfied before merging
  • Choose a merge strategy that matches repo policy (merge, squash, or rebase)
  • Consider enabling auto-merge only after checks are green and policy allows it
  • Decide on deleting the branch after merge to keep branches clean
  • Use --admin only if you have permission to bypass requirements

Example Use Cases

  • Squash-merge PR 123 and delete the branch
  • gh pr merge 123 --squash --delete-branch
  • Merge PR 456 with a standard --merge
  • gh pr merge 456 --merge
  • Auto-merge PR 789 after checks pass
  • gh pr merge 789 --auto --squash
  • Rebase PR 101 for linear history
  • gh pr merge 101 --rebase

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers