/watch-pr:watch-pr [pr-url-or-ref]from watch-pr
Watch a GitHub PR's full lifecycle through the hosted watch-pr MCP server, act on CI and rebase changes, and handle incoming review feedback until merge or closure.
Ships in watch-pr. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Use the hosted watch-pr MCP server for durable GitHub webhook ingestion and periodic
reconciliation. Use the bundled watch-pr-monitor.mjs only for its read-only SSE feed.
MCP resource notifications may be useful hints, but they are never the wake-up or
correctness path.
Before resolving or watching a pull request, confirm that the root session's tool inventory exposes all three required watch-pr MCP tools:
watch_prget_prunwatch_prIf any tool is unavailable, tell the user to authenticate the watch-pr MCP server with
/mcp reauth plugin:watch-pr:watch-pr, then stop and wait. Do not continue until the
root tool inventory exposes all three tools. Do not invoke Claude CLI, another client,
another MCP transport, or any polling path as a workaround.
The root session that authored the pull request owns every action: calls to get_pr,
code edits, rebases, pushes, review replies, and cleanup. The watcher process and any
subagent hosting it are messengers only. They must never inspect or change the checkout,
call GitHub, call MCP tools, or act on a pull request event.
Run one active watcher for this PR in the root session. Prefer keeping it through every intermediate event. Replace it only when it has exited, failed, or can no longer continue and lifecycle monitoring is still needed. Before starting a replacement, confirm the old watcher is stopped and preserve its last event ID when one exists. Never run two watchers for the same PR or substitute recurring polling.
Do not call watch_pr or unwatch_pr for this PR from a
second client that shares the same MCP credential. The backend watch scope is
shared by that credential, so another client's unwatch_pr revokes the root
watcher's capability. Report only that the watcher process started once the harness
returns its concrete process, Monitor, or agent identifier; silence does not prove the
SSE connection is healthy. Permanent connection errors terminate the process on stderr.
Sustained transient failures emit a bounded stderr warning while retries continue.
Resolve the pull request with gh pr view. If no argument was supplied, resolve the
current branch:
gh pr view --json number,url -q '"#\(.number) \(.url)"'
For an explicit number, URL, or branch, pass it to gh pr view. Keep the full URL;
its /OWNER/REPOSITORY/pull/NUMBER path supplies the MCP arguments without depending
on the current checkout's remotes.
From the root session, call watch_pr with:
repository: OWNER/REPOSITORYnumber: the pull-request numberThe single call subscribes and opens the monitor capability. Parse its JSON result
and retain monitor.monitorUrl. The URL is a read-only capability scoped to this
OAuth session and PR. It expires 12 hours after first creation; repeated calls reuse
the same URL and original deadline while it remains valid, then mint a new capability
after expiry. It carries no GitHub credential and is safe to include in harness calls,
process arguments, transcripts, and logs.
If the result has no monitor object, the server predates the merged tool; stop and
report instead of launching a watcher. If monitor.terminalState is already merged
or closed, do not launch a watcher. Call get_pr, perform the matching terminal
action below, and clean up with unwatch_pr.
Resolve watch-pr-monitor.mjs from the absolute directory containing this SKILL.md;
do not search the checkout or assume the current working directory. Start exactly one
watcher through the harness-native flow below, passing the URL directly:
node "<absolute skill directory>/watch-pr-monitor.mjs" "<monitorUrl>"
Classify each stdout record:
│ and therefore cannot be mistaken for a watcher record. Check failures
include their URL; comment and review headers include their IDs, while feedback also
includes the file and start/end lines. Their redundant GitHub URLs are omitted.
Act from this output without calling get_pr.PR <n> finished: MERGED or PR <n> finished: CLOSED is terminal. Call get_pr
once to reconcile final state before the terminal action below.Use get_pr only for terminal reconciliation, after a cursorless monitoring gap, or
when an inline detail explicitly lacks information needed to act. Use
list_pr_events only to explain a transition.
Judge get_pr freshness with its top-level coverage and polledAt. coverage: "webhook" means GitHub delivers this repository's events, so the snapshot updates from
payloads without reading GitHub and polledAt advances only at the hourly
reconciliation; an hour-old polledAt there is normal. Reactions and other changes no
webhook carries can lag by up to that hour. coverage: "polling" (for example an
upstream repository without the GitHub App) is read every minute, so a polledAt more
than a few minutes old there is stale. fetchedAt is the last stored change and can
be newer than polledAt; an old fetchedAt on a quiet PR is not stale data. An empty
checks array is accurate when the head commit has no check runs or statuses; CI
waiting on maintainer approval is reported as an action_required check, not as
missing checks. Right after a push, empty checks and mergeableState: "unknown"
mean the new head has not reported yet: wait for the following mergeability:
line, and for checks: lines only when the repository runs CI on the head.
Create one persistent Monitor running the watcher command with monitorUrl as its
sole argument. Keep that Monitor active after intermediate updates. An idle watcher
prints nothing; each nonterminal output block or PR <n> finished: ... line wakes the
root session. Record the Monitor identifier for explicit cancellation. If the process
exits, inspect its stderr and let the root session decide whether rearming is necessary.
Do not run the command in an ordinary background shell or create a scheduled task.
Before creating a replacement Monitor, stop the recorded Monitor and confirm it ended.
Call spawn_agent once to create one long-lived watcher subagent. Give it the watcher
path and monitorUrl, and instruct it exactly as follows:
Run `node "<absolute skill directory>/watch-pr-monitor.mjs" "<monitorUrl>"` in the
foreground. The process emits nothing while the feed is idle. For each nonterminal
stdout line, immediately send the exact line to the root session through the
parent-message channel. Lines beginning with `│ ` continue the preceding comment,
review, or feedback body and are never standalone watcher records. Continue reading
the same process. For `PR <n> finished: MERGED` or `PR <n> finished: CLOSED`, return
the exact line to the root as the terminal result and exit. If stderr starts with
`watch-pr monitor: still reconnecting`, send that nonfatal warning to the root and
continue reading the same process. For any other stderr output or a nonzero exit, send
the error and last stdout event to the root and exit.
Do not call MCP or GitHub tools, inspect or modify files, rebase, push, reply, poll,
restart, or launch another watcher; the root session decides recovery.
Retain the agent identifier. Do not close it or treat silence or an intermediate message as its result. The root acts directly from intermediate detail lines and leaves the same subagent running until the terminal result, process failure, or explicit cancellation. Before spawning a replacement, confirm the recorded watcher agent and its child process have ended.
Start one hub-managed persistent process with a capability-free unique name:
hub(
op: "start",
name: "watch-pr-<owner>-<repository>-<number>",
application: "node",
args: ["<absolute skill directory>/watch-pr-monitor.mjs", "<monitorUrl>"],
progress: "wake"
)
Retain the process name for cancellation. Initial silence is normal; every actionable
or terminal line wakes the root. If the process exits, use its captured stderr and last
event ID to decide whether to fix the launch, refresh the capability, or stop watching.
Do not use asynchronous Bash, recurring hub wait, job polling, or a second process
while the current watcher is running.
Before restarting this name, stop any live process under it and confirm termination.
Spawn one long-lived subagent with the direct-URL foreground command and messaging contract shown for Codex. It must remain alive during idle periods and deliver stdout, stderr, and process exit to the root. If the harness cannot keep a subagent alive and deliver its messages, report that the required watch cannot be established rather than substituting polling or a detached shell.
| Line | Action |
|---|---|
mergeability: <part>[, <part>...] | One line joins every mergeability change; act on each part below. |
part head -> <ref>@<sha> | Inspect the new commit and restarted checks before acting on earlier results. |
part base <old> -> <new> | Re-evaluate the branch and merge target before pushing or merging. |
part state -> BEHIND | Rebase the head branch onto the PR's base branch and push. |
part state -> DIRTY | Rebase, resolve every conflict, and force-push the feature branch with --force-with-lease. |
part state -> <other-state> | Record that the prior behind/conflict condition cleared; continue with checks and review. |
PR state: <OPEN|CLOSED> [DRAFT] | Record the lifecycle or draft transition; a DRAFT suffix still blocks review. |
checks: <name> -> pending | Informational; wait for that check's result or an immediate failure. Every check arrives on its own line. |
checks: <name> -> pass | checks: <name> -> skipping | Record the terminal result for that check; no action. |
checks: <name> -> fail <url> | Open the URL, inspect logs, fix the cause, commit, and push. |
checks: <name> -> cancel <url> | Investigate whether the canceled check is required or should be rerun. |
checks: <name> -> action_required <url> | CI is waiting for approval, usually a fork PR's workflows awaiting a maintainer; the workflow run exists but has not started executing, so it has no check runs. Nothing to fix in the code: tell the user. Approving runs the PR branch's workflow code, so never approve on your own; approve at the URL only when the user explicitly asks and has confirmed the branch is trusted. |
comment #<id> @<author>: <body> | Read the full body inline, including any │ continuation lines; decide whether it requires action, then use the comment ID to reply when needed. |
review #<id> @<author> <state>: <body> | Handle the verdict and full body directly, including any │ continuation lines; use the review ID when a reply is needed. |
feedback [<thread>] #<comment-id> <file>:<start>[-<end>] @<author>: <body> | Inspect the named code and all │ continuation lines, then fix or reply using the IDs. [-] means GitHub did not return a thread ID. |
thread <id>: reopened|resolved | Re-opened feedback requires action; record resolved feedback without another snapshot fetch. |
comment|review|feedback ... deleted | Record that the referenced feedback was removed; do not act on its stale text. |
active comments: <+n|-n>, now <count> | Informational count of unresolved review feedback; act on the accompanying feedback or thread lines. |
reaction <created|deleted>: @<user> <CONTENT> on <target> | Informational; a reaction is not a request for changes. |
deployment: <environment> [(<ref>)] -> <state> [<url>] | Informational; investigate only a failed or errored deployment. |
+<n> more checks | The server bounded a large check wave; call get_pr once for the omitted check states. |
+<n> more changes | Non-body details exceeded the safety bound or a body required snapshot reconciliation; call get_pr once for the omitted details. |
PR <n> finished: MERGED | Call get_pr, call unwatch_pr, fetch/prune the local repository when applicable, and report completion. The watcher exits on its own. |
PR <n> finished: CLOSED | Call get_pr, call unwatch_pr, and report that the PR closed without merging. The watcher exits on its own. |
For each inline comment, review, or feedback detail:
gh using the comment, review, and thread identifiers already in the
event output. Use the repository's comments skill when available; otherwise use
GitHub's REST reply endpoint and GraphQL resolveReviewThread mutation directly.Continue until the watcher reports merge or closure. Passing checks is intermediate; later reviews, rebases, reruns, and merge events remain part of the same lifecycle.
If the user cancels before a terminal event, stop the exact harness watcher: stop the
Claude Monitor, interrupt and close the Codex/generic subagent, or call
hub(op: "stop", name: "<recorded process name>") for Oh My Pi. Confirm that process
has ended, then call unwatch_pr.
When a watcher fails, confirm that process has exited or stop it before deciding whether to rearm. Diagnose the concrete failure instead of retrying blindly:
watch_pr again, replace the returned
monitor.monitorUrl's cursor query parameter with the reported last event ID
(remove cursor when that ID is empty), then start one replacement watcher with the
URL as its only argument.watch_pr once more and start one more
replacement rebuilt the same way; if it fails again, stop watching and report instead
of retrying.unwatch_pr.get_pr once to reconcile current state.unwatch_pr.Never leave the old process running, start duplicate watchers, or replace monitoring with recurring polling.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub pedropaulovc/agent-plugins --plugin watch-pr