pr-review-response

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PR Review Response

PR评论响应

This skill helps you extract comments from a GitHub Pull Request and act on the feedback.
本技能可帮助你从GitHub Pull Request中提取评论并根据反馈采取行动。

Input

输入

Accept a GitHub PR URL in the format:
https://github.com/{owner}/{repo}/pull/{number}
Parse the URL to extract:
  • owner
    : Repository owner
  • repo
    : Repository name
  • number
    : PR number
接受格式为
https://github.com/{owner}/{repo}/pull/{number}
的GitHub PR URL
解析URL以提取:
  • owner
    :仓库所有者
  • repo
    :仓库名称
  • number
    :PR编号

Extracting Comments

提取评论

Use the
gh
CLI to fetch all types of PR comments:
使用
gh
CLI获取所有类型的PR评论:

1. Review Comments (inline comments on code)

1. 审核评论(代码上的行内评论)

bash
gh api repos/{owner}/{repo}/pulls/{number}/comments
These comments include:
  • path
    : File path the comment references
  • line
    or
    original_line
    : Line number
  • body
    : Comment text
  • diff_hunk
    : Code context
bash
gh api repos/{owner}/{repo}/pulls/{number}/comments
这些评论包含:
  • path
    :评论关联的文件路径
  • line
    original_line
    :行号
  • body
    :评论内容
  • diff_hunk
    :代码上下文

2. PR Reviews (approval/request changes with summary)

2. PR审核(带总结的批准/修改请求)

bash
gh api repos/{owner}/{repo}/pulls/{number}/reviews
These include:
  • body
    : Review summary
  • state
    : APPROVED, CHANGES_REQUESTED, COMMENTED
bash
gh api repos/{owner}/{repo}/pulls/{number}/reviews
这些内容包含:
  • body
    :审核总结
  • state
    :APPROVED(已批准)、CHANGES_REQUESTED(需要修改)、COMMENTED(仅评论)

3. General PR Comments (conversation thread)

3. 通用PR评论(对话线程)

bash
gh api repos/{owner}/{repo}/issues/{number}/comments
These are discussion comments not tied to specific lines.
bash
gh api repos/{owner}/{repo}/issues/{number}/comments
这些是不关联到特定代码行的讨论类评论。

Processing Comments

处理评论

  1. Group by file: Organize inline comments by their
    path
    field
  2. Classify feedback by intent:
    • Change requests — explicit directives to modify code (e.g. "please change", "should be", "fix", "update")
    • Open questions — inquiries that require investigation or clarification
    • Enhancement suggestions — non-blocking recommendations for improvement
  3. Prioritize: Address blocking comments (from CHANGES_REQUESTED reviews) first
  1. 按文件分组:根据
    path
    字段将行内评论分类整理
  2. 按意图分类反馈
    • 修改请求 —— 明确要求修改代码的指令(例如“请修改”、“应该是”、“修复”、“更新”)
    • 开放式问题 —— 需要调查或澄清的疑问
    • 优化建议 —— 非阻塞性的改进建议
  3. 优先级排序:优先处理来自CHANGES_REQUESTED类型审核的阻塞性评论

Acting on Feedback

根据反馈采取行动

For each actionable comment:
  1. Read the referenced file to understand the current code
  2. Fix problems at the root: Don't apply superficial fixes. Investigate and address the underlying cause of the issue, not just the symptom mentioned in the comment
  3. Apply requested changes using the Edit tool
  4. For questions: Investigate and provide answers or make clarifying changes
  5. For suggestions: Evaluate and implement if appropriate
  6. Add tests for edge cases: If the feedback identifies an edge case and the project has testing already set up, add a test to cover that edge case to prevent regression
对于每个可执行的评论:
  1. 阅读关联文件以理解当前代码
  2. 从根源解决问题:不要仅做表面修复。调查并解决问题的根本原因,而不只是评论中提到的症状
  3. 使用编辑工具应用所需修改
  4. 针对问题:调查并提供答案或做出澄清性修改
  5. 针对建议:评估后酌情实施
  6. 添加边缘情况测试:如果反馈指出了边缘情况,且项目已设置测试机制,添加测试覆盖该边缘情况以防止回归

Example Workflow

示例流程

Given
https://github.com/acme/app/pull/42
:
  1. Extract: owner=
    acme
    , repo=
    app
    , number=
    42
  2. Fetch comments:
    bash
    gh api repos/acme/app/pulls/42/comments
    gh api repos/acme/app/pulls/42/reviews
    gh api repos/acme/app/issues/42/comments
  3. Parse the JSON responses to identify feedback
  4. For each comment with a file path, read that file and apply changes
  5. Summarize what was addressed
给定URL
https://github.com/acme/app/pull/42
  1. 提取信息:owner=
    acme
    ,repo=
    app
    ,number=
    42
  2. 获取评论:
    bash
    gh api repos/acme/app/pulls/42/comments
    gh api repos/acme/app/pulls/42/reviews
    gh api repos/acme/app/issues/42/comments
  3. 解析JSON响应以识别反馈内容
  4. 对于每个关联了文件路径的评论,读取对应文件并应用修改
  5. 总结已处理的内容

Output

输出

After processing, provide a summary of:
  • Number of comments found
  • Actions taken for each comment
  • Any comments that need clarification or manual review
处理完成后,提供以下内容的总结:
  • 找到的评论数量
  • 针对每条评论采取的行动
  • 任何需要澄清或手动审核的评论