Skip to content
Agent Orchestration
Skill

/pr-shepherd

Monitor a PR through to merge — handle CI failures, review comments, and thread resolution automatically until all checks pass

From plugin
metaswarm
43714 skills23 agents16 commands2 hooks

Claude Code

$ npx -y skills add dsifry/metaswarm --skill pr-shepherd --agent claude-code

SKILL.md

pr-shepherd.SKILL.md
name: pr-shepherd
description: Monitor a PR through to merge — handle CI failures, review comments, and thread resolution automatically until all checks pass

pr-shepherd

Use when a PR has been created and needs to be monitored through to merge - handles CI failures, review comments, and thread resolution automatically until all checks pass and all threads are resolved.

**IMPORTANT**: This skill is designed for the **agent working in a worktree**, NOT the orchestrator. The agent handles its own PR monitoring so the orchestrator remains free for other work.

Coordination Mode Note

This skill supports both coordination modes:

  • **Task Mode** (default): Runs as a single long-running `Task()` (role type `roleType("pr-shepherd-agent")`) with `run_in_background: true`. Orchestrator checks via `TaskOutput(block: false)`.
  • **Team Mode**: Runs as a persistent `shepherd` teammate (type `roleType("pr-shepherd-agent")`) in the `issue-{number}` team. Sends async status updates via `SendMessage` (CI failure, review comments, all-green, PR merged). Orchestrator can respond with instructions (e.g., "defer that comment, create an issue instead"). Responds to `shutdown_request` for graceful exit.

All monitoring, fixing, and review handling logic is identical in both modes. See `./guides/agent-coordination.md` for mode detection and [Role type resolution](./guides/agent-coordination.md#role-type-resolution).

---

When to Activate

Activate this skill when ANY of these conditions are true:

  • Agent just created a PR with `gh pr create`
  • User asks to "shepherd", "monitor", or "see through" a PR
  • User invokes `/pr-shepherd <pr-number>`
  • User asks to "watch this PR" or "handle this PR until it's merged"
  • Orchestrator spawned you with instructions to shepherd a PR

Starting Right After PR Creation

After `gh pr create`, take the PR number from the URL it prints (or `gh pr view --json number -q .number`) and **immediately invoke the pr-shepherd skill** with it: `/pr-shepherd <pr-number>`.

Announce at Start

"I'm using the pr-shepherd skill to monitor this PR through to merge. I'll watch CI/CD, handle review comments, and fix issues as they arise."

For Orchestrators: Spawning Agents with PR Shepherding

When spawning an agent to work in a worktree (role type `roleType("coder")`, see [Role type resolution](./guides/agent-coordination.md#role-type-resolution)), include PR shepherding in the task prompt:

Work in worktree at /path/to/worktree on branch feature/xyz.

Task: [describe the implementation task]

After creating the PR:
1. Use the pr-shepherd skill to monitor it through to merge
2. Handle CI failures and review comments autonomously
3. Only escalate to orchestrator for complex issues requiring user input
4. Report back when PR is ready to merge or if blocked

Run in background so I can continue other work.

**Key principle**: The agent owns its PR lifecycle. The orchestrator spawns and forgets, checking back via `AgentOutputTool` when needed.

State Machine

The agent operates in one of these states:

MONITORING → FIXING → MONITORING → WAITING_FOR_USER → FIXING → MONITORING → DONE

| State | What Happens | Exit When | | ------------------ | ------------------------------------------- | ---------------------------------------------- | | `MONITORING` | Poll CI and reviews every 60s in background | CI fails, new comments, all done, or need help | | `FIXING` | Fix issues using TDD, run local validation | Local validation passes OR need user guidance | | `HANDLING_REVIEWS` | Invoke `handling-pr-comments` skill | Comments handled OR need user input | | `WAITING_FOR_USER` | Present options, wait for user decision | User responds | | `DONE` | All CI green + all threads resolved | Exit successfully |

Phase 1: Initialize

# Get PR info
PR_NUMBER=$(gh pr view --json number -q .number 2>/dev/null)
OWNER=$(gh repo view --json owner -q .owner.login)
REPO=$(gh repo view --json name -q .name)

# If no PR on current branch, check if number was provided
if [ -z "$PR_NUMBER" ]; then
  echo "No PR found for current branch. Provide PR number."
  exit 1
fi

echo "Shepherding PR #$PR_NUMBER"

Phase 2: Monitoring Loop (Background)

Run GTG every 60 seconds as the **single source of truth** for PR readiness:

Primary Check: GTG (Good-To-Go)

GTG consolidates CI status, comment classification, and thread resolution into one call. Use it instead of separate API queries.

# Primary readiness check — structured JSON output
GTG_RESULT=$(gtg $PR_NUMBER --repo "$OWNER/$REPO" --format json \
  --exclude-checks "Merge Ready (gtg)" \
  --exclude-checks "CodeRabbit" \
  --exclude-checks "Cursor Bugbot" \
  --exclude-checks "claude" 2>&1)

STATUS=$(echo "$GTG_RESULT" | jq -r '.status')
ACTION_ITEMS=$(echo "$GTG_RESULT" | jq -r '.action_items[]?' 2>/dev/null)
CI_STATE=$(echo "$GTG_RESULT" | jq -r '.ci_status.state')

**GTG statuses:**

| Status | Meaning | Agent Action | | -------------------- | ---------------------------------- | ----------------------------------------- | | `READY` | All CI green, all threads resolved | → DONE | | `ACTION_REQUIRED` | Actionable comments need fixes | → HANDLING_REVIEWS (use `action_items`) | | `UNRESOLVED_THREADS` | Review threads still open | → HANDLING_REVIEWS | | `CI_FAILING` | One or more CI checks failing | → FIXING | | `ERROR` | Couldn't fetch PR data | Retry after 60s, escalate after 3 retries |

**GTG reports, agents act**: GTG does not resolve threads or fix code — it only t

Read more
@dsifry
Ships withmetaswarm

A self-improving multi-agent orchestration framework for Claude Code, Gemini CLI, and Codex CLI.

43714 skills23 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
437
Star history of dsifry/metaswarm on GitHub, a chart by star-history.com

Other skills on metaswarm.

brainstorming-extension

brainstorming-extensio…

Loads the assumption ledger and misreadings checklist at the start of brainstorming, and enforces the design review gate when a…

@dsifry@dsifryInstall Skill
create-issue

create-issue

Create comprehensive GitHub issues with TDD plans, acceptance criteria, and agent instructions for autonomous PR lifecycle…

@dsifry@dsifryInstall Skill
design-review-gate

design-review-gate

Automatic review gate that runs when brainstorming commits a project-sized design doc - spawns PM, Architect, Designer, Security,…

@dsifry@dsifryInstall Skill
external-tools

external-tools

Delegate implementation and review tasks to external AI CLI tools (Codex, Gemini) with cross-model adversarial review

@dsifry@dsifryInstall Skill
handling-pr-comments

handling-pr-comments

Address PR review feedback systematically — fetch inline comments, review bodies, handle outside-diff-range comments, resolve…

@dsifry@dsifryInstall Skill
handoff

handoff

Analyze the current session and write a self-contained handoff document so a fresh agent can resume the work with full context —…

@dsifry@dsifryInstall Skill

More skills from other plugins.

1password

1password

Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.

openclaw8d395k
@steipete@steipeteInstall Skill
jira-tickets

jira-tickets

Read and update Jira tickets through Orca's saved Jira connections. Use when a task comes from Jira or the user asks for Jira…

orca6d128k
@stablyai@stablyaiInstall Skill
agentmail

agentmail

Use your assigned AgentMail inbox to read email tasks, explicitly send or reply, and check delivery. Provided automatically by…

paperclip6d114k
@paperclipai@paperclipaiInstall Skill
adr-create

adr-create

Create a new Architecture Decision Record with sequential numbering and AgentDB registration

@ruvnet@ruvnetInstall Skill

Questions about pr-shepherd.

Which coding agents can use pr-shepherd?
pr-shepherd installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.