github-pr-review-setup
Prepare a clean local checkout for a GitHub PR (worktree-first via `ohc`/Orca), fetch the PR base ref, and emit PR context (CI checks + PR comments/reviews) as JSON for downstream review.
SKILL.mdagent-marketplace/src/experimental/skills/github-pr-review-setup/SKILL.md
GitHubSet up a GitHub PR review
Run this skill when a review needs a clean local checkout and a JSON bundle of the PR's metadata, CI checks, and discussion. The script prints that bundle to stdout and can also save it to a file.
Prepare the checkout
Run the script with a PR number or GitHub PR URL:
python "<path-to-skill>/scripts/prepare_github_pr_review.py" --pr "<number-or-url>"Supply
--repo OWNER/REPOwhen--pris a number and the repository cannot be inferred from the current checkout. Supply--repo-dir <path-to-clone>when you are not running inside the target repository.Use the default
--checkout-mode worktreefor an isolated Orca worktree. The script resolvesohc, requireszsh,orca, andgh, then asksohcto create a worktree namedpr-review-<number>. Set--worktree-nameto choose another name.ohcclones throughghc, registers the repository in Orca, and creates the worktree; the script then runsgh pr checkoutin it with--branch <worktree-name> --force. This handles same-repository and fork PRs through the same checkout path.Use
--checkout-mode inplaceonly when you want the PR branch in the existing clone. The script requires a clean clone and, when it can detect the localorigin, checks that it matches the requested repository. It checks out the PR withgh pr checkout; Orca is not required.python "<path-to-skill>/scripts/prepare_github_pr_review.py" \ --pr "<number-or-url>" \ --checkout-mode inplaceThe script fetches the PR base branch so the returned
compare_toref is available locally. It usesupstreamwhen present, otherwiseorigin, otherwise the first configured remote. If there are no remotes, the base ref must already exist locally.
Read the review context
Use the JSON payload as the input to the review. It includes:
worktree_dir: checkout path, whether created as a worktree or used in placerepo_dir: underlying clone path when knowncompare_to: fetched base ref suitable for review tools, such asupstream/mainpr: metadata returned bygh pr viewchecksandchecks_summary: CI checks and counts grouped by result bucketissue_comments,reviews, andreview_comments: paginated PR discussiongit: resolved base and checked-out head commit IDs
CI checks come from gh pr checks; PR metadata comes from gh pr view; the
three discussion fields come from paginated gh api requests. A pending-checks
exit from gh pr checks is accepted and represented in the returned payload.
Pass these values to the review tool:
path = worktree_dir
compare_to = compare_to
Save the payload
Use --out <path> to write the same JSON payload to a file as well as stdout.
The script creates parent directories for that path.
python "<path-to-skill>/scripts/prepare_github_pr_review.py" \
--pr "<number-or-url>" \
--out "/path/to/pr-context.json"
The script requires git and gh in either checkout mode. A PR number can be
paired with --repo or inferred from the local origin; a GitHub PR URL
provides its repository directly.