agentleFS
clawwork-aiclawwork-ai/ClawWork/.claude/skills/pr-merge-runner/SKILL.md

pr-merge-runner

Skill533 starsChanged 5 months agoApache-2.0View on GitHub

Auto-merge PRs after pr-cleaner-master. Processes only open PRs whose last pr-cleaner verdict is merge, oldest first: post Thanks + /lgtm + /approve, wait for ci-bot squash merge, git pull origin main, skip on any blocker. Never rebase, retest, or fix CI. Always skip workflow-file PRs. Use when: "merge safe PRs", "auto merge", "ship merge rows", "pr-merge-runner", "/pr-merge-runner", after pr-cleaner when user wants hands-off landing. Chains after pr-cleaner-master; does not replace review.

The file

Show its rules and text

We split this skill into the rules it gives an agent

20 rules. About 0 are common, 6 are distinctive, and 14 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 14

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Use the loaded skill base directory as SKILL_DIR.

    line 23
  2. Very specific:

    If --repo given → use it.

    line 39
  3. Very specific:

    If neither works → error: "Not in a GitHub repo.

    line 41
  4. Very specific:

    If missing or repo mismatch → treat as {}.

    line 50
  5. Very specific:

    If --from-snapshot yields zero candidates → print No merge-verdict PRs in snapshot.

    line 56
  6. Distinctive:

    Do not attempt any fix.

    line 84
  7. Very specific:

    Never gh pr update-branch, rebase, merge main into PR, or /rebase.

    line 109
  8. Very specific:

    Never /retest, fix CI, or push commits to the PR branch.

    line 110
  9. Very specific:

    Never gh pr merge, gh pr review --approve, or close PRs.

    line 111
  10. Very specific:

    Never post /merge as a fallback (comment body is fixed.

    line 112
  11. Distinctive:

    Do not post again on timeout.

    line 149
  12. Very specific:

    Run from the current git workspace root.

    line 157
  13. Very specific:

    After the run, update pr-cleaner-state.json for every candidate seen:

    line 201
  14. Distinctive:

    Never fix, rebase, retest, or manually merge.

    line 231
  15. Very specific:

    Never merge PRs not marked merge in snapshot (unless --fresh).

    line 232
  16. Very specific:

    Never merge PRs that touch .github/workflows/.

    line 233
  17. Distinctive:

    Never paste code to contributors.

    line 234
  18. Distinctive:

    Never parallelize by default.

    line 235
  19. Distinctive:

    Never skip the final Merged/Skipped report.

    line 236
  20. Very specific:

    Never claim CI is green without checking statusCheckRollup.

    line 237

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PR Merge Runner

Companion to pr-cleaner-master. That skill classifies; this skill lands only rows already marked merge. The user invoking this skill is the confirmation gate — no second approval step.

This skill does not run deep review (use pr-cleaner-master or pr-eval). It does not fix code, rebase branches, retest CI, or call gh pr merge.

Use the loaded skill base directory as SKILL_DIR.

Argument Parsing

InputBehavior
no argsmerge all eligible PRs from snapshot (--from-snapshot, default on)
517 521only those PR numbers
#517 #521same
--repo owner/repotarget repo instead of current git directory
--dry-runpreflight + plan only; no comments, no pull
--freshignore snapshot verdict filter; preflight all open PRs instead
--from-snapshotdefault on; only PRs with snapshot verdict == "merge"

Resolve target repo:

  1. If --repo given → use it.
  2. Else → gh repo view --json nameWithOwner --jq .nameWithOwner.
  3. If neither works → error: "Not in a GitHub repo. Pass --repo owner/repo."

Phase 0: Load Snapshot ⛔ BLOCKING

Same path as pr-cleaner-master:

~/.claude/projects/<project-dir-slug>/pr-cleaner-state.json

  • <project-dir-slug> matches the memory-system slug for the current project root.
  • If missing or repo mismatch → treat as {}.
  • With default --from-snapshot: candidate PR numbers are keys in snapshot.prs where verdict == "merge". Still must pass live preflight (PR may have closed, CI may have regressed).
  • With --fresh: candidate set = all open non-draft PRs from batch fetch.

If --from-snapshot yields zero candidates → print No merge-verdict PRs in snapshot. Run pr-cleaner-master first. and exit.

Phase 1: Batch Fetch ⛔ BLOCKING

Fetch metadata for every candidate (and all open PRs when --fresh):

gh pr view <number> --repo <repo> --json \
  number,title,author,createdAt,headRefOid,mergeable,mergeStateStatus,\
state,isDraft,reviewDecision,labels,updatedAt,additions,deletions,changedFiles,\
statusCheckRollup,comments

Or list all open when building --fresh set:

gh pr list --repo <repo> --state open --limit 100 --json \
  number,title,author,createdAt,headRefOid,mergeable,mergeStateStatus,\
state,isDraft,reviewDecision,labels,updatedAt,additions,deletions,changedFiles,\
statusCheckRollup,comments

Sort candidates by createdAt ascending (oldest first).

Phase 2: Preflight ⛔ BLOCKING

For each candidate, first failing rule → skip (record reason, continue). Do not attempt any fix.

#ConditionSkip reason
1state != "OPEN" or isDraftnot-open
2--from-snapshot and snapshot verdict ≠ mergenot-merge-verdict
3mergeable == "CONFLICTING"conflicts
4mergeStateStatus == "BLOCKED"blocked
5statusCheckRollup has PENDING / FAILURE / CANCELLED / ERRORci-fail
6diff touches .github/workflows/** (see below)workflow-permission
—all pass→ Phase 3

Workflow-file gate (always skip)

Bot merge fails when the PR updates workflow files without workflows permission (e.g. .github/workflows/ci-bot.yml). Detect before commenting:

gh pr diff <number> --repo <repo> --name-only | rg '^\.github/workflows/'

Any match → skip with workflow-permission. Never add a bypass flag.

Hard prohibitions

  • Never gh pr update-branch, rebase, merge main into PR, or /rebase.
  • Never /retest, fix CI, or push commits to the PR branch.
  • Never gh pr merge, gh pr review --approve, or close PRs.
  • Never post /merge as a fallback (comment body is fixed; see Phase 3).

Phase 3: Execute Merge Loop ⚠️ REQUIRED

Process preflight-pass PRs one at a time (oldest first). Parallel batching is forbidden unless the user explicitly says several named PRs may run together in the same turn — default remains serial.

For each PR:

Step A — Comment (exact three lines)

gh pr comment <N> --repo <repo> --body "$(cat <<'EOF'
Thanks @<author>!
/lgtm
/approve
EOF
)"

Replace <author> with author.login. No other text. No code blocks.

Skip Step A in --dry-run (log the would-be body instead).

Step B — Wait for merge

Poll every 10 seconds, up to 36 attempts (~6 minutes):

gh pr view <N> --repo <repo> --json state,mergedAt --jq '.state'
  • MERGED → Step C.
  • Still OPEN after 36 polls → skip timeout, next PR.
  • CLOSED without merge → skip not-open, next PR.

Do not post again on timeout.

Step C — Sync local main

git pull origin main

Run from the current git workspace root. Skip in --dry-run.

Step D — Record

Append to in-memory results: { number, title, author, mergedAt }.

Then continue to the next PR.

Phase 4: Report ⚠️ REQUIRED

## PR Merge Runner — <repo>  (<UTC timestamp>)

### Merged (N)

| PR | Author | Title |
|---|---|---|
| #517 | @alice | fix: … |

### Skipped (M)

| PR | Reason | Note |
|---|---|---|
| #520 | workflow-permission | touches .github/workflows/ |
| #516 | ci-fail | gateway / e2e failed |

Local main: `<git rev-parse --short HEAD>` (after last pull)
Dry run: yes/no

Skip reason codes (use exactly):

CodeMeaning
ci-failCI red or pending
conflictsmergeable CONFLICTING
blockedmergeStateStatus BLOCKED
workflow-permissiondiff touches .github/workflows/**
timeoutlabels posted but not merged in 6 min
not-openclosed, merged already, or draft
not-merge-verdictsnapshot verdict ≠ merge

Phase 5: Update Snapshot

After the run, update pr-cleaner-state.json for every candidate seen:

"123": {
  "headSha": "...",
  "comments": 4,
  "verdict": "merge",
  "mergeResult": "merged",
  "skipReason": null,
  "at": "2026-06-10T18:00:00Z"
}
  • mergeResult: "merged" | "skipped" | "dry-run"
  • skipReason: null when merged; otherwise the code above.

Atomic write: <path>.tmp then rename. Same repo key as pr-cleaner.

Chaining With pr-cleaner-master

Typical maintainer flow:

  1. /pr-cleaner-master — classify, user reviews Action table.
  2. /pr-merge-runner — land every snapshot merge row that still passes preflight.

pr-cleaner-master never merges; this skill never re-classifies.

Do Not

  • Never fix, rebase, retest, or manually merge.
  • Never merge PRs not marked merge in snapshot (unless --fresh).
  • Never merge PRs that touch .github/workflows/**.
  • Never paste code to contributors.
  • Never parallelize by default.
  • Never skip the final Merged/Skipped report.
  • Never claim CI is green without checking statusCheckRollup.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.