review-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReview PR
审核PR
Perform a comprehensive code review of a pull request or branch diff using the knowledge graph.
Token optimization: Before starting, call for the optimized workflow. Never include full files unless explicitly asked.
get_docs_section_tool(section_name="review-pr")借助知识图谱对拉取请求(PR)或分支差异进行全面的代码审核。
Token优化:开始之前,请调用获取优化后的工作流程。除非明确要求,否则切勿包含完整文件内容。
get_docs_section_tool(section_name="review-pr")Steps
步骤
-
Identify the changes for the PR:
- If a PR number or branch is provided, use to get changed files
git diff main...<branch> - Otherwise auto-detect from the current branch vs main/master
- If a PR number or branch is provided, use
-
Update the graph by callingto ensure the graph reflects the current state.
build_or_update_graph_tool(base="main") -
Get the full review context by calling:
get_review_context_tool(base="main")- This uses (or the specified base branch) as the diff base
main - Returns all changed files across all commits in the PR
- This uses
-
Analyze impact by calling:
get_impact_radius_tool(base="main")- Review the blast radius across the entire PR
- Identify high-risk areas (widely depended-upon code)
-
Deep-dive each changed file:
- Read the full source of files with significant changes
- Use for high-risk functions
query_graph_tool(pattern="callers_of", target=<func>) - Use to verify test coverage
query_graph_tool(pattern="tests_for", target=<func>) - Check for breaking changes in public APIs
-
Generate structured review output:
## PR Review: <title> ### Summary <1-3 sentence overview> ### Risk Assessment - **Overall risk**: Low / Medium / High - **Blast radius**: X files, Y functions impacted - **Test coverage**: N changed functions covered / M total ### File-by-File Review #### <file_path> - Changes: <description> - Impact: <who depends on this> - Issues: <bugs, style, concerns> ### Missing Tests - <function_name> in <file> - no test coverage found ### Recommendations 1. <actionable suggestion> 2. <actionable suggestion>
-
确定PR中的变更:
- 如果提供了PR编号或分支,使用获取变更文件
git diff main...<branch> - 否则自动检测当前分支与main/master分支的差异
- 如果提供了PR编号或分支,使用
-
更新图谱:调用确保图谱反映当前状态。
build_or_update_graph_tool(base="main") -
获取完整审核上下文:调用:
get_review_context_tool(base="main")- 以(或指定的基准分支)作为差异基准
main - 返回PR中所有提交涉及的所有变更文件
- 以
-
分析影响:调用:
get_impact_radius_tool(base="main")- 审核整个PR的影响范围(blast radius)
- 识别高风险区域(被广泛依赖的代码)
-
深入分析每个变更文件:
- 阅读有重大变更的文件的完整源码
- 对高风险函数,使用
query_graph_tool(pattern="callers_of", target=<func>) - 使用验证测试覆盖率
query_graph_tool(pattern="tests_for", target=<func>) - 检查公共API是否存在破坏性变更
-
生成结构化审核输出:
## PR审核:<标题> ### 摘要 <1-3句话概述> ### 风险评估 - **整体风险**:低/中/高 - **影响范围**:影响X个文件,Y个函数 - **测试覆盖率**:已覆盖N个变更函数 / 共M个变更函数 ### 逐文件审核 #### <文件路径> - 变更内容:<描述> - 影响:<依赖此代码的对象> - 问题:<bug、风格、关注点> ### 缺失测试 - <函数名> 在 <文件> 中 - 未找到测试覆盖 ### 建议 1. <可执行的建议> 2. <可执行的建议>
Tips
提示
- For large PRs, focus on the highest-impact files first (most dependents)
- Use to find related code the PR might have missed
semantic_search_nodes_tool - Check if renamed/moved functions have updated all callers
- 对于大型PR,优先关注影响最大的文件(依赖者最多的文件)
- 使用查找PR可能遗漏的相关代码
semantic_search_nodes_tool - 检查重命名/移动的函数是否已更新所有调用方