pr-shepherd

Automates GitHub pull request lifecycle from mergeable checks through merge-queue enqueue and worktree teardown.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/Sassy-Dog/sassydog-skills --skill pr-shepherd-sassy-dog
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pr-shepherd
Source: https://github.com/Sassy-Dog/sassydog-skills/tree/main/skills/pr-shepherd
Command: npx skills add https://github.com/Sassy-Dog/sassydog-skills --skill pr-shepherd-sassy-dog

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Shepherding pull requests from "opened" to "merged and cleaned up" involves fragile manual steps: detecting merge conflicts that silently block CI, distinguishing real failures from GitHub platform degradation, navigating merge-queue vs direct-merge regimes, handling stacked PRs, and tearing down worktrees afterward. This Skill encodes those mechanics as deterministic scripts so nothing is merged past red checks, stale bases, or open lower stack layers. ## Core Features & Use Cases - Mergeable and stack gating: Detects CONFLICTING PRs before watching CI, probes stacked-PR membership, and refuses to merge a layer whose lower layers are still open. - Check polling and queue watching: Polls one or many PRs until checks are terminal, then watches merge-queue state with eject-aware disambiguation via RemovedFromMergeQueueEvent. - Stateless merge writer: merge-shepherd.sh advances one PR through gating, GraphQL enqueuePullRequest (or direct squash merge), staleness checks, and teardown as an idempotent, re-runnable step with distinct exit codes. - Platform degradation probe: Distinguishes a real CI failure from a GitHub outage by comparing workflow runs across heads and attributing against the status page, returning one of four verdicts that never gate a merge. - Use Case: After a batch of parallel sub-agents opens five PRs, run the poller to watch checks, let merge-shepherd.sh enqueue the green ones, and finish with teardown.sh to remove worktrees and reconcile the default branch. ## Quick Start Ask the agent to watch PR #123 in this repository and merge it once all checks are green, then clean up the worktree.

Frequently Asked Questions about pr-shepherd

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

FAQPage Schema
How do I auto-merge a GitHub PR when checks pass?

Use merge-shepherd.sh with the PR number and repo; it gates on green checks, MERGEABLE and CLEAN state, then enqueues via the GraphQL enqueuePullRequest mutation or squash-merges directly with --direct. It is stateless and idempotent, so re-running it after an interruption safely resumes the step.

How do I enqueue a PR to a GitHub merge queue with gh CLI?

The reliable path is the GraphQL enqueuePullRequest mutation with the PR node id, because some queue configurations reject every gh pr merge flag including --auto. If using the CLI fallback, pass --auto with no method flag and no --delete-branch, then confirm isInMergeQueue via GraphQL.

Why does my PR show no checks reported on GitHub?

A CONFLICTING mergeable state silently blocks CI from firing, and an empty statusCheckRollup also occurs when the base branch has no required checks, such as an intermediate stacked PR. Check mergeable and mergeStateStatus first, and verify the rollup is non-empty before trusting a CLEAN state.

Can this skill merge stacked pull requests?

It detects stack membership with stack-probe.sh using both the REST stacks endpoint and GraphQL, and blocks merging any layer with open lower layers (exit 23). Stacks merge bottom-up one layer per run; a stack under a merge queue is refused and surfaced for a human decision.

How do I tell a GitHub outage apart from a real CI failure?

Run probe-platform-health.sh, which compares workflow runs across prior heads of the branch and checks the status page scoped to check-relevant components. It returns healthy, degraded (attributed), degraded (unattributed), or unknown, and every verdict exits 0 so it never gates a merge decision.

What are the limitations of the merge automation?

It never auto-rebases CONFLICTING PRs, never decides what to merge, and the stateless writer cannot distinguish a queue eject from never-enqueued, so repeated ejects need manual rebase and regeneration. The platform probe also cannot emit healthy on branches with 100 or more head-triggered runs due to pagination.