/pr-shepherd
Monitor a PR through to merge — handle CI failures, review comments, and thread resolution automatically until all checks pass
Claude Code
$ npx -y skills add dsifry/metaswarm --skill pr-shepherd --agent claude-code
Codex
$ npx skills add dsifry/metaswarm --skill pr-shepherd -a codex -y
Cursor
$ npx skills add dsifry/metaswarm --skill pr-shepherd -a cursor -y
Gemini CLI
$ npx skills add dsifry/metaswarm --skill pr-shepherd -a gemini-cli -y
GitHub Copilot
$ npx skills add dsifry/metaswarm --skill pr-shepherd -a github-copilot -y
OpenCode
$ npx skills add dsifry/metaswarm --skill pr-shepherd -a opencode -y
Windsurf
$ npx skills add dsifry/metaswarm --skill pr-shepherd -a windsurf -y
SKILL.md
pr-shepherd.SKILL.mdname: 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
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
A self-improving multi-agent orchestration framework for Claude Code, Gemini CLI, and Codex CLI.
Other skills on metaswarm.
More skills from other plugins.
agentmail
Use your assigned AgentMail inbox to read email tasks, explicitly send or reply, and check delivery. Provided automatically by…
adr-create
Create a new Architecture Decision Record with sequential numbering and AgentDB registration
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.

