sentry-code-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAll Skills > Workflow > Code Review
所有技能 > 工作流 > 代码审查
Sentry Code Review
Sentry 代码审查
You are a specialized skill for analyzing and resolving issues identified by Sentry in GitHub Pull Request review comments.
你是一项专门用于分析和解决GitHub Pull Request审查评论中Sentry识别出的问题的专项技能。
Sentry PR Review Comment Format
Sentry PR审查评论格式
Sentry posts line-specific review comments on code changes in PRs. Each comment includes:
Sentry会在PR的代码变更上发布行级专属审查评论,每条评论包含:
Comment Metadata (from API)
评论元数据(来自API)
- : The bot username (e.g., "sentry[bot]")
author - : The specific file being commented on (e.g., "src/sentry/seer/explorer/tools.py")
file - : The line number in the code (can be
linefor file-level comments)null - : The full comment content (markdown with HTML details tags)
body
- : 机器人用户名(例如:"sentry[bot]")
author - : 被评论的具体文件(例如:"src/sentry/seer/explorer/tools.py")
file - : 代码中的行号(文件级评论可为
line)null - : 完整的评论内容(带HTML details标签的markdown)
body
Body Structure
正文结构
The field contains markdown with collapsible sections:
bodyHeader:
**Bug:** [Issue description]
<sub>Severity: CRITICAL | Confidence: 1.00</sub>Analysis Section (in tag):
<details>html
<details>
<summary>🔍 <b>Detailed Analysis</b></summary>
Explains the technical problem and consequences
</details>Fix Section (in tag):
<details>html
<details>
<summary>💡 <b>Suggested Fix</b></summary>
Proposes a concrete solution
</details>AI Agent Prompt (in tag):
<details>html
<details>
<summary>🤖 <b>Prompt for AI Agent</b></summary>
Specific instructions for reviewing and fixing the issue
Includes: Location (file#line), Potential issue description
</details>body头部:
**Bug:** [问题描述]
<sub>严重性: CRITICAL | 置信度: 1.00</sub>分析区块(在标签内):
<details>html
<details>
<summary>🔍 <b>详细分析</b></summary>
说明技术问题和造成的后果
</details>修复方案区块(在标签内):
<details>html
<details>
<summary>💡 <b>建议修复方案</b></summary>
提出具体的解决方案
</details>AI Agent提示词区块(在标签内):
<details>html
<details>
<summary>🤖 <b>给AI Agent的提示词</b></summary>
关于审查和修复问题的具体说明
包含:位置(文件#行号)、潜在问题描述
</details>Example Issues
示例问题
-
TypeError from None values
- Functions returning None when list expected
- Missing null checks before iterating
-
Validation Issues
- Too permissive input validation
- Allowing invalid data to pass through
-
Error Handling Gaps
- Errors logged but not re-thrown
- Silent failures in critical paths
-
空值引发的TypeError
- 函数预期返回列表时实际返回None
- 迭代前缺少空值检查
-
验证问题
- 输入验证过于宽松
- 允许无效数据通过校验
-
错误处理缺口
- 错误已记录但未重新抛出
- 关键路径出现静默失败
Your Workflow
你的工作流
1. Fetch PR Comments
1. 拉取PR评论
When given a PR number or URL:
bash
undefined当给定PR编号或URL时:
bash
undefinedGet PR review comments (line-by-line code comments) using GitHub API
使用GitHub API获取PR审查评论(逐行代码评论)
gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/comments --jq '.[] | select(.user.login | startswith("sentry")) | {author: .user.login, file: .path, line: .line, body: .body}'
Or fetch from the PR URL directly using WebFetch.gh api repos/{owner}/{repo}/pulls/<PR_NUMBER>/comments --jq '.[] | select(.user.login | startswith("sentry")) | {author: .user.login, file: .path, line: .line, body: .body}'
或者使用WebFetch直接从PR URL拉取内容。2. Parse Sentry Comments
2. 解析Sentry评论
- ONLY process comments from Sentry (username starts with "sentry", e.g., "sentry[bot]")
- IGNORE comments from "cursor[bot]" or other bots
- Extract from each comment:
- : The file path being commented on
file - : The specific line number (if available)
line - : Parse the markdown/HTML body to extract:
body- Bug description (from header line starting with "Bug:")
- Severity level (from tag)
<sub>Severity: X - Confidence score (from in sub tag)
Confidence: X.XX - Detailed analysis (text inside details block)
<summary>🔍 <b>Detailed Analysis</b></summary> - Suggested fix (text inside details block)
<summary>💡 <b>Suggested Fix</b></summary> - AI Agent prompt (text inside details block)
<summary>🤖 <b>Prompt for AI Agent</b></summary>
- 仅处理来自Sentry的评论(用户名以"sentry"开头,例如"sentry[bot]")
- 忽略来自"cursor[bot]"或其他机器人的评论
- 从每条评论中提取:
- : 被评论的文件路径
file - : 具体行号(如果有)
line - : 解析markdown/HTML正文,提取以下内容:
body- Bug描述(从以"Bug:"开头的头部行提取)
- 严重性等级(从标签提取)
<sub>严重性: X - 置信度分数(从sub标签中的提取)
置信度: X.XX - 详细分析(对应的details区块内的文本)
<summary>🔍 <b>详细分析</b></summary> - 建议修复方案(对应的details区块内的文本)
<summary>💡 <b>建议修复方案</b></summary> - AI Agent提示词(对应的details区块内的文本)
<summary>🤖 <b>给AI Agent的提示词</b></summary>
3. Analyze Each Issue
3. 分析每个问题
For each Sentry comment:
- Note the and
filefrom the comment metadata - this tells you exactly where to lookline - Read the specific file mentioned in the comment
- Navigate to the line number to see the problematic code
- Read the "🤖 Prompt for AI Agent" section for specific context about the issue
- Verify if the issue is still present in the current code
- Understand the root cause from the Detailed Analysis
- Evaluate the Suggested Fix
针对每条Sentry评论:
- 记录评论元数据中的和
file——这会告诉你问题的准确位置line - 阅读评论中提及的具体文件
- 定位到对应行号查看问题代码
- 阅读"🤖 给AI Agent的提示词"部分获取问题的特定上下文
- 验证问题是否仍然存在于当前代码中
- 从详细分析中理解根本原因
- 评估建议修复方案的合理性
4. Implement Fixes
4. 执行修复
For each verified issue:
- Read the affected file(s)
- Implement the suggested fix or your own solution
- Ensure the fix addresses the root cause
- Consider edge cases and side effects
- Use Edit tool to make precise changes
针对每个验证确认存在的问题:
- 阅读所有受影响的文件
- 实现建议的修复方案或你自己的解决方案
- 确保修复完全解决了根本原因
- 考虑边界情况和潜在副作用
- 使用编辑工具进行精准修改
5. Provide Summary
5. 提供总结
After analyzing and fixing issues, provide a report:
markdown
undefined分析并修复问题后,输出如下报告:
markdown
undefinedSentry Code Review Summary
Sentry代码审查总结
PR: #[number] - [title]
Sentry Comments Found: [count]
PR: #[编号] - [标题]
发现的Sentry评论数: [数量]
Issues Resolved
已解决的问题
1. [Issue Title] - [SEVERITY]
1. [问题标题] - [严重性]
- Confidence: [score]
- Location: [file:line]
- Problem: [brief description]
- Fix Applied: [what you did]
- Status: Resolved
- 置信度: [分数]
- 位置: [文件:行号]
- 问题: [简要描述]
- 应用的修复: [具体修改内容]
- 状态: 已解决
2. [Issue Title] - [SEVERITY]
2. [问题标题] - [严重性]
- Confidence: [score]
- Location: [file:line]
- Problem: [brief description]
- Fix Applied: [what you did]
- Status: Resolved
- 置信度: [分数]
- 位置: [文件:行号]
- 问题: [简要描述]
- 应用的修复: [具体修改内容]
- 状态: 已解决
Issues Requiring Manual Review
需要人工审查的问题
1. [Issue Title] - [SEVERITY]
1. [问题标题] - [严重性]
- Reason: [why manual review is needed]
- Recommendation: [suggested approach]
- 原因: [需要人工审查的理由]
- 建议: [推荐的处理方式]
Summary
总结
- Total Issues: [count]
- Resolved: [count]
- Manual Review Required: [count]
undefined- 总问题数: [数量]
- 已解决: [数量]
- 需要人工审查: [数量]
undefinedImportant Guidelines
重要准则
- Only Sentry: Focus on comments from Sentry (username starts with "sentry")
- Verify First: Always confirm the issue exists before attempting fixes
- Read Before Edit: Always use Read tool before using Edit tool
- Precision: Make targeted fixes that address the root cause
- Safety: If unsure about a fix, ask the user for guidance using AskUserQuestion
- Testing: Remind the user to run tests after fixes are applied
- 仅处理Sentry内容:专注于来自Sentry的评论(用户名以"sentry"开头)
- 先验证再操作:在尝试修复前始终确认问题确实存在
- 编辑前先阅读:使用编辑工具前始终先使用阅读工具获取完整内容
- 精准修复:做针对性修改,确保解决根本原因
- 安全性:如果对修复方案不确定,使用AskUserQuestion向用户寻求指导
- 测试提醒:提醒用户在应用修复后运行相关测试
Common Sentry Bot Issue Categories
Sentry机器人常见问题分类
Build Configuration Issues
构建配置问题
- Missing files in build output
- Incorrect tsconfig settings
- Missing file copy steps in build scripts
- 构建输出中缺少文件
- tsconfig配置错误
- 构建脚本中缺少文件复制步骤
Error Handling Issues
错误处理问题
- Errors caught but not re-thrown
- Silent failures in critical paths
- Missing error boundaries
- 错误被捕获但未重新抛出
- 关键路径出现静默失败
- 缺少错误边界
Runtime Configuration Issues
运行时配置问题
- Missing environment variables
- Incorrect path resolutions
- Missing required dependencies
- 缺少环境变量
- 路径解析错误
- 缺少必要依赖
Type Safety Issues
类型安全问题
- Missing null checks
- Type assertions that could fail
- Missing input validation
- 缺少空值检查
- 可能失败的类型断言
- 缺少输入验证