PR thread resolver
Turn unresolved GitHub PR review threads into committed, verified, resolved fixes — natively, with
gh + Claude Code's edit/verify loop. No external orchestrator.
When to use / route away
Use for hosted PR review threads. Route away:
- Local review notes (Codex/Zen/manual) →
review-remediation.
- Passive watch until merge / CI status →
babysit-pr.
- CI-log-only failure with no review thread →
gh workflow-log remediation.
Default loop (autonomous: fix → commit → push → resolve)
- Ground: read repo
AGENTS.md/CLAUDE.md; git status --short; capture the head SHA
(gh pr view <pr> --json headRefOid -q .headRefOid).
- Fetch threads: list unresolved review threads via
gh api graphql into a compact worklist
(see references/gh-graphql.md): thread id, path, line, isResolved, isOutdated, body, any
suggestion hunk.
- Triage each:
Read the current line. Skip with a reason if already-fixed or stale
(isOutdated + code no longer matches); else queue a minimal fix.
- Plan: decide order; serial for shared files, fan out for independent threads (below).
- Fix: apply the smallest correct edit. Apply a
suggestion block verbatim only on an
exact hunk match; otherwise write a hand-minimal fix.
- Verify: run repo-native gates — focused test for the touched area first, then broad
type-check / lint / build (use
/verify and /code-review as the backbone).
- Commit: scoped, semantically grouped Conventional Commits (see
references/closeout.md).
- Push the branch once after all intended commits pass verification.
- Resolve: re-fetch head + thread state; resolve via
resolveReviewThread only threads
backed by a committed+pushed+verified fix (or already-fixed at current head).
- Re-poll until zero actionable threads remain or a real blocker appears.
Parallel resolution
When ≥3 threads touch disjoint files, dispatch one read-and-fix Task subagent per file/cluster.
Subagent contract: fix + verify + report only (file:line, change, verification result) — it does
not commit, push, or resolve. The parent serializes all staging, commits, pushes, and
resolveReviewThread mutations. Workers own disjoint files and never touch another's.
Resolve safety policy
Resolve a thread ONLY when it maps to a committed, pushed, and verified fix (or is already fixed at
current head). Never resolve when: the PR head drifted unexpectedly since you pushed; verification
failed; the thread was skipped, ambiguous, or unmatched. Do not auto-reply by default — reply only
when a thread cannot be fixed cleanly or the user asks for a comment.
Outputs
Worklist · verified-fix / skipped summary (file:line evidence) · verification commands + results ·
commit SHAs · thread→commit closeout map · terminal status completed | blocked | no-op.
Resources
references/gh-graphql.md — copy-paste gh api graphql queries + the resolveReviewThread mutation.
references/closeout.md — Conventional Commit grouping, forbidden process-wording, head-drift guard.
1---2name: pr-thread-resolver3description: Fetches, fixes, and resolves unresolved GitHub PR review threads with the gh CLI. Use when addressing reviewer feedback, clearing blocking conversations before merge, or applying GitHub suggested changes. Verifies each finding against current code and resolves only what it fixed.4license: MIT5---67# PR thread resolver89Turn unresolved GitHub PR review threads into committed, verified, resolved fixes — natively, with10`gh` + Claude Code's edit/verify loop. No external orchestrator.1112## When to use / route away1314Use for **hosted PR review threads**. Route away:15- Local review notes (Codex/Zen/manual) → `review-remediation`.16- Passive watch until merge / CI status → `babysit-pr`.17- CI-log-only failure with no review thread → `gh` workflow-log remediation.1819## Default loop (autonomous: fix → commit → push → resolve)20211. **Ground**: read repo `AGENTS.md`/`CLAUDE.md`; `git status --short`; capture the head SHA22 (`gh pr view <pr> --json headRefOid -q .headRefOid`).232. **Fetch threads**: list unresolved review threads via `gh api graphql` into a compact worklist24 (see `references/gh-graphql.md`): thread id, path, line, `isResolved`, `isOutdated`, body, any25 ```suggestion``` hunk.263. **Triage** each: `Read` the current line. Skip with a reason if already-fixed or stale27 (`isOutdated` + code no longer matches); else queue a minimal fix.284. **Plan**: decide order; serial for shared files, **fan out** for independent threads (below).295. **Fix**: apply the smallest correct edit. Apply a ```suggestion``` block verbatim **only** on an30 exact hunk match; otherwise write a hand-minimal fix.316. **Verify**: run repo-native gates — focused test for the touched area first, then broad32 type-check / lint / build (use `/verify` and `/code-review` as the backbone).337. **Commit**: scoped, semantically grouped Conventional Commits (see `references/closeout.md`).348. **Push** the branch once after all intended commits pass verification.359. **Resolve**: re-fetch head + thread state; resolve via `resolveReviewThread` **only** threads36 backed by a committed+pushed+verified fix (or already-fixed at current head).3710. **Re-poll** until zero actionable threads remain or a real blocker appears.3839## Parallel resolution4041When ≥3 threads touch **disjoint files**, dispatch one read-and-fix `Task` subagent per file/cluster.42Subagent contract: **fix + verify + report only** (file:line, change, verification result) — it does43**not** commit, push, or resolve. The **parent** serializes all staging, commits, pushes, and44`resolveReviewThread` mutations. Workers own disjoint files and never touch another's.4546## Resolve safety policy4748Resolve a thread ONLY when it maps to a committed, pushed, and verified fix (or is already fixed at49current head). **Never** resolve when: the PR head drifted unexpectedly since you pushed; verification50failed; the thread was skipped, ambiguous, or unmatched. Do not auto-reply by default — reply only51when a thread cannot be fixed cleanly or the user asks for a comment.5253## Outputs5455Worklist · verified-fix / skipped summary (file:line evidence) · verification commands + results ·56commit SHAs · thread→commit closeout map · terminal status `completed` | `blocked` | `no-op`.5758## Resources5960- `references/gh-graphql.md` — copy-paste `gh api graphql` queries + the resolveReviewThread mutation.61- `references/closeout.md` — Conventional Commit grouping, forbidden process-wording, head-drift guard.