/gh-review-loop:gh-review-loopfrom GH Review Loop
Automates the GitHub PR review loop: fetches AI reviewer feedback, fixes comments, sweeps sibling instances, verifies, pushes, and requests re-review. Requires an open PR and authenticated gh CLI.
Ships in GH Review Loop. 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; scripts run unread.
Run the full GitHub PR loop: wait for the configured AI reviewer, fetch unresolved actionable review threads, acknowledge, fix, verify against the repo's own checks, push, request re-review — capped. Prefer thread-aware review data over flat PR comments (threads preserve isResolved, isOutdated, paths, line anchors, diff hunks).
Explicit user instructions override every default here and in the references (cap, severity filter, auto-resolve, reviewer choice); "never X without an explicit request" means an explicit request unlocks X. Say in one line when you override a default. This file wins over any reference file — don't stop to reconcile them, follow this file.
Requires python3 (3.10+) and an authenticated gh CLI with GitHub access. If either is missing the script prints error: ... — relay it and stop. Never substitute raw API calls, unauthenticated requests, or guesses about review state.
This file holds the every-cycle happy path. Read the referenced file at the point of need, not up front:
| File | Load when |
|---|---|
references/reviewer-selection.md | No persisted reviewer; discovery returns none_configured/partial/confirmation_required; reviewer switch/reset |
references/claude-reviewer.md | The selected reviewer is Claude Code |
references/verification-profile.md | First run for a repo (edit gate blocks until a profile decision); customize/un-skip/re-detect |
references/sweep-internals.md | Receipt shows a multi-site pattern (count >= 2), a multi-line ranged finding, or a Clustering: advisory |
references/write-safety.md | Resolving beyond the auto-resolve set; write constraints; is a push safe; what the bundled hooks enforce |
references/judge-eval.md | judge_mode ≠ off, the user mentions judge/eval, or the one-time tip is due |
references/receipts-and-metrics.md | --post-receipt/--sticky-receipt, --semantic-risk, --stats, the --record-run flag catalog |
references/terminal-report.md | Terminal [loop] Summary has remaining_actionable > 0 |
references/ci-checks.md | The fetch prints a [loop] CI: block (failing or pending head checks) |
references/churn.md | The fetch prints [loop] Fix-induced: or [loop] churn: |
references/resume-and-recovery.md | Re-invocation at the cap; new pushes after the loop stopped; resumed/compacted session |
references/variations.md | Phrasing isn't the plain default loop (severity filters, audit-only, cap changes, judge modes, stats) |
references/script-usage.md | Any invocation not shown inline (wait catalog + outcome handling, discovery, read-only, dry-run, JSON, history) |
One configured reviewer bot per PR; returning runs reuse the persisted selection silently. Anything else — no persisted reviewer, none_configured, partial: true, confirmation_required: true, or a switch/reset — load references/reviewer-selection.md and run its prompt flow before any edit or re-review request. Never wait on a reviewer the user did not choose; never hand-write a trigger mention for an unknown bot.
RESOLVED / OUTDATED — skip (outdated is auto-resolved by the script).ADDRESSED_BY_REPLY — a maintainer's substantive reply deferred it: do not fix again; auto-resolved next pass (details: references/write-safety.md).UNRESOLVED — actionable; drives the next fix attempt. Ordered critical → high → medium → low → unknown from each reviewer's severity markers; unrecognized formats remain unknown.A cycle is one agent-posted re-review request after the reviewer's first review (cycle 0, free). Cap = max_rereview_requests (prefs file, default 3); after cycle N, hard stop. Replies and pushes without a re-review request do not count — only the agent's own requests do (login auto-detected; --agent-login/--no-agent-filter to override). The cap blocks new fix cycles and re-review requests, not stale-thread cleanup, metrics, terminal classification, or recording terminal state.
Bot reviewers are LLMs: fixing only the flagged sites of a pattern teaches the bot to flag more next cycle. Collapse that into one cycle. The receipt's Patterns (N): section clusters findings — reason about patterns, not a flat list. For each multi-site pattern (count >= 2) and each multi-line ranged finding: load references/sweep-internals.md, run sweep_siblings.py over the PR's changed files only, print the sweep report first (report-then-go — never edit unflagged code silently), then fix the cluster plus reported siblings this cycle. Honor the script's status (too_few_sites/pattern_too_thin/no_source → do not sweep; truncated: true → show the report, ask first). Mark swept patterns with --swept-pattern <sig> alongside --fixed-finding.
Each repo can have a code-derived verification profile — the checks the verify step runs. First run for a repo (a PreToolUse hook blocks edits until a profile decision is saved): load references/verification-profile.md and run its detect → menu → save flow before any edit. Subsequent runs: no prompt — the fetch output ends with the profile intro and planned-verification blocks; relay the intro from there, then for confirmed/customized run run_profile.py <owner/repo> <repo_root> — never call the test runner directly — feeding its verification field into --verification and its JSON into --verification-details. Verify fails iff any required check fails or times out. On skipped/unknown, relay the fallback intro and use ad-hoc narrowest-meaningful checks.
--cycle-summary — read-only mid-loop receipt from accumulated run state. Safe every cycle.--record-run — terminal: appends one record to local runs.jsonl and clears the run accumulator. Call exactly once, at loop end (flag catalog: references/receipts-and-metrics.md).Emit a receipt at the end of every cycle. Non-terminal → --cycle-summary right after verify, REQUIRED even when fixes were small. Terminal → --record-run only (never both on one cycle; never twice).
Single-channel delivery. Both deliver the FULL receipt to the sticky PR comment (one per PR, edited in place) and print a one-line [loop] pointer to stdout. Relay the pointer verbatim; do NOT reprint the full receipt in chat. On comment-write failure (or --dry-run) the script prints the full receipt to stdout — relay that fallback verbatim instead.
Script-owned human blocks — relay verbatim, never paraphrase unless the script fails: profile intro, planned verification, judge table/skip line, receipt pointer (or fallback receipt), semantic-risk note, Next options:, wait heartbeat. Before the reviewer confirms a re-review use the script's fixed-pending wording, never Remaining valid actionable. --json/--format json stdout is machine JSON — parse, don't relay.
Emit one-line status updates at each phase transition. N = session cycle: copy it from the script ([loop] session cycle N, loopStatus.sessionCycle, or the receipt header) — never count it yourself. It exists only after a fetch, so the pre-fetch line omits it. M/K = cap consumed.
| Phase | Narration line |
|---|---|
| Before fetch | [loop] fetching threads from PR #<num>... (no ordinal yet — the fetch is what reports it) |
| After fetch | [loop] session cycle N — re-review cap: M/K consumed. <J> actionable thread(s) (severity: <breakdown>). Fixing. + judge tip/block if due |
| After fixes | [loop] session cycle N — fixes applied. Verifying via profile runner. |
| After verify | [loop] session cycle N — verified (<test summary>). |
| Before push | --cycle-summary + relay pointer (HARD GATE), then [loop] session cycle N — committing and pushing <sha>... |
| After push | [loop] session cycle N — pushed. Requesting reviewer re-review. Cap now M/K. |
| Reviewer wait | Background task (primary) or chunked heartbeats (fallback) — Workflow step 8 |
| Stop | [loop] STOP — <stop-condition>: <one-line explanation>. |
| Done | [loop] DONE — 0 actionable threads remaining. Re-review requests used: M/K. (cap consumption, not N — a clean PR ends at 0/K) + relay the --record-run pointer; remaining_actionable > 0 → references/terminal-report.md |
Skip narration only in pure non-interactive batch mode. User stepping away → pair with --sticky-receipt.
An opt-in, read-only OpenAI judge can classify findings. Off by default; nothing is sent to OpenAI unless the user opts in. When the saved mode ≠ off, the user mentions judge eval, or the one-time tip is due, load references/judge-eval.md.
Stop and report instead of pushing or re-asking when any is true: 1. Cap reached (capped) — ask once: stop, or raise to N (--max-rereview-requests N). 2. All clean — no UNRESOLVED actionable threads after cleanup. 3. Human decision required — remaining threads are informational, duplicate, contradictory, or need a human call (incl. ADDRESSED_BY_REPLY). 4. Test regression — a failure the fix did not clearly cause. 5. No progress — the script prints [loop] no_progress: …: stop at once with --record-run --outcome no_progress; do not push or re-request. 6. CI failed — the [loop] CI: block shows a failing head check and no actionable thread is left: --outcome ci_failed (references/ci-checks.md). 7. Churn — the script prints [loop] churn: …: --outcome churn unless the user said to ignore churn.
At the cap still run cleanup, terminal classification, metrics, and the final summary. Re-invocation at the cap is a resume signal — load references/resume-and-recovery.md first.
gh pr view --json number,url,headRefName,baseRefName. No PR → report the blocker.reviewerSelection.auto_reviews: false (Codex, Copilot, Claude) and no review activity → post the trigger via request_rereview.py first, then wait with --after; waiting without pinging burns the whole timeout. Activity already present → skip the wait and fetch. Timeout → say so; never invent feedback.loopStatus.cleanBlockedBy null → report clean and stop (set → not clean, see references/reviewer-selection.md). First run for the repo → profile decision NOW, before any edit (see Verification Profile), then relay the profile intro. Explanation requests get a reply draft, not a forced edit; conflicts or regression risk → stop and surface the tradeoff.--cycle-summary + relay pointer; push. Within the cap, post the re-review via request_rereview.py --repo OWNER/REPO --pr N --expect-head "$(git rev-parse HEAD)" --json (never hand-write the trigger: it also stamps the cycle boundary; a non-posting status: review_pending → wait --after <pending_since>; already_reviewed_head, request_in_progress → fetch; head_mismatch → confirm the push, retry once; review_request_uncertain → the POST may have landed: do not re-request; re-run in two minutes; capped → Stopping Condition 1; any other status (uncountable_*, lock_unavailable, state_unwritable, unconfirmed_unreadable, review_request_rejected, …) → stop and relay exactly), capturing created_at as REREVIEW_AT only from a posted result. Then wait — primary (runtimes with background-task completion notifications, e.g. Claude Code): a background Bash task, one turn per wait:
python3 "$GGRL_PLUGIN_ROOT/skills/gh-review-loop/scripts/fetch_gemini_threads.py" \
--wait --after "$REREVIEW_AT" --timeout 1800
Do not poll it; never invent its result; relay its final output once. Fallback (no completion notifications, e.g. Codex): chunked waits — commands, statuses, refused/timed-out handling in references/script-usage.md. After the final wait, --record-run exactly once and relay its [loop] Summary pointer line.Resolve the runtime-neutral plugin root once, as its own Bash call:
GGRL_PLUGIN_ROOT="${GGRL_PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-}}"
if [ -z "$GGRL_PLUGIN_ROOT" ]; then
GGRL_PLUGIN_ROOT=$(
find ~/.codex/plugins ~/.codex/plugins/cache ~/.claude/plugins/cache \
-type d -path "*/skills/gh-review-loop" 2>/dev/null \
| sort -rV | head -1 | sed 's|/skills/gh-review-loop$||'
)
fi
if [ -z "$GGRL_PLUGIN_ROOT" ] && [ -d "$(git rev-parse --show-toplevel 2>/dev/null)/plugins/gh-review-loop" ]; then
GGRL_PLUGIN_ROOT="$(git rev-parse --show-toplevel)/plugins/gh-review-loop"
fi
export GGRL_PLUGIN_ROOT
Default fetch (resolves stale threads, prints current feedback, ends with the profile intro + planned-verification blocks):
python3 "$GGRL_PLUGIN_ROOT/skills/gh-review-loop/scripts/fetch_gemini_threads.py" [--pr <URL>]
Delta mode. Threads unchanged since the previous cycle collapse to one line (anchor, severity, URL) — not missing data; any change renders full automatically. On a resumed session or after context compaction, run one fetch with --full to re-establish the baseline. Full option catalog: references/script-usage.md.
Invariants: never resolve an UNRESOLVED thread without an explicit user request; never submit approve/request-changes reviews unless explicitly asked. Stale threads (outdated, addressed-by-reply) auto-resolve by default; uncertain run → --dry-run first. Full policy, publish-stop conditions, and the bundled-hooks table: references/write-safety.md.
references/churn.md (opens in a new tab)references/ci-checks.md (opens in a new tab)references/claude-reviewer.md (opens in a new tab)references/judge-eval.md (opens in a new tab)references/receipts-and-metrics.md (opens in a new tab)references/resume-and-recovery.md (opens in a new tab)references/reviewer-selection.md (opens in a new tab)references/script-usage.md (opens in a new tab)references/sweep-internals.md (opens in a new tab)references/terminal-report.md (opens in a new tab)references/variations.md (opens in a new tab)references/verification-profile.md (opens in a new tab)references/write-safety.md (opens in a new tab)scripts/cluster_findings.py (opens in a new tab)scripts/detect_profile.py (opens in a new tab)scripts/fetch_gemini_threads.py (opens in a new tab)scripts/hook_runtime.py (opens in a new tab)scripts/judge.py (opens in a new tab)scripts/judge_doctor.py (opens in a new tab)scripts/key_resolver.py (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
pr-review, github-actions, review-loop, code-review-automation
npx claudepluginhub orenashkenazy/gh-review-loop --plugin gh-review-loopOther plugins' skills for the same job