git-pr-merge
Skill0 starsChanged 7 days agoMITView on GitHub
Push the current branch, create a GitHub Pull Request with auto-generated title and body, run a structured review of the diff, wait for CI checks, and squash-merge with explicit user confirmation. Use when the user asks to "open a PR", "create a pull request and merge", "ship this branch", "merge this branch into main", or wants the full push-to-merge workflow. Uses the `gh` CLI; squash-merges by default; never merges without explicit user "yes"; deletes the source branch and switches back to the base branch after merge. Third step of the git-conflict-review → git-conflict-resolve → git-pr-merge workflow; safe to run standalone if the branch is already conflict-free.
- Reads credentials
- Deletes or force-pushes
- Commits and pushes
In this repository6 other files it gives its agents.
- ahmed-humanizerSkill
- directSkill
- git-conflict-resolveSkill
- git-conflict-reviewSkill
- pr-guardSkill
- sql-server-dbaSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
24 rules. About 0 are common, 18 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈18
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
After running git-conflict-resolve and the merge commit (or rebased branch) is local and clean
- Distinctive: line 24
Default merge strategy is squash: Only switch if the user names a different strategy in this turn.
- Distinctive: line 42
If any of these fail, stop and tell the user what's missing.
- Very specific: line 62
No new files that look like secrets (.env, *.pem, id_rsa, *.key, credentials.json)
- Distinctive: line 63
No accidentally committed binaries >5 MB
- Very specific: line 64
No conflict markers (<<<<<<<, =======, >>>>>>>) left in tracked files
- Distinctive: line 69
If any check fails, surface the failure and ask the user whether to abort or proceed anyway.
- Distinctive: line 73
If the branch is not on the remote, or local is ahead of remote:
- Distinctive: line 79
If remote is ahead (someone else pushed) — stop and tell the user.
- Distinctive: line 83
Look at commits on the branch since the merge base:
- Distinctive: line 107
If "edit", let the user dictate changes and re-show.
- Very specific: line 124
If a PR already exists for <source> → <base>, skip creation and use the existing PR:
- Distinctive: line 146
Do not auto-approve. Ask the user:
- Distinctive: line 155
If CI is green → continue.
- Distinctive: line 157
If CI is failing → surface the failing job log:
- Distinctive: line 164
If CI is not configured → tell the user explicitly and ask whether to proceed without CI signal.
- Distinctive: line 168
Before merging, fetch the PR's current state:
- Very specific: line 179
If reviewDecision is CHANGES_REQUESTED → refuse to merge.
- Distinctive: line 181
Ask the user explicitly:
- Distinctive: line 184
Do not proceed without a clear "yes".
- Distinctive: line 196
After a successful merge:
- Very specific: line 215
PR already merged: If gh pr view --json state returns MERGED, tell the user, skip Steps 5–9, and just run Step 10 to sync local.
- Distinctive: line 216
PR already closed without merge: Ask whether to reopen or open a new PR.
- Very specific: line 217
Force-push needed mid-flow: If the safety check finds a problem and the user fixes it by amending the last commit, prefer git push …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Git PR Merge
Overview
Takes a clean local branch from "ready to ship" to "merged on main". The skill pushes, creates a PR, reviews the diff for common issues, waits for CI, and squash-merges — with explicit user approval at every state-changing step.
When to Use
- "Open a PR for this branch"
- "Push this and create a pull request, then merge it"
- "Ship this branch"
- After running git-conflict-resolve and the merge commit (or rebased branch) is local and clean
Non-Negotiable Rules
- Never merge without explicit user "yes" / "merge it" / "approved" after the diff review.
- Never force-push to
main/master, regardless of how the user phrases the request. If the user asks for it, refuse and explain why. - Never force-push at all unless the user explicitly types
forceor--force-with-lease. Prefer--force-with-leaseover plain--force. - Default merge strategy is squash. Only switch if the user names a different strategy in this turn.
- Never skip CI unless the user explicitly says so. If CI is failing or pending, surface the state and ask.
- Never delete branches other than the just-merged source branch, and only after confirming the merge succeeded.
- Never commit while inside this skill — committing is the resolve-skill's job. If there are uncommitted changes, refuse and tell the user.
Prerequisites
Before starting, verify:
git status --porcelain # must be empty
git rev-parse --abbrev-ref HEAD # source branch
git rev-parse --abbrev-ref origin/HEAD # base branch (usually main)
gh --version # gh CLI present
gh auth status # authenticated
git remote -v | grep -i github # repo lives on GitHubIf any of these fail, stop and tell the user what's missing.
Workflow
Step 1 — Establish Source and Base
<source>= current branch (must not bemain/master).<base>=mainif it exists on the remote, elsemaster, else ask.- Fail loudly if
<source> == <base>— there is nothing to PR.
Step 2 — Run the Safety Check Script
bash <skill-dir>/scripts/pr_safety_check.sh <base>This script runs read-only checks and prints a structured pre-flight report:
- Working tree clean
- Branch ahead of base by ≥1 commit
- No new files that look like secrets (
.env,*.pem,id_rsa,*.key,credentials.json) - No accidentally committed binaries >5 MB
- No conflict markers (
<<<<<<<,=======,>>>>>>>) left in tracked files - No
console.log/dd(/var_dump(/dump(/print_r(in diff - No
.only/.skip/xfailleft in test files - Commits are signed off if the repo policy requires it (check
.github/CODEOWNERSfor hints)
If any check fails, surface the failure and ask the user whether to abort or proceed anyway.
Step 3 — Push the Branch
If the branch is not on the remote, or local is ahead of remote:
git push -u origin <source>If remote is ahead (someone else pushed) — stop and tell the user. Do not auto-pull/rebase here; that's the conflict-resolve skill's job.
Step 4 — Compose PR Title and Body
Look at commits on the branch since the merge base:
git log --pretty=format:'%s%n%n%b' "$(git merge-base <source> origin/<base>)..HEAD"Compose:
- Title — short, imperative, under 70 chars. If there's a single commit, reuse its subject. Otherwise summarize the theme.
- Body — three sections (omit any that don't apply):
## Summary - <1-3 bullets describing what changed and why> ## Changes - <key file groups touched> ## Test plan - [ ] <how to verify each change>
Show the proposed title and body to the user. Ask:
"Open the PR with this title and body? (yes / edit / abort)"
If "edit", let the user dictate changes and re-show. If "abort", stop without pushing further state.
Step 5 — Create the PR
gh pr create \
--base <base> \
--head <source> \
--title "<title>" \
--body "$(cat <<'EOF'
<body>
EOF
)"Capture the returned PR URL and number for later steps.
If a PR already exists for <source> → <base>, skip creation and use the existing PR:
gh pr view --json number,url,stateStep 6 — Review the Diff
Pull the diff and produce a structured review the user can scan in 30 seconds:
gh pr diff <number>
gh pr view <number> --json files,additions,deletions,commits,statusCheckRollupProduce a single Markdown report with:
- File-count and lines-changed totals
- A list of files grouped by area (backend, frontend, db, tests, docs)
- Risk flags (re-using the severity heuristics from git-conflict-review)
- 3–8 bullets of "what changed" derived from the diff (not the commit messages)
- "Things to double-check before merging" — bullets surfaced from the safety check + diff scan
Do not auto-approve. Ask the user:
"Diff review done. Approve and proceed to wait for CI? (yes / request changes / abort)"
Step 7 — Wait for CI
gh pr checks <number> --watch --interval 30If CI is green → continue.
If CI is failing → surface the failing job log:
gh run view <run-id> --log-failedThen ask:
"CI is failing on
<job>. Investigate, retry, or abort? (do not merge with red CI unless the user explicitly overrides.)"
If CI is not configured → tell the user explicitly and ask whether to proceed without CI signal.
Step 8 — Final Merge Approval
Before merging, fetch the PR's current state:
gh pr view <number> --json state,mergeable,mergeStateStatus,reviewDecisionSurface:
state— should beOPENmergeable— should beMERGEABLEmergeStateStatus— should beCLEANreviewDecision—APPROVED/REVIEW_REQUIRED/CHANGES_REQUESTED/ null
If reviewDecision is CHANGES_REQUESTED → refuse to merge. Ask the user to address comments first.
Ask the user explicitly:
"Ready to squash-merge PR #
<number>into<base>and delete the source branch<source>? (yes / no)"
Do not proceed without a clear "yes".
Step 9 — Squash-Merge
gh pr merge <number> --squash --delete-branch(Other strategies, only if the user names one: --merge for a true merge commit, --rebase for rebase-and-merge. Never substitute on your own.)
Step 10 — Sync Local
After a successful merge:
git switch <base>
git pull --ff-only
git remote prune origin
git branch -d <source> # safe-delete; refuses if local has unmerged workShow the user:
- New tip of
<base> - Confirmation the source branch is gone locally and remotely
- The merged PR URL for their records
End with one sentence: "Merged PR #<n>; local <base> is up to date. Branch <source> has been deleted."
Edge Cases
- Detached HEAD: Refuse, tell the user to switch to a named branch.
- PR already merged: If
gh pr view --json statereturnsMERGED, tell the user, skip Steps 5–9, and just run Step 10 to sync local. - PR already closed without merge: Ask whether to reopen or open a new PR.
- Force-push needed mid-flow: If the safety check finds a problem and the user fixes it by amending the last commit, prefer
git push --force-with-lease origin <source>over--force. Require user approval. - No
ghCLI installed: Fall back to printing the PR URL the user can open manually (e.g.https://github.com/<owner>/<repo>/compare/<base>...<source>), and stop there — do not attempt to API-call directly. - Repo is not on GitHub: This skill only supports GitHub. Tell the user.
gh auth statusnot authenticated: Tell the user to rungh auth loginand re-invoke.- Branch protection rejects squash-merge: Surface the GitHub error verbatim, do not retry blindly.
What This Skill Does NOT Do
- Does not resolve conflicts (→ git-conflict-resolve).
- Does not start a merge or rebase locally — only handles the PR side.
- Does not modify code or test files; if the safety check finds issues, it surfaces them and asks the user to fix.
- Does not add Co-Authored-By or signature trailers unless the user explicitly asks.
- Does not auto-approve reviews or dismiss other reviewers' change requests.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

