pr-comments

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

GitHub PR Review Comment Manager

GitHub PR评审评论管理器

This skill automatically fetches unresolved review comments from GitHub PRs and helps you resolve them. It uses GitHub's GraphQL API and handles multiple input formats seamlessly.
本工具可自动从GitHub PR中获取未解决的评审评论,并协助您解决这些评论。它使用GitHub的GraphQL API,可无缝处理多种输入格式。

Quick Start

快速开始

Invoke the skill with any of these formats — the skill auto-detects and fetches immediately:
/pr-comments                                                              # From current branch (requires git repo)
/pr-comments https://github.com/owner/repo/pull/123                      # GitHub URL (recommended, works anywhere)
/pr-comments owner repo 123                                               # Explicit owner/repo/PR#
/pr-comments 216                                                          # PR number (requires git repo)
The skill will:
  1. Fetch automatically — No extra steps needed; comments display immediately
  2. Show pending comments — File paths, authors, comment text, and thread IDs
  3. Ready to resolve — Once you've reviewed, provide thread IDs to resolve
您可以通过以下任意格式调用本工具,工具会自动检测并立即获取评论:
/pr-comments                                                              # 从当前分支获取(需要git仓库环境)
/pr-comments https://github.com/owner/repo/pull/123                      # GitHub URL(推荐,任意场景均可使用)
/pr-comments owner repo 123                                               # 明确指定所有者/仓库/PR编号
/pr-comments 216                                                          # PR编号(需要git仓库环境)
本工具会:
  1. 自动获取评论 — 无需额外步骤,评论会立即显示
  2. 展示待处理评论 — 包含文件路径、评论者、评论内容和线程ID
  3. 支持解决操作 — 您查看评论后,可提供线程ID来标记评论为已解决

Workflow

工作流程

  1. User invokes skill with PR identifier (any format above)
    • Skill auto-detects format and fetches pending comments
    • Displays results immediately
  2. Review pending comments displayed by the skill
  3. Optionally resolve — If you want to mark threads as resolved:
    • Provide thread IDs from the output
    • Skill will ask for confirmation (resolving is destructive)
    • Threads marked as resolved
Example output:
📋 Found 3 pending comment(s) in hugcanada/insurfactapps#216

ID: PRRT_kwDOQFTPGc51yyCV | apps/IFCAdmin/app/layouts/AppMenuItem.vue:126 | @reviewer: missing icon handling
ID: PRRT_kwDOQFTPGc51yyCz | apps/IFCAdmin/app/layouts/AppMenuItem.vue:129 | @reviewer: accessibility issue
ID: PRRT_kwDOQFTPGc51yyDP | apps/IFCAdmin/app/assets/layout/_menu.scss:90 | @reviewer: empty styles
  1. 用户调用工具,提供PR标识符(上述任意格式)
    • 工具自动检测格式并获取待处理评论
    • 立即显示结果
  2. 查看工具展示的待处理评论
  3. 可选:解决评论 — 如果您想标记线程为已解决:
    • 提供输出结果中的线程ID
    • 工具会请求确认(解决操作不可撤销)
    • 标记线程为已解决
示例输出:
📋 在hugcanada/insurfactapps#216中找到3条待处理评论

ID: PRRT_kwDOQFTPGc51yyCV | apps/IFCAdmin/app/layouts/AppMenuItem.vue:126 | @reviewer: 缺少图标处理逻辑
ID: PRRT_kwDOQFTPGc51yyCz | apps/IFCAdmin/app/layouts/AppMenuItem.vue:129 | @reviewer: 无障碍访问问题
ID: PRRT_kwDOQFTPGc51yyDP | apps/IFCAdmin/app/assets/layout/_menu.scss:90 | @reviewer: 空样式

Input Formats

输入格式

The skill accepts four formats. Choose based on your situation:
OptionExampleDependenciesWhen to use
Option 0 ⭐⭐(no arguments)
gh
,
jq
,
git
When working on a PR branch (requires git repo)
Option B
https://github.com/owner/repo/pull/123
gh
,
jq
(no git needed)
Recommended — Works anywhere without a git repository
Option C
owner repo 123
gh
,
jq
(no git needed)
When you know the owner/repo details, works anywhere
Option A ⚠️
216
gh
,
jq
,
git
(requires git repo)
When you know the PR number and are in the project directory
Option 0 (Current Branch):
  • No arguments needed — just run
    /pr-comments
  • Queries GitHub for the PR associated with your current branch
  • Requires: Must run from project root (a git repo with a git remote configured)
  • Most convenient for developers actively working on a PR
Key Point: Options 0 and A both require running from a git repository with a configured git remote. For maximum portability, use Option B (GitHub URL) or C (explicit owner/repo).
Why Option A can fail:
  • If you run the script from a directory inside a monorepo or nested git structure, auto-detection might find the wrong repository
  • Solution: Use Option 0 (current branch), Option B (GitHub URL), or Option C (explicit owner/repo)
If you encounter errors, the script will automatically suggest alternative formats.
本工具支持四种输入格式,您可根据场景选择:
选项示例依赖项适用场景
选项0 ⭐⭐(无参数)
gh
jq
git
在PR分支上工作时(需要git仓库环境
选项B
https://github.com/owner/repo/pull/123
gh
jq
(无需git)
推荐 — 无需git仓库,任意场景均可使用
选项C
owner repo 123
gh
jq
(无需git)
已知所有者/仓库信息时,任意场景均可使用
选项A ⚠️
216
gh
jq
git
需要git仓库环境
已知PR编号且处于项目目录中时
选项0(当前分支):
  • 无需参数 — 只需运行
    /pr-comments
  • 查询GitHub获取与当前分支关联的PR
  • 要求: 必须从项目根目录(包含
    .git
    的目录)运行
  • 对正在处理PR的开发者来说最便捷
关键点: 选项0和A都需要在配置了git远程仓库的git目录中运行。为了获得最大的可移植性,请使用选项B(GitHub URL)或选项C(明确指定所有者/仓库)。
选项A可能失败的原因:
  • 如果您在单体仓库或嵌套git结构内的目录中运行脚本,自动检测可能会找到错误的仓库
  • 解决方案: 使用选项0(当前分支)、选项B(GitHub URL)或选项C(明确指定所有者/仓库)
如果遇到错误,脚本会自动建议替代格式。

How Claude Executes This Skill

Claude执行本工具的方式

When you invoke
/pr-comments
, Claude should:
  1. Ensure correct working directoryCRITICAL: Change to the project root (the directory containing
    .git
    ) before executing the script. This is required for auto-detection to work correctly.
  2. Parse the user's input — Extract the PR identifier in whatever format they provided
  3. Handle Plan Mode Fast-Track — If you are currently in a planning phase (e.g., Plan Mode in Gemini CLI) where shell execution is not permitted:
    • IMMEDIATELY create a minimal plan that only contains the execution of the
      fetch_pending_comments.sh
      script.
    • Call the tool to exit the planning phase (
      exit_plan_mode
      ) immediately without asking for further clarification or adding complex implementation steps.
    • Once out of the planning phase, proceed to execute the script.
  4. Auto-fetch immediately — Run the appropriate fetch script without asking for confirmation (fetching is read-only and safe)
  5. Display results — Show pending comments with thread IDs
  6. Offer next steps — Explain how to resolve threads if there are any pending
Implementation detail: The skill must execute from the project root:
bash
undefined
当您调用
/pr-comments
时,Claude应执行以下步骤:
  1. 确保工作目录正确至关重要:在执行脚本前切换到项目根目录(包含
    .git
    的目录)。这是自动检测功能正常工作的必要条件。
  2. 解析用户输入 — 提取用户提供的任意格式的PR标识符
  3. 处理计划模式快速通道 — 如果当前处于规划阶段(例如Gemini CLI中的计划模式),不允许执行shell命令:
    • 立即创建一个仅包含执行
      fetch_pending_comments.sh
      脚本的极简计划。
    • 立即调用工具退出规划阶段(
      exit_plan_mode
      ),无需进一步确认或添加复杂的实现步骤。
    • 退出规划阶段后,继续执行脚本。
  4. 立即自动获取评论 — 无需确认即可运行相应的获取脚本(获取操作是只读的,安全无风险)
  5. 展示结果 — 显示带有线程ID的待处理评论
  6. 提供下一步操作建议 — 如果有待处理评论,说明如何解决线程
实现细节: 工具必须从项目根目录执行:
bash
undefined

Change to project root FIRST (critical for auto-detection)

首先切换到项目根目录(对自动检测至关重要)

cd <project-root>
cd <project-root>

Then run the fetch script (no confirmation needed)

然后运行获取脚本(无需确认)

bash <skill-path>/scripts/fetch_pending_comments.sh <user-input>

**Why this matters:** When using Option A (PR number only), the script auto-detects the repository by running `git rev-parse --git-dir` and `gh repo view`. If run from a non-project directory, git may find the wrong repository, causing auto-detection to fail. The script will detect this and suggest using Option B (GitHub URL) or C (explicit owner/repo) instead, but execution from the project root eliminates this issue entirely.

This works for all four input formats — the script handles the detection internally.

---
bash <skill-path>/scripts/fetch_pending_comments.sh <user-input>

**为什么这很重要:** 使用选项A(仅PR编号)时,脚本通过运行`git rev-parse --git-dir`和`gh repo view`自动检测仓库。如果在非项目目录中运行,git可能会找到错误的仓库,导致自动检测失败。脚本会检测到这种情况并建议使用选项B(GitHub URL)或选项C(明确指定所有者/仓库),但从项目根目录执行可以完全避免这个问题。

这适用于所有四种输入格式 — 脚本会在内部处理检测逻辑。

---

Resolving Comments [Destructive — confirmation required]

解决评论 [操作不可撤销 — 需要确认]

If the user asks to resolve comments:
  1. Require explicit approval — Confirm which thread IDs they want to resolve
  2. Ask for permission — "I'll resolve these N threads. OK?"
  3. Execute on approval — Run
    bash scripts/resolve_comment_thread.sh ID1 ID2 ...
Resolving modifies the PR, so it requires user confirmation. Fetching does not.
如果用户要求解决评论:
  1. 要求明确批准 — 确认用户想要解决哪些线程ID
  2. 请求权限 — "我将解决这N个线程。可以吗?"
  3. 获得批准后执行 — 运行
    bash scripts/resolve_comment_thread.sh ID1 ID2 ...
解决操作会修改PR,因此需要用户确认。获取操作则不需要。

Key Principles

核心原则

  • Auto-fetch on invocation — When you invoke the skill with a PR identifier, it immediately fetches and displays comments. No manual steps required.
  • Safe operations are automatic — Read-only fetch operations run immediately without confirmation.
  • Destructive operations require approval — Only when resolving threads (which modifies the PR) does the skill ask for explicit user confirmation.
  • Multiple input formats — The skill accepts PR numbers (auto-detect), GitHub URLs, or explicit owner/repo/PR# — all work seamlessly.
  • Error suggestions — If auto-detection fails (e.g., not in a git repo), error messages suggest using alternative input formats (URL or explicit owner/repo).
  • Scope — This skill handles GitHub PR review comments only — it doesn't modify code or PR content.
  • No side effects — Each invocation is independent; fetching the same PR multiple times is safe.
  • 调用后自动获取 — 当您使用PR标识符调用工具时,它会立即获取并显示评论。无需手动步骤。
  • 安全操作自动执行 — 只读的获取操作无需确认即可立即运行。
  • 破坏性操作需要批准 — 只有解决线程(会修改PR)时,工具才会请求用户明确确认。
  • 多种输入格式 — 工具接受PR编号(自动检测)、GitHub URL或明确的所有者/仓库/PR编号 — 所有格式均可无缝使用。
  • 错误建议 — 如果自动检测失败(例如不在git仓库中),错误消息会建议使用替代输入格式(URL或明确的所有者/仓库)。
  • 适用范围 — 本工具仅处理GitHub PR评审评论 — 不修改代码或PR内容。
  • 无副作用 — 每次调用都是独立的;多次获取同一个PR是安全的。