github-pr-review by fvadicamo/dev-agent-skills
npx skills add https://github.com/fvadicamo/dev-agent-skills --skill github-pr-review包含 Shell 命令
此技能包含可能执行系统命令的 shell 命令指令(!command``)。安装前请仔细审查。
通过基于严重性的优先级排序、应用修复和线程回复来解决 Pull Request 审查评论。
!gh pr view --json number,title,state,milestone -q '"PR #\(.number): \(.title) (\(.state)) | Milestone: \(.milestone.title // "none")"' 2>/dev/null
REPO=$(gh repo view --json nameWithOwner -q '.nameWithOwner')
PR=$(gh pr view --json number -q '.number')
LAST_PUSH=$(git log -1 --format=%cI HEAD)
# 行内审查评论 - 过滤掉回复(仅保留原始评论)
gh api repos/$REPO/pulls/$PR/comments?per_page=100 --jq '
[.[] | select(.in_reply_to_id == null) |
{id, path, user: .user.login, created_at, body: .body[0:200]}]
'
# 包含非空正文的 PR 级别审查(CodeRabbit 部分、Gemini 等)
gh api repos/$REPO/pulls/$PR/reviews?per_page=100 --jq '
[.[] | select(.body | length > 0) |
{id, user: .user.login, state, submitted_at, body: .body[0:500]}]
'
交叉检查审查附带的评论:CodeRabbit 的审查正文声明"已发布可操作评论:N"。如果通用的 端点返回的来自该审查者的新原始评论少于 N 条,则某些评论只能通过特定于审查的端点获取。获取它们并按评论 ID 合并:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
pulls/$PR/comments# $REVIEW_ID 来自上面的 reviews 获取;$EXPECTED 来自解析"已发布可操作评论:N"
gh api repos/$REPO/pulls/$PR/reviews/$REVIEW_ID/comments?per_page=100 --jq '
[.[] | select(.in_reply_to_id == null) |
{id, path, user: .user.login, created_at, body: .body[0:200]}]
'
在继续之前按 id 去重。仅通过特定于审查的端点找到的评论是有效的行内评论,应同等对待(相同的分类,相同的 in_reply_to 回复机制)。
筛选新评论与已查看评论:将 created_at/submitted_at 与 $LAST_PUSH 进行比较。在最后一次推送之后发布的评论是新的。在摘要表中将较早的评论标记为"上一轮"。
解析 CodeRabbit 审查正文:初始获取会截断正文以进行分类。对于来自 CodeRabbit(user.login 以 coderabbitai 开头)的审查,单独获取完整正文:
gh api repos/$REPO/pulls/$PR/reviews?per_page=100 --jq '
[.[] | select(.user.login | startswith("coderabbitai")) |
{id, submitted_at, body}]
'
CodeRabbit 发布结构化的 <details> 块,包含差异外、重复和挑剔评论。每个块都包含文件路径、行范围、严重性,以及可选的包含预构建上下文的"AI 代理提示"。完整解析指南请参阅 references/coderabbit_parsing.md。
在可用时使用 CodeRabbit AI 提示:如果评论(或审查正文)包含"AI 代理提示" <details> 块,请使用它来理解问题和建议的方法。在提出修复方案之前,务必阅读实际代码。如果审查正文包含"所有审查评论的 AI 代理提示"块,在处理单个评论之前,请先阅读它以获取跨评论的上下文。
按严重性对所有评论进行分类并按顺序处理:CRITICAL > HIGH > MEDIUM > LOW。
| 严重性 | 指示器 | 操作 |
|---|---|---|
| CRITICAL | critical.svg, _🔒 Security_, _🚨 Critical_, _🔴 Critical_, "security", "vulnerability" | 必须修复 |
| HIGH | high-priority.svg, _⚠️ Potential issue_, _🐛 Bug_, _⚡ Performance_, _🟠 Major_, "High Severity" | 应该修复 |
| MEDIUM | medium-priority.svg, _🛠️ Refactor suggestion_, _💡 Suggestion_, "Medium Severity" | 推荐 |
| LOW | low-priority.svg, _🧹 Nitpick_, _🔧 Optional_, _🟡 Minor_, _🔵 Trivial_, _⚪ Info_, "style", "nit" | 可选 |
当评论同时具有类型标签和次要颜色徽章(例如 _💡 Suggestion_ | _🟠 Major_)时,颜色徽章是绑定严重性,并覆盖基于类型的默认值。
完整检测模式(Gemini 徽章、CodeRabbit 表情符号、Cursor 评论、关键词回退、相关评论启发式方法)请参阅 references/severity_guide.md。
在处理之前,显示所有评论的结构化概览:
| # | ID | 严重性 | 文件:行 | 类型 | 状态 | 摘要 |
|---|------------|----------|--------------------|----------|----------|--------------------|
| 1 | 123456789 | CRITICAL | src/auth.py:45 | inline | new | SQL 注入风险 |
| 2 | 987654321 | HIGH | src/db.py:346-350 | outside | new | 缺少连接条件 |
| 3 | 555555555 | HIGH | src/chunk.py:188 | duplicate| previous | 过时元数据 |
| 4 | 444444444 | LOW | tests/test_q.py:12 | nitpick | previous | 命名约定 |
inline、outside(差异外)、duplicate、minor、nitpick(来自 CodeRabbit 部分)或 review(通用 PR 级别)new(在最后一次推送后发布)或 previous(来自较早的轮次)如果存在超过 10 条评论,建议将审查摘要保存到 Claude 的记忆中,以便跨会话跟踪。摘要应包括:PR 编号、评论 ID、严重性、状态(新/已处理/已推迟/不修复)和简要描述。这有助于在后续推送后出现新评论时保持连续性。
按严重性顺序处理每条评论:
使用 git-commit 技能格式。功能性修复单独提交,外观性修复批量处理:
| 变更类型 | 策略 |
|---|---|
| 功能性(CRITICAL/HIGH) | 每个修复单独提交 |
| 外观性(MEDIUM/LOW) | 单个批量 style: 提交 |
在提交正文中引用评论 ID。
重要:使用 --input - 配合 JSON。-f in_reply_to=... 语法不起作用。
COMMIT=$(git rev-parse --short HEAD)
gh api repos/$REPO/pulls/$PR/comments \
--input - <<< '{"body": "Fixed in '"$COMMIT"'. Brief explanation.", "in_reply_to": 123456789}'
嵌入在审查正文中的评论(差异外、重复、挑剔)没有行内线程。GitHub API 不支持直接回复审查正文。发布一个引用特定问题的通用 PR 评论:
gh pr comment $PR --body "Fixed in $COMMIT. Addresses outside-diff comment on file/path.py:346-350."
回复模板(无表情符号,简洁专业):
| 情况 | 模板 |
|---|---|
| 已修复 | Fixed in [hash]. [brief description of fix] |
| 不修复 | Won't fix: [reason] |
| 设计如此 | By design: [explanation] |
| 已推迟 | Deferred to [issue/task]. Will address in future iteration. |
| 已确认 | Acknowledged. [brief note] |
运行项目测试套件。所有测试必须在推送前通过。将所有修复一起推送,以最小化审查循环。
处理完所有评论后,正式提交审查:
gh pr review $PR --approve --body "..." - 所有评论已处理,PR 准备就绪gh pr review $PR --request-changes --body "..." - 关键问题仍然存在gh pr review $PR --comment --body "..." - 进度更新,尚未决定gh pr view $PR --json milestone -q '.milestone.title // "none"'
如果 PR 没有里程碑,检查是否有开放的里程碑:
REPO=$(gh repo view --json nameWithOwner -q '.nameWithOwner')
gh api repos/$REPO/milestones --jq '[.[] | select(.state=="open")] | .[] | "\(.number): \(.title)"'
如果存在开放的里程碑,通知用户并建议分配:
gh pr edit $PR --milestone "[milestone-title]"
请不要自动分配。这只是一个提醒。
当机器人(Gemini、Codex 等)审查每次推送时:
[skip ci] 或 [skip review]pulls/$PR/comments)和审查正文(pulls/$PR/reviews)pulls/$PR/reviews/$REVIEW_ID/commentsgh pr review)style: 提交中references/severity_guide.md - 严重性检测模式(Gemini 徽章、CodeRabbit 表情符号、Cursor 评论、关键词回退、相关评论启发式方法)references/coderabbit_parsing.md - CodeRabbit 审查正文结构、部分解析、"AI 代理提示"使用、重复和"也适用于"处理每周安装
330
仓库
GitHub 星标
54
首次出现
Jan 21, 2026
安全审计
安装于
opencode293
gemini-cli278
codex275
cursor269
github-copilot265
claude-code249
Contains Shell Commands
This skill contains shell command directives (!command``) that may execute system commands. Review carefully before installing.
Resolves Pull Request review comments with severity-based prioritization, fix application, and thread replies.
!gh pr view --json number,title,state,milestone -q '"PR #\(.number): \(.title) (\(.state)) | Milestone: \(.milestone.title // "none")"' 2>/dev/null
REPO=$(gh repo view --json nameWithOwner -q '.nameWithOwner')
PR=$(gh pr view --json number -q '.number')
LAST_PUSH=$(git log -1 --format=%cI HEAD)
# Inline review comments - filter out replies (keep only originals)
gh api repos/$REPO/pulls/$PR/comments?per_page=100 --jq '
[.[] | select(.in_reply_to_id == null) |
{id, path, user: .user.login, created_at, body: .body[0:200]}]
'
# PR-level reviews with non-empty body (CodeRabbit sections, Gemini, etc.)
gh api repos/$REPO/pulls/$PR/reviews?per_page=100 --jq '
[.[] | select(.body | length > 0) |
{id, user: .user.login, state, submitted_at, body: .body[0:500]}]
'
Cross-check review-attached comments : CodeRabbit's review body states "Actionable comments posted: N". If the general pulls/$PR/comments endpoint returns fewer than N new originals from that reviewer, some comments are only available via the review-specific endpoint. Fetch them and merge by comment ID:
# $REVIEW_ID from the reviews fetch above; $EXPECTED from parsing "Actionable comments posted: N"
gh api repos/$REPO/pulls/$PR/reviews/$REVIEW_ID/comments?per_page=100 --jq '
[.[] | select(.in_reply_to_id == null) |
{id, path, user: .user.login, created_at, body: .body[0:200]}]
'
Deduplicate by id before continuing. Comments found only via the review-specific endpoint are valid inline comments and should be treated identically (same classification, same in_reply_to reply mechanism).
Filter new vs already-seen : compare created_at/submitted_at with $LAST_PUSH. Comments posted after the last push are new. Mark older comments as "previous round" in the summary table.
Parse CodeRabbit review bodies : the initial fetch truncates bodies for classification. For reviews from CodeRabbit (user.login starts with coderabbitai), fetch the full body separately:
gh api repos/$REPO/pulls/$PR/reviews?per_page=100 --jq '
[.[] | select(.user.login | startswith("coderabbitai")) |
{id, submitted_at, body}]
'
CodeRabbit posts structured <details> blocks containing outside-diff, duplicate, and nitpick comments. Each block includes file path, line range, severity, and optionally a "Prompt for AI Agents" with pre-built context. See references/coderabbit_parsing.md for full parsing guide.
Use CodeRabbit AI prompts when available : if a comment (or the review body) contains a "Prompt for AI Agents" <details> block, use it to understand the issue and suggested approach. Always read the actual code before proposing a fix. If the review body contains a "Prompt for all review comments with AI agents" block, read it first for cross-comment context before processing individual comments.
Classify all comments by severity and process in order: CRITICAL > HIGH > MEDIUM > LOW.
| Severity | Indicators | Action |
|---|---|---|
| CRITICAL | critical.svg, _🔒 Security_, _🚨 Critical_, _🔴 Critical_, "security", "vulnerability" | Must fix |
| HIGH | high-priority.svg, _⚠️ Potential issue_, _🐛 Bug_, _⚡ Performance_, , "High Severity" |
When a comment has both a type label and a secondary color badge (e.g., _💡 Suggestion_ | _🟠 Major_), the color badge is the binding severity and overrides the type-based default.
See references/severity_guide.md for full detection patterns (Gemini badges, CodeRabbit emoji, Cursor comments, keyword fallback, related comments heuristics).
Before processing, display a structured overview of all comments:
| # | ID | Severity | File:Line | Type | Status | Summary |
|---|------------|----------|--------------------|----------|----------|--------------------|
| 1 | 123456789 | CRITICAL | src/auth.py:45 | inline | new | SQL injection risk |
| 2 | 987654321 | HIGH | src/db.py:346-350 | outside | new | Missing join cond |
| 3 | 555555555 | HIGH | src/chunk.py:188 | duplicate| previous | Stale metadata |
| 4 | 444444444 | LOW | tests/test_q.py:12 | nitpick | previous | Naming convention |
inline, outside (outside diff), duplicate, minor, nitpick (from CodeRabbit sections), or review (generic PR-level)new (posted after last push) or previous (from earlier rounds)If there are more than 10 comments , suggest saving a review summary to Claude's memory for tracking across sessions. The summary should include: PR number, comment IDs, severity, status (new/addressed/deferred/won't fix), and brief description. This helps maintain continuity when new comments arrive after subsequent pushes.
For each comment, in severity order:
Use git-commit skill format. Functional fixes get separate commits, cosmetic fixes are batched:
| Change type | Strategy |
|---|---|
| Functional (CRITICAL/HIGH) | Separate commit per fix |
| Cosmetic (MEDIUM/LOW) | Single batch style: commit |
Reference the comment ID in the commit body.
Important : use --input - with JSON. The -f in_reply_to=... syntax does NOT work.
COMMIT=$(git rev-parse --short HEAD)
gh api repos/$REPO/pulls/$PR/comments \
--input - <<< '{"body": "Fixed in '"$COMMIT"'. Brief explanation.", "in_reply_to": 123456789}'
Comments embedded in the review body (outside diff, duplicate, nitpick) do not have inline threads. The GitHub API does not support replying to a review body directly. Post a general PR comment referencing the specific issue:
gh pr comment $PR --body "Fixed in $COMMIT. Addresses outside-diff comment on file/path.py:346-350."
Reply templates (no emojis, minimal and professional):
| Situation | Template |
|---|---|
| Fixed | Fixed in [hash]. [brief description of fix] |
| Won't fix | Won't fix: [reason] |
| By design | By design: [explanation] |
| Deferred | Deferred to [issue/task]. Will address in future iteration. |
| Acknowledged | Acknowledged. [brief note] |
Run the project test suite. All tests must pass before pushing. Push all fixes together to minimize review loops.
After addressing all comments, formally submit a review:
gh pr review $PR --approve --body "..." - all comments addressed, PR is readygh pr review $PR --request-changes --body "..." - critical issues remaingh pr review $PR --comment --body "..." - progress update, no decision yetgh pr view $PR --json milestone -q '.milestone.title // "none"'
If the PR has no milestone, check for open milestones:
REPO=$(gh repo view --json nameWithOwner -q '.nameWithOwner')
gh api repos/$REPO/milestones --jq '[.[] | select(.state=="open")] | .[] | "\(.number): \(.title)"'
If open milestones exist, inform the user and suggest assigning:
gh pr edit $PR --milestone "[milestone-title]"
Do not assign automatically. This is a reminder only.
When bots (Gemini, Codex, etc.) review every push:
[skip ci] or [skip review]pulls/$PR/comments) and review bodies (pulls/$PR/reviews)pulls/$PR/reviews/$REVIEW_ID/comments when count mismatchesgh pr review) after addressing all commentsreferences/severity_guide.md - Severity detection patterns (Gemini badges, CodeRabbit emoji, Cursor comments, keyword fallback, related comments heuristics)references/coderabbit_parsing.md - CodeRabbit review body structure, section parsing, "Prompt for AI Agents" usage, duplicate and "also applies to" handlingWeekly Installs
330
Repository
GitHub Stars
54
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode293
gemini-cli278
codex275
cursor269
github-copilot265
claude-code249
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
140,500 周安装
代码复杂度分析工具:Python/Go代码质量检测与重构指南
273 周安装
批量处理器技能 - 高效批量处理文档,支持PDF转换、文本提取、文件重命名
273 周安装
Cypress 自动化测试指南:E2E 与组件测试最佳实践、安装配置与故障排除
273 周安装
Antigravity Manager - AI账户管理器与代理网关,支持Gemini/Claude多账户轮换与协议转换
273 周安装
Inngest 持久化函数教程:构建容错工作流与 TypeScript 实践指南
273 周安装
AI合同审查工具 - 依据谈判手册自动分析条款、标记偏差与商业影响
273 周安装
_🟠 Major_| Should fix |
| MEDIUM | medium-priority.svg, _🛠️ Refactor suggestion_, _💡 Suggestion_, "Medium Severity" | Recommended |
| LOW | low-priority.svg, _🧹 Nitpick_, _🔧 Optional_, _🟡 Minor_, _🔵 Trivial_, _⚪ Info_, "style", "nit" | Optional |
style: commit