gemini-review-integrator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGemini Review Integrator
Gemini评审整合工具
Integrate Gemini Code Assist review suggestions into the pr-review-and-document PR comment.
将Gemini Code Assist的评审建议整合到pr-review-and-document的PR评论中。
When to Use
使用场景
Invoke this skill when:
- A PR has both Gemini Code Assist reviews and a pr-review-and-document comment
- Need to consolidate all review feedback into a single location
- Want to track Gemini suggestions alongside Claude's PR review
当以下情况时调用此Skill:
- PR同时包含Gemini Code Assist评审和pr-review-and-document评论
- 需要将所有评审反馈整合到单一位置
- 希望将Gemini建议与Claude的PR评审一起跟踪
Workflow
工作流
Step 1: Get PR Number and Verify Prerequisites (Cache-Aware)
步骤1:获取PR编号并验证前提条件(支持缓存)
bash
PR_NUMBER=$("${CLAUDE_PLUGIN_ROOT}/scripts/get-pr-number.sh")This uses the branch-to-PR-number cache () with 1-hour TTL, falling back to GitHub API on cache miss.
branch-map.jsonIf no PR exists, inform the user and stop.
Verify pr-review-and-document comment exists:
bash
${CLAUDE_PLUGIN_ROOT}/scripts/find-review-comment.sh "$PR_NUMBER"If no review comment exists, inform the user to run skill first.
pr-review-and-documentbash
PR_NUMBER=$("${CLAUDE_PLUGIN_ROOT}/scripts/get-pr-number.sh")这会使用分支到PR编号的缓存(),TTL为1小时,缓存未命中时回退到GitHub API。
branch-map.json如果不存在PR,通知用户并停止操作。
验证pr-review-and-document评论是否存在:
bash
${CLAUDE_PLUGIN_ROOT}/scripts/find-review-comment.sh "$PR_NUMBER"如果没有评审评论,通知用户先运行 Skill。
pr-review-and-documentStep 2: Fetch Gemini Code Assist Comments
步骤2:获取Gemini Code Assist评论
Fetch all PR review comments (inline code comments):
bash
${CLAUDE_PLUGIN_ROOT}/scripts/fetch-gemini-comments.sh "$PR_NUMBER"The script returns JSON with Gemini suggestions, including:
- : Comment ID for deduplication
id - : high, medium, or low
priority - : Whether it's a security issue
is_security - : Whether the comment is outdated (code changed)
is_outdated - : File path
file - : Line number (null if file-level)
line - : Full comment body
body - : Extracted code suggestion (if any)
suggestion
获取所有PR评审评论(内联代码评论):
bash
${CLAUDE_PLUGIN_ROOT}/scripts/fetch-gemini-comments.sh "$PR_NUMBER"该脚本返回包含Gemini建议的JSON,包括:
- :用于去重的评论ID
id - :高、中或低
priority - :是否为安全问题
is_security - :评论是否过时(代码已更改)
is_outdated - :文件路径
file - :行号(如果是文件级评论则为null)
line - :完整评论内容
body - :提取的代码建议(如果有)
suggestion
Step 3: Filter and Deduplicate
步骤3:过滤与去重
Apply filters to Gemini suggestions:
- Exclude outdated comments: Skip comments where
is_outdated: true - Check existing integration: Parse pr-review-and-document comment metadata for
gemini_integrated_ids - Skip already integrated: Exclude comments whose IDs are in
gemini_integrated_ids
对Gemini建议应用以下过滤规则:
- 排除过时评论:跳过的评论
is_outdated: true - 检查已整合记录:解析pr-review-and-document评论元数据中的
gemini_integrated_ids - 跳过已整合内容:排除ID在中的评论
gemini_integrated_ids
Step 4: Categorize Suggestions
步骤4:建议分类
Map Gemini priorities to pr-review-and-document categories:
| Gemini Priority | PR Review Category |
|---|---|
| 🔴 Critical Issues |
| 🟡 Important Issues |
| 🟡 Important Issues |
| 💡 Suggestions |
| 💡 Suggestions |
将Gemini优先级映射到pr-review-and-document的分类:
| Gemini优先级 | PR评审分类 |
|---|---|
| 🔴 关键问题 |
| 🟡 重要问题 |
| 🟡 重要问题 |
| 💡 建议 |
| 💡 建议 |
Step 5: Format Integrated Suggestions
步骤5:格式化整合后的建议
For each new Gemini suggestion, format as:
markdown
<details>
<summary><b>N. ⚠️ [Gemini] Issue Title</b></summary>
**Source:** Gemini Code Assist
**File:** `path/to/file.ts:line`
**Problem:** Description from Gemini comment.
**Suggested Fix:**
```suggestion
code hereKey formatting rules:
- Prefix title with to identify source
[Gemini] - Use status indicator (pending review)
⚠️ - Include line
**Source:** Gemini Code Assist - Preserve Gemini's suggestion code block if present
每个新的Gemini建议按以下格式处理:
markdown
<details>
<summary><b>N. ⚠️ [Gemini] 问题标题</b></summary>
**来源:** Gemini Code Assist
**文件:** `path/to/file.ts:line`
**问题描述:** Gemini评论中的描述内容。
**建议修复方案:**
```suggestion
代码内容关键格式规则:
- 标题前缀添加以标识来源
[Gemini] - 使用状态指示器(待评审)
⚠️ - 包含行
**来源:** Gemini Code Assist - 保留Gemini的建议代码块(如果存在)
Step 6: Update PR Review Comment
步骤6:更新PR评审评论
- Fetch existing pr-review-and-document comment body
- Parse metadata JSON from block
<!-- pr-review-metadata ... --> - Update metadata:
- Add array with newly integrated comment IDs
gemini_integrated_ids - Increment issue counts in object
issues - Update timestamp
updated_at
- Add
- Insert new Gemini issues into appropriate sections (Critical, Important, Suggestions)
- Renumber existing issues to accommodate new entries
Pipe updated content to via :
cache-write-comment.sh--stdinbash
echo "$UPDATED_CONTENT" | ${CLAUDE_PLUGIN_ROOT}/scripts/cache-write-comment.sh --stdin "$PR_NUMBER"This updates local cache and syncs to GitHub in one step, without temp files.
- 获取现有的pr-review-and-document评论内容
- 解析块中的元数据JSON
<!-- pr-review-metadata ... --> - 更新元数据:
- 添加数组,包含新整合的评论ID
gemini_integrated_ids - 递增对象中的问题计数
issues - 更新时间戳
updated_at
- 添加
- 将新的Gemini问题插入到对应的分类部分(关键问题、重要问题、建议)
- 重新编号现有问题以容纳新条目
通过将更新后的内容传递给:
--stdincache-write-comment.shbash
echo "$UPDATED_CONTENT" | ${CLAUDE_PLUGIN_ROOT}/scripts/cache-write-comment.sh --stdin "$PR_NUMBER"这会一步更新本地缓存并同步到GitHub,无需临时文件。
Step 7: Report Integration Results
步骤7:报告整合结果
Summarize what was integrated:
Gemini Review Integration Complete:
- Found: X Gemini comments
- Outdated (skipped): Y
- Already integrated (skipped): Z
- Newly integrated: W
- Critical: A
- Important: B
- Suggestions: C总结整合内容:
Gemini评审整合完成:
- 发现: X条Gemini评论
- 已过时(已跳过): Y条
- 已整合(已跳过): Z条
- 新整合: W条
- 关键问题: A条
- 重要问题: B条
- 建议: C条Metadata Schema Extension
元数据扩展 schema
The pr-review-and-document metadata is extended with:
json
{
"gemini_integrated_ids": [2726014213, 2726014217, ...],
"gemini_integration_date": "2026-01-26T12:00:00Z"
}This enables:
- Tracking which Gemini comments have been integrated
- Preventing duplicate integration across multiple runs
- Audit trail for integrated suggestions
pr-review-and-document的元数据扩展如下:
json
{
"gemini_integrated_ids": [2726014213, 2726014217, ...],
"gemini_integration_date": "2026-01-26T12:00:00Z"
}这实现了:
- 跟踪哪些Gemini评论已被整合
- 防止多次运行时重复整合
- 为整合的建议提供审计追踪
Gemini Comment Structure
Gemini评论结构
Gemini Code Assist comments have these characteristics:
Priority Indicators (in body):
- - High priority
 - - Medium priority
 - or
- Security-related
Outdated Detection:
- GitHub API field indicates the code has changed
position: null - These comments should be skipped as they may no longer apply
Code Suggestions:
- Enclosed in ````suggestion` blocks
- Should be preserved in integration
Gemini Code Assist评论具有以下特征:
优先级指示器(在内容中):
- - 高优先级
 - - 中优先级
 - 或
- 安全相关
过时检测:
- GitHub API字段表示代码已更改
position: null - 这些评论应被跳过,因为可能不再适用
代码建议:
- 包裹在````suggestion`块中
- 整合时应保留
Handling Multiple Gemini Review Rounds
处理多轮Gemini评审
Gemini may perform multiple review rounds on a PR. The integration handles this by:
- ID-based deduplication: Each comment has a unique ID
- Cumulative tracking: grows with each integration
gemini_integrated_ids - New comments only: Only comments not in are processed
gemini_integrated_ids
To re-integrate after Gemini runs another review:
- Run this skill again
- Only new comments will be added
- Previously integrated comments remain unchanged
Gemini可能会对PR进行多轮评审。本整合工具通过以下方式处理:
- 基于ID的去重: 每个评论都有唯一ID
- 累积跟踪: 随每次整合增长
gemini_integrated_ids - 仅处理新评论: 仅处理不在中的评论
gemini_integrated_ids
在Gemini完成新一轮评审后重新整合:
- 再次运行此Skill
- 仅添加新评论
- 已整合的评论保持不变
Status Indicators for Gemini Issues
Gemini问题的状态指示器
| Indicator | Meaning |
|---|---|
| ⚠️ | Pending review (newly integrated from Gemini) |
| ✅ | Fixed / Resolved |
| ⏭️ | Deferred / Not applicable |
| 🔴 | Escalated to blocking |
Initial status for all Gemini integrations is (pending review).
⚠️| 指示器 | 含义 |
|---|---|
| ⚠️ | 待评审(从Gemini新整合的内容) |
| ✅ | 已修复/已解决 |
| ⏭️ | 已推迟/不适用 |
| 🔴 | 升级为阻塞问题 |
所有Gemini整合内容的初始状态为(待评审)。
⚠️Example Integration
整合示例
Before (pr-review-and-document comment):
markdown
undefined整合前(pr-review-and-document评论):
markdown
undefined🟡 Important Issues
🟡 重要问题
<details>
<summary><b>1. ✅ Some Claude-found issue</b></summary>
...
</details>
```
After integration:
markdown
undefined<details>
<summary><b>1. ✅ 某个Claude发现的问题</b></summary>
...
</details>
```
整合后:
markdown
undefined🟡 Important Issues
🟡 重要问题
<details>
<summary><b>1. ✅ Some Claude-found issue</b></summary>
...
</details>
<details>
<summary><b>2. ⚠️ [Gemini] Suppress stderr hides errors</b></summary>
</details>
```
Source: Gemini Code Assist
File:
.claude/skills/pr-review-and-document/scripts/find-review-comment.sh:19Problem: Suppressing stderr with can hide important underlying errors.
2>/dev/nullSuggested Fix:
suggestion
PR_NUMBER=$(gh pr view --json number -q '.number' || echo "")<details>
<summary><b>1. ✅ 某个Claude发现的问题</b></summary>
...
</details>
<details>
<summary><b>2. ⚠️ [Gemini] 抑制stderr会隐藏错误</b></summary>
</details>
```
来源: Gemini Code Assist
文件:
.claude/skills/pr-review-and-document/scripts/find-review-comment.sh:19问题描述: 使用抑制stderr会隐藏重要的底层错误。
2>/dev/null建议修复方案:
suggestion
PR_NUMBER=$(gh pr view --json number -q '.number' || echo "")Validation Checklist
验证检查清单
Before completing integration:
- PR number correctly identified
- pr-review-and-document comment exists
- Gemini comments fetched successfully
- Outdated comments filtered out
- Previously integrated comments skipped
- New comments categorized correctly
- Metadata updated with integrated IDs
- Issue counts updated accurately
- Comment posted successfully
完成整合前需确认:
- PR编号已正确识别
- pr-review-and-document评论存在
- Gemini评论已成功获取
- 过时评论已过滤
- 已整合评论已跳过
- 新评论已正确分类
- 元数据已更新整合ID
- 问题计数已准确更新
- 评论已成功发布
Error Handling
错误处理
| Error | Action |
|---|---|
| No PR found | Inform user, stop |
| No review comment | Suggest running pr-review-and-document first |
| No Gemini comments | Inform user, nothing to integrate |
| API failure | Report error with details |
| All comments outdated | Inform user, nothing to integrate |
| All comments already integrated | Inform user, up to date |
| 错误 | 处理动作 |
|---|---|
| 未找到PR | 通知用户,停止操作 |
| 无评审评论 | 建议先运行pr-review-and-document |
| 无Gemini评论 | 通知用户,无内容可整合 |
| API调用失败 | 报告错误详情 |
| 所有评论均过时 | 通知用户,无内容可整合 |
| 所有评论均已整合 | 通知用户,内容已最新 |