pr-checks
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePR Checks Skill
PR检查Skill
This skill runs comprehensive PR checks to ensure code quality and address review feedback on an existing pull request.
本Skill可执行全面的PR检查,确保代码质量并处理已有PR上的评审反馈。
When to Use
使用场景
Run this skill when:
- A PR has been created and CodeRabbit has posted review comments
- You want to address existing review feedback systematically
- Before requesting final review/merge on a PR
在以下场景中使用本Skill:
- 已创建PR且CodeRabbit已发布评审评论
- 你想要系统地处理现有评审反馈
- 在请求最终评审/合并PR之前
Usage
使用方法
/pr-checks/pr-checksWorkflow
工作流程
1. Analyze Current State
1. 分析当前状态
First, understand what's being reviewed:
bash
undefined首先,了解正在评审的内容:
bash
undefinedCheck current branch and status
检查当前分支和状态
git branch --show-current
git status --short
git branch --show-current
git status --short
Show diff summary vs main
显示与main分支的差异摘要
git diff --stat main...HEAD
git diff --stat main...HEAD
Get the PR number for this branch
获取当前分支对应的PR编号
gh pr view --json number,title,state
undefinedgh pr view --json number,title,state
undefined2. Review and Fix PR Description
2. 评审并完善PR描述
Ensure the PR has a proper description before addressing code comments:
bash
undefined在处理代码评论之前,确保PR具备规范的描述:
bash
undefinedView current PR description
查看当前PR描述
gh pr view --json body,title
**A good PR description should include:**
- **Summary**: 1-3 bullet points explaining what the PR does
- **Test plan**: How to verify the changes work
- **Related issues**: Links to Linear/GitHub issues (e.g., `Closes MAS-XXX`)
**If the description is missing or inadequate:**
```bashgh pr view --json body,title
**优质的PR描述应包含:**
- **摘要**:1-3个要点说明PR的作用
- **测试计划**:如何验证更改是否生效
- **相关问题**:关联Linear/GitHub问题的链接(例如:`Closes MAS-XXX`)
**若描述缺失或不完善:**
```bashUpdate the PR description
更新PR描述
gh pr edit --body "$(cat <<'EOF'
gh pr edit --body "$(cat <<'EOF'
Summary
摘要
<1-2 sentence overview of what this PR accomplishes>
<1-2句话概述本PR实现的功能>
Changes
更改内容
- <change 1: what was added/modified/removed>
- <change 2>
- <change 3>
- ...
- <更改1:新增/修改/删除的内容>
- <更改2>
- <更改3>
- ...
Technical details (if applicable)
技术细节(如适用)
<Brief explanation of implementation approach, architectural decisions, or non-obvious changes>
<简要说明实现方案、架构决策或非直观的更改>
Test plan
测试计划
- <verification step 1>
- <verification step 2>
- <edge case or error scenario tested>
- <验证步骤1>
- <验证步骤2>
- <已测试的边缘情况或错误场景>
Related issues
相关问题
Closes MAS-XXX
Closes MAS-XXX
Screenshots/recordings (if applicable)
截图/录制(如适用)
<Add screenshots for UI changes, terminal output for CLI changes>
🤖 Generated with Claude Code
EOF
)"
**Fix the title if needed** (should follow conventional commits format):
```bashUpdate PR title
更新PR标题
gh pr edit --title "feat: descriptive title here"
undefinedgh pr edit --title "feat: 描述性标题"
undefined3. Review Existing CodeRabbit Comments
3. 评审现有CodeRabbit评论
This is the primary workflow. CodeRabbit automatically reviews PRs and posts comments. Use to fetch and process them:
/pr-comments/pr-commentsThis fetches all review comments from the PR. For each CodeRabbit comment:
- Read the comment - Understand what CodeRabbit is suggesting
- Evaluate relevance - Is this a valid concern for this codebase?
- Decide action - One of:
- ✅ Implement - The suggestion is valid and worth fixing
- ❌ Skip - The suggestion doesn't apply or is too minor
- ❓ Clarify - Need more context from user before deciding
Walk through comments one by one with the user:
undefined这是核心工作流程。CodeRabbit会自动评审PR并发布评论。使用命令获取并处理这些评论:
/pr-comments/pr-comments该命令会获取PR中的所有评审评论。针对每条CodeRabbit评论:
- 阅读评论 - 理解CodeRabbit的建议
- 评估相关性 - 该建议是否适用于此代码库?
- 决定操作 - 选择以下之一:
- ✅ 采纳 - 建议合理,值得修复
- ❌ 跳过 - 建议不适用或过于次要
- ❓ 澄清 - 需要用户提供更多上下文再做决定
与用户逐一梳理评论:
undefinedCodeRabbit Comment #1 of 5
CodeRabbit评论 第1条/共5条
File:
massgen/backend/foo.py:45Original code:
python
response = client.api_call(params)
return response.dataCodeRabbit suggestion:
Consider adding error handling for the API call. The request could fail due to network issues or API errors, which would cause an unhandled exception. This is especially important since this is called from the main orchestration loop where failures could crash the entire run. [truncated - 8 more lines]
Suggested change:
python
try:
response = client.api_call(params)
return response.data
except APIError as e:
logger.error(f"API call failed: {e}")
raiseMy assessment: Valid concern - the API call could fail and there's no error handling.
Recommendation: ✅ Implement
Do you want me to:
- Implement this fix
- Skip this comment
- Need more information
**After user decides, resolve the comment on GitHub:**
```bash文件:
massgen/backend/foo.py:45原始代码:
python
response = client.api_call(params)
return response.dataCodeRabbit建议:
考虑为API调用添加错误处理。请求可能因网络问题或API错误而失败,这会导致未处理的异常。由于此代码从主编排循环中调用,失败可能会导致整个运行崩溃。 [截断 - 剩余8行]
建议更改:
python
try:
response = client.api_call(params)
return response.data
except APIError as e:
logger.error(f"API调用失败: {e}")
raise我的评估: 建议合理 - API调用可能失败且当前无错误处理。
推荐操作: ✅ 采纳
你希望我:
- 实施此修复
- 跳过此评论
- 需要更多信息
**用户决定后,在GitHub上标记评论为已解决:**
```bashIf implemented or intentionally skipped, resolve the comment thread
若已采纳或有意跳过,解决评论线程
gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "THREAD_ID"}) {
thread { isResolved }
}
}
'
Alternatively, reply to the comment explaining the action taken:
```bashgh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "THREAD_ID"}) {
thread { isResolved }
}
}
'
或者,回复评论说明已采取的操作:
```bashReply to the comment
回复评论
gh pr comment <PR_NUMBER> --body "Addressed in <commit-sha>: <brief description of fix>"
When showing comments:
- Show the **original code** being discussed
- Show the **full suggestion text** (truncate if >15 lines with "[truncated - N more lines]")
- Show the **suggested change** if CodeRabbit provided one
- Include **line numbers** for context
Wait for user approval before implementing each fix. This ensures:
- User maintains control over what changes are made
- No unnecessary changes are introduced
- Context-specific decisions can be madegh pr comment <PR_NUMBER> --body "已在<commit-sha>中处理:<修复内容简要说明>"
展示评论时:
- 显示讨论的**原始代码**
- 显示**完整建议文本**(若超过15行,使用"[截断 - 剩余N行]"截断)
- 若CodeRabbit提供了修改方案,显示**建议更改**
- 包含**行号**以提供上下文
在实施每项修复前需等待用户确认。这确保:
- 用户对所做更改拥有控制权
- 不会引入不必要的更改
- 可做出符合上下文的决策4. Run Pre-commit Hooks
4. 运行预提交钩子
After making fixes, run pre-commit to ensure code style:
bash
uv run pre-commit run --all-filesIf issues are found, fix them and commit.
修复完成后,运行预提交钩子确保代码风格符合规范:
bash
uv run pre-commit run --all-files若发现问题,修复后提交。
5. Run Tests
5. 运行测试
bash
undefinedbash
undefinedRun tests (skip expensive API tests)
运行测试(跳过耗时的API测试)
uv run pytest massgen/tests/ -v -m "not expensive and not docker" -x --tb=short
undefineduv run pytest massgen/tests/ -v -m "not expensive and not docker" -x --tb=short
undefined6. Validate Configs (if modified)
6. 验证配置(若已修改)
bash
uv run python scripts/validate_all_configs.pybash
uv run python scripts/validate_all_configs.py7. Commit and Push Fixes
7. 提交并推送修复
bash
undefinedbash
undefinedStage fixes
暂存修复内容
git add -u .
git add -u .
Commit with descriptive message
提交并添加描述性消息
git commit -m "fix: address CodeRabbit review comments
- Fix error handling in foo.py
- Add missing type hints in bar.py
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com"
git commit -m "fix: 处理CodeRabbit评审评论
- 修复foo.py中的错误处理
- 为bar.py添加缺失的类型提示
🤖 由Claude Code生成
Co-Authored-By: Claude noreply@anthropic.com"
Push to trigger CodeRabbit re-review
推送以触发CodeRabbit重新评审
git push
undefinedgit push
undefined8. Run PR Review Toolkit (Optional)
8. 运行PR评审工具包(可选)
For additional analysis beyond CodeRabbit:
/pr-review-toolkit:review-prThis runs specialized agents for:
- Code review against project guidelines
- Silent failure detection
- Type design analysis
- Test coverage analysis
若需要CodeRabbit之外的额外分析:
/pr-review-toolkit:review-pr该命令会运行专用Agent进行以下分析:
- 对照项目规范的代码评审
- 静默故障检测
- 类型设计分析
- 测试覆盖率分析
9. (Optional) Run Local CodeRabbit Review
9.(可选)运行本地CodeRabbit评审
If you want to run a fresh local review (separate from GitHub PR comments):
bash
coderabbit --prompt-only --type committedNote: This runs CodeRabbit's own analysis locally, which may differ from the automated PR review. The GitHub PR comments from step 3 are typically more thorough since they have full PR context.
若要进行全新的本地评审(与GitHub PR评论分离):
bash
coderabbit --prompt-only --type committed注意: 此命令会在本地运行CodeRabbit的分析,结果可能与自动化PR评审不同。步骤3中的GitHub PR评论通常更全面,因为它们拥有完整的PR上下文。
10. Generate Summary
10. 生成总结
After all checks, output a summary:
undefined所有检查完成后,输出总结:
undefinedPR Checks Summary
PR检查总结
Branch: feature/my-feature
分支:feature/my-feature
- PR #123: "feat: add new feature"
- Commits ahead of main: 3
- Files changed: 5
- PR #123: "feat: 添加新功能"
- 领先main分支的提交数:3
- 修改的文件数:5
PR Description
PR描述
✅ Has summary, test plan, and issue links
✅ 包含摘要、测试计划和问题链接
CodeRabbit Comments Addressed
已处理的CodeRabbit评论
| Comment | File | Action |
|---|---|---|
| Add error handling | foo.py:45 | ✅ Implemented |
| Consider caching | bar.py:12 | ❌ Skipped (not applicable) |
| Missing type hint | baz.py:78 | ✅ Implemented |
| 评论 | 文件 | 操作 |
|---|---|---|
| 添加错误处理 | foo.py:45 | ✅ 已实施 |
| 考虑添加缓存 | bar.py:12 | ❌ 已跳过(不适用) |
| 添加缺失的类型提示 | baz.py:78 | ✅ 已实施 |
Check Results
检查结果
| Check | Status |
|---|---|
| Pre-commit | ✅ Passed |
| Tests | ✅ 47 passed |
| Config Validation | ✅ Valid |
| 检查项 | 状态 |
|---|---|
| 预提交钩子 | ✅ 通过 |
| 测试 | ✅ 47项通过 |
| 配置验证 | ✅ 有效 |
Ready for Merge?
是否可合并?
✅ All critical issues addressed, ready for final review
undefined✅ 所有关键问题已处理,可请求最终评审
undefinedReference
参考
PR Description Template
PR描述模板
markdown
undefinedmarkdown
undefinedSummary
摘要
<1-2 sentence overview of what this PR accomplishes>
<1-2句话概述本PR实现的功能>
Changes
更改内容
- <change 1: what was added/modified/removed>
- <change 2>
- <change 3>
- <更改1:新增/修改/删除的内容>
- <更改2>
- <更改3>
Technical details (if applicable)
技术细节(如适用)
<Implementation approach, architectural decisions, or non-obvious changes>
<实现方案、架构决策或非直观的更改>
Test plan
测试计划
- Step to verify functionality
- Edge cases tested
- Error scenarios handled
- 功能验证步骤
- 已测试边缘情况
- 已处理错误场景
Related issues
相关问题
Closes MAS-XXX
Closes MAS-XXX
Screenshots/recordings (if applicable)
截图/录制(如适用)
<For UI/CLI changes>
<用于UI/CLI更改>
Breaking changes (if applicable)
破坏性更改(如适用)
<What breaks and migration steps>
```
<受影响的内容及迁移步骤>
undefinedPR Title Format
PR标题格式
Use conventional commits format:
- - New feature
feat: - - Bug fix
fix: - - Documentation only
docs: - - Code change that neither fixes a bug nor adds a feature
refactor: - - Performance improvement
perf: - - Adding or updating tests
test: - - Maintenance tasks
chore:
遵循约定式提交格式:
- - 新功能
feat: - - Bug修复
fix: - - 仅文档更改
docs: - - 既不修复Bug也不添加功能的代码更改
refactor: - - 性能优化
perf: - - 添加或更新测试
test: - - 维护任务
chore:
Pre-commit Hooks
预提交钩子
- black - Python formatter (200 char line)
- isort - Import sorter
- flake8 - Style checker
- autoflake - Remove unused imports
- black - Python格式化工具(行宽200字符)
- isort - 导入排序工具
- flake8 - 风格检查工具
- autoflake - 移除未使用的导入
Test Markers
测试标记
- - Skip in quick checks
@pytest.mark.expensive - - Docker-dependent
@pytest.mark.docker
- - 快速检查中跳过
@pytest.mark.expensive - - 依赖Docker
@pytest.mark.docker
CodeRabbit Config
CodeRabbit配置
See for path-specific review instructions and exclusions.
.coderabbit.yaml查看获取路径特定的评审说明和排除规则。
.coderabbit.yaml