review-pr
Read PR review comments, monitor CI with gh pr checks --watch, implement fixes, and push updates.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- review-pr
- license
- MIT
- metadata
- { "author": "local", "version": "1.15" }
- description
- Read PR review comments, monitor CI with gh pr checks --watch, implement fixes, and push updates.
- compatibility
- Requires GitHub CLI (gh).
03 SKILL.md 正文
Review a Pull Request, collect actionable review feedback, monitor CI/check status with gh pr checks --watch, implement fixes, run lightweight review-fix validation, then commit and push updates.
Input: Optional PR number or URL (e.g., review-pr 19).
If omitted, infer from current branch. If ambiguous, show candidate PRs and ask user to choose.
Pre-checks
- Auth check: Verify GitHub CLI is authenticated
gh auth status
Steps
-
Select PR
- If input is provided, use it directly.
- Otherwise infer from branch:
gh pr view --json number,url,title,headRefName,baseRefName,state- If inference fails, list open PRs and ask user to pick one.
- After selection: verify PR is still open
If state is notgh pr view <pr> --json state --jq .stateOPEN, stop and report. - Normalize to explicit repository, number, and host for later REST/GraphQL calls (
pull_numbermust be an integer, and{owner}/{repo}would otherwise resolve to the current directory's repository even when the input URL belongs to a different one):
Usegh pr view <pr> --json url --jq '.url | capture("^https?://(?<host>[^/]+)/(?<owner>[^/]+)/(?<repo>[^/]+)/pull/(?<number>[0-9]+)$")'<owner>/<repo>as<owner_repo>and the capturednumberas<pr_number>in allgh apicalls below; for GitHub Enterprise hosts other thangithub.com, add--hostname <host>to eachgh apicall.gh prcommands still accept the original input;gh runcommands must use the captured repository via-R(see step 3). - Verify the local worktree matches the selected PR before any edits (steps 4–7 operate on the current checkout and push to its remote):
gh repo view --json nameWithOwner --jq .nameWithOwner git branch --show-current gh pr view <pr> --json headRefName,headRefOid,isCrossRepository,headRepository --jq '{branch: .headRefName, head: .headRefOid, fork: .isCrossRepository, head_repo: .headRepository.nameWithOwner}'- Stop and ask the user when the checkout repository matches neither
<owner_repo>nor (forfork: true)head_repo: runninggh pr checkout <pr>from the wrong repository only fetches the foreign PR ref into this unrelated checkout. Continue only from an actual checkout of the correct repository (clone/change directory, then re-run this verification). - If the repository matches but the current branch differs from the PR's
headRefName, switch to the PR branch (gh pr checkout <pr>, fetching first); if that is not possible (dirty worktree), stop and ask the user. - If the branch name matches but HEAD is behind
headRefOid, refresh it; prefergit pull --ff-only. Only usegh pr checkout <pr> --force(which performs a hard reset) when the index and worktree are fully clean (git status --porcelainis empty) or after the user explicitly approves a stash — never discard uncommitted changes silently. - If local is simply ahead of
headRefOidwith this PR's unpushed commits, keep them local — do not push before validation; steps 5–6 must cover them and step 7 pushes everything together. - If the branch has diverged from the PR head (both local and PR head gained commits since the merge base), stop and ask the user whether to rebase or merge before editing — never reconcile divergence implicitly. After any synchronization, re-verify HEAD against
headRefOid(or the local-ahead state). - For fork PRs (
fork: true), confirm the configured push remote targets the PR's head repository and host (git remote -vvshead_repo); otherwise stop and ask the user. - Never apply fixes to an unrelated repository or branch.
- Stop and ask the user when the checkout repository matches neither
-
Collect review feedback
gh pr view <pr> --json reviews,latestReviews,comments,files,headRefName,baseRefName,url gh api "repos/<owner_repo>/pulls/<pr_number>/comments" --paginate gh api graphql --paginate -F owner="<owner>" -F repo="<repo>" -F pr=<pr_number> -f query=' query($owner:String!,$repo:String!,$pr:Int!,$endCursor:String) { repository(owner:$owner,name:$repo){ pullRequest(number:$pr){ reviewThreads(first:100, after:$endCursor){ pageInfo{hasNextPage endCursor} nodes { isResolved isOutdated comments(first:100){ nodes { path line body } } } } } } }' --jq '.data.repository.pullRequest.reviewThreads.nodes[] | select(.isResolved==false and .isOutdated==false) | .comments.nodes[] | {path, line, body}'gh pr view --json commentsonly returns general PR comments; thegh api .../pulls/<pr_number>/commentscall captures inline (file/line) comments, but the REST endpoint does not expose thread resolution state — use the paginated GraphQLreviewThreadsquery ($endCursor/pageInfo, each thread's comments viacomments(first:100)) to exclude resolved/outdated threads and include reviewer replies before creating work items; add nested pagination if a single thread exceeds 100 replies. Build an actionable review list:- Include concrete requested changes and blocking issues
- Include inline review comments with their file/line context (from the calls above)
- Exclude pure summaries, non-actionable praise, resolved/outdated threads, and duplicates
-
Monitor CI status and failures
gh pr checks <pr> --watch gh run list -R <owner_repo> --limit 10 --json databaseId,headBranch,status,conclusion,workflowName,createdAtgh pr checksresolves the repository from the PR input, butgh runcommands do not receive it — always pass-R <owner_repo>(prefix with the host for GitHub Enterprise:-R <host>/<owner>/<repo>) so workflow runs are read from the selected PR's repository.- Determine if any required checks are failing/pending.
- For failed checks, find the latest run and inspect failing job logs:
gh run view -R <owner_repo> <run_id> --json jobs gh run view -R <owner_repo> <run_id> --job <job_id> --log-failed- Convert CI failures into actionable fix items.
-
Plan and implement fixes Resolve both sources of work:
- Review comment items
- CI failure items
For each actionable item:
- Edit only necessary files
- Keep changes minimal and aligned with PR scope
- Run relevant checks/tests for touched areas
-
Check for conflicting files before commit/push (mandatory) Run both checks:
git diff --name-only --diff-filter=U rg -n "^(<<<<<<<|=======|>>>>>>>)" .- If either command reports conflicts, stop and resolve all conflicting files first.
- Do not run commit/push until conflict output is empty.
-
Run lightweight
review-fixvalidation before commit/push (mandatory)- After coding fixes are done, run the
review-fixskill in its lightweight validation mode (seereview-fix附錄 B): it reviews only the PR's changed files and runs affected tests/lint. - Do NOT trigger the full review-fix pipeline here: no branch creation, no OpenSpec change, no full P0-P3 report, no doc consolidation, no PR prompt.
- If it reports actionable findings, implement the required follow-up fixes and repeat until none remain.
- Do not commit or push before this step is complete.
- After coding fixes are done, run the
-
Commit, push, and re-verify PR
git status --porcelain git add <files changed by the fixes> git commit -m "<clear message for the fixes>" git push- Stage only the files created or modified for the actionable items; do not use
git add -A/git add .(avoids committing unrelated or sensitive local changes). Then verify:
gh pr checks <pr> --watch gh pr view <pr> --json reviewDecision,mergeStateStatus- If checks fail again, continue log-driven fixes until green or blocked.
- Stage only the files created or modified for the actionable items; do not use
-
Report outcome Summarize:
- Which review items were fixed
- Which CI failures were fixed
- Conflict-file check result
- Lightweight
review-fixvalidation result and any extra issues it caught - Commits added
- Current checks/review state
- Remaining blockers (if any)
Guardrails
- Do not rewrite unrelated code.
- Never edit or push in a worktree that does not match the selected PR's repository.
- If a review comment is unclear or conflicts with spec/requirements, pause and ask user.
- If there are no actionable review comments, still check CI and fix CI failures if present.
- If review is clean and CI is green, explicitly state no action is needed.
- Conflict-file checks are required before every commit/push in this workflow.
- Lightweight
review-fixvalidation (changed-files review + affected tests/lint) is required before every commit/push in this workflow.
04 同仓库更多 Skills
skill-installer
Install Codex skills into $CODEX_HOME/skills from a curated list or a GitHub repo path. Use when a user asks to list installable skills, install a curated skill, or install a skill from another repo (including private repos).
openai-docs
Use when the user asks how to build with OpenAI products or APIs and needs up-to-date official documentation with citations, help choosing the latest model for a use case, or explicit GPT-5.4 upgrade and prompt-upgrade guidance; prioritize OpenAI docs MCP tools, use bundled references only as helper context, and restrict any fallback browsing to official OpenAI domains.
imagegen
Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output should be a bitmap asset rather than repo-native code or vector. Do not use when the task is better handled by editing existing SVG/vector/code-native assets, extending an established icon or logo system, or building the visual directly in HTML/CSS/canvas.
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
web-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.