gh-pr-merge
npx machina-cli add skill dceoy/github-cli-agent-skills/gh-pr-merge --openclawFiles (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
- Verify auth and PR status:
gh --version gh auth status gh pr view 123 - Merge:
gh pr merge 123 --squash gh pr merge 123 --merge --delete-branch - 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 mergewill use it automatically. - Use
--adminonly when you have permission to bypass requirements.
References
- GitHub CLI manual: https://cli.github.com/manual/
gh pr merge --help
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
- Step 1: Confirm PR details (number/URL/branch) or use the current branch PR
- Step 2: Choose a strategy and optional flags (--delete-branch, --auto, --admin)
- 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