ankraio/agent-tools/pr-shepherd

Claude Code and agent skill by ankraio/agent-tools

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Drive a just-created or just-updated PR to ready-for-review, and merge it when it is safe to. Use IMMEDIATELY after creating a PR (gh pr create) or after pushing new commits to an open PR in any {{GITHUB_ORG}} repo. Watches CI to green, resolves merge conflicts, addresses every finding from the automated reviewer ({{REVIEW_BOT_LOGIN}}) by fixing it or replying why not, un-drafts the PR early (because the reviewer skips drafts), and merges by default once everything is green. Only genuinely risk…

Install

npx vskill@latest install ankraio/agent-tools/pr-shepherd

SKILL.md

The same SKILL.md was published earlier as ankraio/agent-tools/pr-shepherd.

PR shepherd

Configure before first use. Every {{PLACEHOLDER}} below is a decision for
your team. Fill them in, delete the sections that do not apply (there is a
per-section note where a whole step is optional), then run
grep -nE '\{\{[A-Z][A-Z_]*\**\}\}' SKILL.md and confirm nothing is left. The
installer runs the same check. A skill with live placeholders sends the agent
chasing comment markers and commands that do not exist.

0. Configuration

PlaceholderWhat it isExample
{{GITHUB_ORG}}GitHub org or user that owns the reposacme-inc
{{REPOS}}Repos this skill covers, for the description lineapi, web, infra
{{DEFAULT_BRANCH}}Branch PRs merge intomain
{{MERGE_METHOD}}--squash, --merge or --rebase--squash
{{AUTO_MERGE}}yes to merge by default, no to always stop at ready-for-reviewyes
{{REVIEW_BOT_LOGIN}}Login of the automated reviewer, exactly as GitHub reports itclaude[bot]
{{REVIEW_MARKER}}Hidden HTML marker in the review comment body, if it has one<!-- ai:review -->
{{REVIEW_UNAVAILABLE_MARKER}}Marker the reviewer posts when it gave up, if it has one<!-- ai:review-unavailable -->
{{CI_DIAGNOSIS_MARKER}}Marker for an automated failed-workflow diagnosis, if you have one<!-- ai:actions -->
{{REVIEW_MENTION}}Mention keyword that makes the reviewer answer a reply@claude
{{REVIEW_WAIT_MINUTES}}How long to wait for a review before proceeding without one20
{{REVIEWED_COMMIT_FOOTER}}The line in the review that names the commit it readReviewed commit <sha>
{{CI_ALERT_CHANNEL}}Where default-branch CI failures are announced#ci-alerts
{{MIGRATION_DIRS}}Paths that hold DB migrationsdb/migrations/, alembic/
{{MIGRATION_MERGE_CMD}}How your migration tool resolves two heads, if it canalembic merge -m "..." <head> <head>
{{DEPLOY_REPOS}}Repos where a merge is itself a production rolloutinfra-values, gitops
{{SIZE_LIMIT_LINES}} / {{SIZE_LIMIT_FILES}}Diff size above which a human looks1500 / 50
{{LOCAL_GATE_RULE}}Any machine-local constraint on running lint or tests(delete if none)
{{TRACKER_*}}Issue tracker wiring, covered in step 6. Delete the whole block if you have none.

If you have no automated reviewer, delete step 5 and the fourth exit condition. If you have no issue tracker link step, delete "Before merging: record the PR on the issue". Everything else is tracker-agnostic and reviewer-agnostic.


Given a PR (argument: number or URL, otherwise the PR for the current branch via gh pr view --json number,url,isDraft), do not stop until ALL of these hold for the latest pushed commit:

  1. No conflicts. mergeable is MERGEABLE
  2. CI green. Every check concluded SUCCESS, SKIPPED or NEUTRAL
  3. Un-drafted. gh pr ready executed (skip if it was never a draft)
  4. Every review finding addressed. Code updated and pushed, or a reply

explaining why not

Then merge (if {{AUTO_MERGE}} is yes and the PR misses step 6's risk list), watch the default branch's own CI on the merge commit (step 7), and report (step 8). Hard limits: never push to {{DEFAULT_BRANCH}} directly, never force-push, never close the PR, and never merge a PR on the risk list. Those stop at ready-for-review for a human to merge.

Un-draft comes before the review, not after. Most automated reviewers decline draft pull requests, and the draft-to-ready transition is one of the events that starts a review. A shepherd that saves gh pr ready for last waits for a review that by construction never runs. This skill used to do exactly that.

Run gh from the PR's worktree, or pass -R {{GITHUB_ORG}}/<repo> explicitly. A checkout whose origin points somewhere other than GitHub will otherwise send every command to the wrong place.

1. Snapshot

sh
gh pr view <n> --json number,url,isDraft,mergeable,mergeStateStatus,headRefName,statusCheckRollup

Order matters: check conflicts before interpreting checks. A PR with zero check suites at all almost always means mergeable: CONFLICTING. GitHub cannot build the merge ref, so Actions never starts. Fix the conflict (step 2), do not conclude "CI is broken", and do not re-create the branch.

2. Conflicts

If mergeable is CONFLICTING (poll a few times if UNKNOWN, since GitHub computes it lazily):

  • In the PR's worktree, run git fetch origin && git merge origin/{{DEFAULT_BRANCH}},

resolve the conflicts, commit the merge, and push. Merge, never rebase. Force-push is banned and rebase requires it.

  • Migrations. If both sides added a migration under {{MIGRATION_DIRS}} you

now have two heads. Resolve with a no-op merge revision ({{MIGRATION_MERGE_CMD}}) rather than renumbering either side, and expect any schema-golden or snapshot tests to need regenerating.

  • A push resets the checks, so go back to step 1 after any push.

3. CI to green

Watch until every check concludes:

sh
gh pr checks <n> --watch --interval 30

Run it with a large timeout (10 minutes) and re-run while checks are still pending. It exits non-zero when something failed.

On failure:

  • Get the failing job's log with gh run view <run-id> --log-failed. Find the run

id in the check's detail URL or via gh run list --branch <headRefName>.

  • If you have an automated failure diagnosis, read it first. It is a separate

comment per failed run, not a finding you have to answer, so it is a free first read:

``sh gh api repos/{{GITHUB_ORG}}/<repo>/issues/<n>/comments \ --jq '.[] | select(.body | contains("{{CI_DIAGNOSIS_MARKER}}")) | {id, created_at, body}' ``

  • PR checks build the merge of the branch with `{{DEFAULT_BRANCH}}`. Before

blaming the PR, check whether plain origin/{{DEFAULT_BRANCH}} reproduces the failure, because a parallel PR may have landed a semantic conflict. If the default branch is red, fix forward only if the fix belongs in this PR. Otherwise report that it is broken and stop the loop there. Do not grind a PR against a red default branch.

  • {{LOCAL_GATE_RULE}} *(for example: "only one lint or typecheck process may run

on this machine at a time, so wait for the lock before starting, run sequentially, and never run it in the background". Delete this bullet if you have no such rule.)*

  • Fix, commit, push, then go back to step 1.

4. Un-draft

Do this as soon as the branch is pushed and free of conflicts, not at the end. It is what starts the review (step 5), and it lets the review run against the same head commit CI is already testing instead of serially after it:

sh
gh pr ready <n>

Skip it if the PR was never a draft. If CI then goes red and you push a fix, the push re-reviews on its own, so nothing is lost by having gone ready early.

5. Automated review

(Delete this whole step if you have no automated reviewer. Do not replace it with a guess. An agent that invents a review is worse than one that has none.)

{{REVIEW_BOT_LOGIN}} posts the review as an issue comment carrying the hidden marker {{REVIEW_MARKER}}. The review is advisory: it posts no check run, never submits CHANGES_REQUESTED, and never blocks CI. That is what makes bounding the wait safe.

Three terminal states, and "still running" is not one of them

A failed review turn is often retried, and some reviewers keep the intent owed and re-drive it minutes later. So there are three states to poll for, not two:

What you seeWhat it means
{{REVIEW_MARKER}} commentReviewed. Answer the findings.
{{REVIEW_UNAVAILABLE_MARKER}} commentThe reviewer gave up and said so. Record it, nothing to answer.
Neither, yetStill in flight, possibly waiting on a retry.

Bound the wait, and know what your reviewer's slow path costs. In one measured case the review turn failed when the backing service rolled mid-request, a sweep re-drove it 15 minutes later, and the verdict landed 16 minutes after the failure, onto a PR this skill had already merged on a "~10 minutes at the outside" rule. A clean PR was merged unreviewed and the review arrived on a closed PR. Hence: wait up to ~{{REVIEW_WAIT_MINUTES}} minutes from the last push, checking for both markers each poll. If you proceed without either, say exactly that in the report ("no review and no unavailable notice after N minutes, may still be in flight"), never "the review came back clean".

When it runs
  • PR opened (not a draft), draft to ready, and every push to the

branch.

  • Drafts are declined. Step 4 is the trigger for a draft-opened PR.
  • Head-SHA dedup. A commit already reviewed is not reviewed twice. Marking an

already-public PR ready without pushing produces no second review, and that is correct, because the existing review covers that commit.

Which repos have it

If the reviewer is bound per-repo (a GitHub App installation) rather than by a workflow file in the repo, it is a per-repo fact that changes as repos are connected. Probe, do not keep a list. An unreviewed PR and an unbound repo look identical from a single PR:

sh
for pr in $(gh pr list -R {{GITHUB_ORG}}/<repo> --state all --limit 5 --json number --jq '.[].number'); do
hits=$(gh api repos/{{GITHUB_ORG}}/<repo>/issues/$pr/comments \
--jq '[.[] | select(.user.login=="{{REVIEW_BOT_LOGIN}}") | select(.body | contains("{{REVIEW_MARKER}}"))] | length')
echo "<repo>#$pr reviewed=$hits"
done

The version of this skill that carried a hardcoded list of reviewed repos had it wrong within two weeks, and a shepherd that trusted the list skipped waiting for a review that was on its way.

When a repo genuinely has no reviewer, say so in the report ("no automated review posted for this PR") rather than reporting a clean review. Never invent a review that did not happen.

Collecting it

Two surfaces. The summary comment always exists, inline findings are anchored to their lines, and the second query simply returns nothing where there are none:

sh
# summary comment (one per PR, upserted in place)
gh api repos/{{GITHUB_ORG}}/<repo>/issues/<n>/comments \
--jq '.[] | select(.user.login=="{{REVIEW_BOT_LOGIN}}") | select(.body | contains("{{REVIEW_MARKER}}")) | {id, updated_at, body}'
# inline findings pinned to lines
gh api repos/{{GITHUB_ORG}}/<repo>/pulls/<n>/comments \
--jq '.[] | select(.user.login=="{{REVIEW_BOT_LOGIN}}") | {id, path, line, body}'

The summary comment is edited in place, not reposted. There is exactly one per PR and a re-review PATCHes it, so polling for a new comment after a push waits forever. Re-fetch the same id and read the footer:

{{REVIEWED_COMMIT_FOOTER}}

That SHA is the gate. It must match the latest pushed commit (git rev-parse --short=12 HEAD) before the findings can be called addressed. If the footer still names an older commit after {{REVIEW_WAIT_MINUTES}} minutes, note it in the report and proceed.

Poll for both markers, so a reviewer that gave up is not mistaken for one still working:

sh
gh api repos/{{GITHUB_ORG}}/<repo>/issues/<n>/comments \
--jq '.[] | select(.user.login=="{{REVIEW_BOT_LOGIN}}")
| select(.body | test("{{REVIEW_MARKER}}|{{REVIEW_UNAVAILABLE_MARKER}}"))
| {id, updated_at, unavailable: (.body | contains("{{REVIEW_UNAVAILABLE_MARKER}}"))}'

Inline comments are not upserted. If your reviewer dedups them by a fingerprint of (path, title), a finding already pinned is not restated on the next push, so an inline comment created two commits ago is live rather than stale, and still needs an answer.

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

Popularity

Repository stars
1
7-day trend score
0

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/ankraio/agent-tools/pr-shepherd/badge)](https://verified-skill.com/skills/ankraio/agent-tools/pr-shepherd)

Something wrong with this skill or its page? Tell us.