review-pr

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Review PR

审核PR

Perform a comprehensive code review of a pull request or branch diff using the knowledge graph.
Token optimization: Before starting, call
get_docs_section_tool(section_name="review-pr")
for the optimized workflow. Never include full files unless explicitly asked.
借助知识图谱对拉取请求(PR)或分支差异进行全面的代码审核。
Token优化:开始之前,请调用
get_docs_section_tool(section_name="review-pr")
获取优化后的工作流程。除非明确要求,否则切勿包含完整文件内容。

Steps

步骤

  1. Identify the changes for the PR:
    • If a PR number or branch is provided, use
      git diff main...<branch>
      to get changed files
    • Otherwise auto-detect from the current branch vs main/master
  2. Update the graph by calling
    build_or_update_graph_tool(base="main")
    to ensure the graph reflects the current state.
  3. Get the full review context by calling
    get_review_context_tool(base="main")
    :
    • This uses
      main
      (or the specified base branch) as the diff base
    • Returns all changed files across all commits in the PR
  4. 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)
  5. Deep-dive each changed file:
    • Read the full source of files with significant changes
    • Use
      query_graph_tool(pattern="callers_of", target=<func>)
      for high-risk functions
    • Use
      query_graph_tool(pattern="tests_for", target=<func>)
      to verify test coverage
    • Check for breaking changes in public APIs
  6. 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>
  1. 确定PR中的变更
    • 如果提供了PR编号或分支,使用
      git diff main...<branch>
      获取变更文件
    • 否则自动检测当前分支与main/master分支的差异
  2. 更新图谱:调用
    build_or_update_graph_tool(base="main")
    确保图谱反映当前状态。
  3. 获取完整审核上下文:调用
    get_review_context_tool(base="main")
    • main
      (或指定的基准分支)作为差异基准
    • 返回PR中所有提交涉及的所有变更文件
  4. 分析影响:调用
    get_impact_radius_tool(base="main")
    • 审核整个PR的影响范围(blast radius)
    • 识别高风险区域(被广泛依赖的代码)
  5. 深入分析每个变更文件
    • 阅读有重大变更的文件的完整源码
    • 对高风险函数,使用
      query_graph_tool(pattern="callers_of", target=<func>)
    • 使用
      query_graph_tool(pattern="tests_for", target=<func>)
      验证测试覆盖率
    • 检查公共API是否存在破坏性变更
  6. 生成结构化审核输出
    ## PR审核:<标题>
    
    ### 摘要
    <1-3句话概述>
    
    ### 风险评估
    - **整体风险**:低/中/高
    - **影响范围**:影响X个文件,Y个函数
    - **测试覆盖率**:已覆盖N个变更函数 / 共M个变更函数
    
    ### 逐文件审核
    #### <文件路径>
    - 变更内容:<描述>
    - 影响:<依赖此代码的对象>
    - 问题:<bug、风格、关注点>
    
    ### 缺失测试
    - <函数名> 在 <文件> 中 - 未找到测试覆盖
    
    ### 建议
    1. <可执行的建议>
    2. <可执行的建议>

Tips

提示

  • For large PRs, focus on the highest-impact files first (most dependents)
  • Use
    semantic_search_nodes_tool
    to find related code the PR might have missed
  • Check if renamed/moved functions have updated all callers
  • 对于大型PR,优先关注影响最大的文件(依赖者最多的文件)
  • 使用
    semantic_search_nodes_tool
    查找PR可能遗漏的相关代码
  • 检查重命名/移动的函数是否已更新所有调用方