dsifry/metaswarm/pr-shepherd
Claude Code and agent skill by dsifry/metaswarm
- community
Checking that the SKILL.md file is still in the repository.
Monitor a PR through to merge — handle CI failures, review comments, and thread resolution automatically until all checks pass
Install
npx vskill@latest install dsifry/metaswarm/pr-shepherdSKILL.md
The same SKILL.md was published earlier as dsifry/metaswarm/pr-shepherd.
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 typeroleType("pr-shepherd-agent")) withrun_in_background: true. Orchestrator checks viaTaskOutput(block: false). - Team Mode: Runs as a persistent
shepherdteammate (typeroleType("pr-shepherd-agent")) in theissue-{number}team. Sends async status updates viaSendMessage(CI failure, review comments, all-green, PR merged). Orchestrator can respond with instructions (e.g., "defer that comment, create an issue instead"). Responds toshutdown_requestfor 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.
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), include PR shepherding in the task prompt:
Key principle: The shepherd owns the PR lifecycle, but the PR's original coder does not own its fixes. The shepherd monitors CI, review comments and threads. When something needs a code change (a CI failure or an actionable review comment), it spawns a fresh coder of the tier the rubric picks (the coder selection rubric, guides/coder-selection.md) with a fix brief, and never asks the coder that wrote the PR. The fix brief contains:
- the comment or failure verbatim, with file:line;
- the PR head SHA;
- the contract pointers (spec, plan or work-unit files);
- the validation commands.
The shepherd then verifies the result, pushes, and resolves threads per the handling-pr-comments skill. Trivial reply-only or doc fixes can stay with the shepherd. The orchestrator spawns the shepherd and checks back via AgentOutputTool when needed.
State Machine
The agent operates in one of these states:
| 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 a decision request; only the blocked failure waits, monitoring and review handling continue | User responds | |
DONE | All CI green + all threads resolved | Exit successfully |
Phase 1: Initialize
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.
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 tells you what's blocking. After addressing feedback, you must resolve threads yourself using the GraphQL mutation in handle-pr-comments.md (Section 3). GTG will report READY on the next poll once threads are resolved.
Evaluate State Transitions
Fallback: Manual Checks
If GTG is unavailable (e.g., not installed in environment), fall back to manual queries:
Re-triggering GTG CI Check
When threads are resolved but the Merge Ready (gtg) GitHub Actions check is stale:
Phase 3: Fixing Issues
Simple Issues (Auto-fix)
These can be fixed without user approval:
- Lint failures → run linter
- Prettier failures → run formatter
- Type errors → fix the types
- Test failures in code YOU wrote → fix using TDD
Complex Issues (Need Approval)
These require user input BEFORE fixing:
- Test failures in code you didn't write
- Infrastructure/config failures
- Ambiguous errors
- Anything you're uncertain about
FIXING State Rules
- Use TDD - Invoke
superpowers:test-driven-developmentfor code changes - Kill stale test runners - Run
pkill -f vitest 2>/dev/null || truebefore test runs - Stay until green - Don't leave FIXING until
pnpm lint && pnpm typecheck && pnpm test --run && pnpm test:coverageall pass - Only push when verified - Never push code that fails local validation or coverage thresholds
- Return to MONITORING after push - Let CI run, continue monitoring
Phase 4: Handling Reviews
When new review comments are detected:
- Invoke the
handling-pr-commentsskill - That skill handles categorization, fixes, responses, and thread resolution
- CRITICAL: The handling-pr-comments skill includes an iteration loop
- ALL threads must be resolved before returning to MONITORING
- If a thread cannot be resolved (needs clarification from reviewer), query the comment author asking for follow-up
- Return to MONITORING only when:
- All threads are resolved, AND
- Post-push verification confirms NO new comments appeared
Iteration Enforcement
THE #1 FAILURE MODE: Returning to MONITORING after one pass without checking for new comments.
The handling-pr-comments skill's Phase 7 (Post-Push Iteration Check) MUST complete successfully before exiting HANDLING_REVIEWS state. The skill will iterate automatically:
DO NOT manually override or skip Phase 7. If you find yourself tempted to skip iteration, you're about to make the #1 mistake.
Out-of-Scope Comments
Reviewers may leave comments on code outside the PR diff. The handling-pr-comments skill handles these, but key points:
- Treat out-of-scope as IN SCOPE by default - respect reviewer feedback
- Use ultrathink to evaluate if fixes are quick (< 30 min, < 3 files)
- If simple: fix immediately and note it was outside original scope
- If complex: create a GitHub issue and link it in the thread response
- Always respond and resolve - never leave out-of-scope threads hanging
Phase 5: Waiting for User
When user input is needed, ALWAYS:
- Present the situation clearly
- Offer 2-4 lettered options, each with pros and cons
- State your recommendation, with Why recommended on that option only
- Allow user to choose OR provide their own approach
Template
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/pr-shepherd/SKILL.md
Popularity
- Repository stars
- 335
- Repository forks
- 44
- Repository npm downloads, 7 days
- 25
- 7-day trend score
- 42
Stars and forks are for the whole GitHub repository, not this skill alone. Downloads are for the repository's npm package. Refreshed 18 Mar 2026, 8 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/dsifry/metaswarm/pr-shepherd)