async-pr-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Async PR Review

异步PR评审

This skill provides a set of tools to asynchronously review a Pull Request. It will create a background job to run the project's preflight checks, execute Gemini-powered test plans, and perform a comprehensive code review using custom prompts.
This skill is designed to showcase an advanced "Agentic Asynchronous Pattern":
  1. Native Background Shells vs Headless Inference: While Gemini CLI can natively spawn and detach background shell commands (using the
    run_shell_command
    tool with
    is_background: true
    ), a standard bash background job cannot perform LLM inference. To conduct AI-driven code reviews and test generation in the background, the shell script must invoke the
    gemini
    executable headlessly using
    -p
    . This offloads the AI tasks to independent worker agents.
  2. Dynamic Git Scoping: The review scripts avoid hardcoded paths. They use
    git rev-parse --show-toplevel
    to automatically resolve the root of the user's current project.
  3. Ephemeral Worktrees: Instead of checking out branches in the user's main workspace, the skill provisions temporary git worktrees in
    .gemini/tmp/async-reviews/pr-<number>
    . This prevents git lock conflicts and namespace pollution.
  4. Agentic Evaluation (
    check-async-review.sh
    )
    : The check script outputs clean JSON/text statuses for the main agent to parse. The interactive agent itself synthesizes the final assessment dynamically from the generated log files.
该Skill提供了一套用于异步评审Pull Request(PR)的工具。它会创建一个后台任务来运行项目的预检检查、执行由Gemini驱动的测试计划,并使用自定义提示词执行全面的代码评审。
该Skill旨在展示一种高级的「Agentic Asynchronous Pattern」:
  1. 原生后台Shell与无头推理:虽然Gemini CLI可以原生生成并分离后台Shell命令(使用
    run_shell_command
    工具并设置
    is_background: true
    ),但标准的bash后台任务无法执行LLM推理。要在后台进行AI驱动的代码评审和测试生成,Shell脚本必须使用
    -p
    参数以无头模式调用
    gemini
    可执行文件。这会将AI任务卸载到独立的工作者智能体(worker agents)。
  2. 动态Git范围界定:评审脚本避免使用硬编码路径。它们使用
    git rev-parse --show-toplevel
    来自动解析用户当前项目的根目录。
  3. 临时工作树(Ephemeral Worktrees):该Skill不会在用户的主工作区中检出分支,而是在
    .gemini/tmp/async-reviews/pr-<number>
    目录下创建临时的Git工作树。这可以避免Git锁定冲突和命名空间污染。
  4. 智能体评估(
    check-async-review.sh
    :检查脚本会输出清晰的JSON/文本状态,供主智能体解析。交互式智能体本身会根据生成的日志文件动态合成最终评估结果。

Workflow

工作流程

  1. Determine Action: Establish whether the user wants to start a new async review or check the status of an existing one.
    • If the user says "start an async review for PR #123" or similar, proceed to Start Review.
    • If the user says "check the status of my async review for PR #123" or similar, proceed to Check Status.
  1. 确定操作:判断用户是想要启动新的异步评审,还是查看现有评审的状态。
    • 如果用户说“为PR #123启动异步评审”或类似表述,进入启动评审环节。
    • 如果用户说“查看我为PR #123启动的异步评审状态”或类似表述,进入查看状态环节。

Start Review

启动评审

If the user wants to start a new async PR review:
  1. Ask the user for the PR number if they haven't provided it.
  2. Execute the
    async-review.sh
    script, passing the PR number as the first argument. Be sure to run it with the
    is_background
    flag set to true to ensure it immediately detaches.
    bash
    .gemini/skills/async-pr-review/scripts/async-review.sh <PR_NUMBER>
  3. Inform the user that the tasks have started successfully and they can check the status later.
如果用户想要启动新的异步PR评审:
  1. 如果用户未提供PR编号,询问用户获取该编号。
  2. 执行
    async-review.sh
    脚本,将PR编号作为第一个参数传入。确保设置
    is_background
    标志为true,以确保脚本立即分离到后台运行。
    bash
    .gemini/skills/async-pr-review/scripts/async-review.sh <PR_NUMBER>
  3. 告知用户任务已成功启动,他们可以稍后查看状态。

Check Status

查看状态

If the user wants to check the status or view the final assessment of a previously started async review:
  1. Ask the user for the PR number if they haven't provided it.
  2. Execute the
    check-async-review.sh
    script, passing the PR number as the first argument:
    bash
    .gemini/skills/async-pr-review/scripts/check-async-review.sh <PR_NUMBER>
  3. Evaluate Output: Read the output from the script.
    • If the output contains
      STATUS: IN_PROGRESS
      , tell the user which tasks are still running.
    • If the output contains
      STATUS: COMPLETE
      , use your file reading tools (
      read_file
      ) to retrieve the contents of
      final-assessment.md
      ,
      review.md
      ,
      pr-diff.diff
      ,
      npm-test.log
      , and
      test-execution.log
      files from the
      LOG_DIR
      specified in the output.
    • Final Assessment: Read those files, synthesize their results, and give the user a concise recommendation on whether the PR builds successfully, passes tests, and if you recommend they approve it based on the review.
如果用户想要查看之前启动的异步评审的状态或最终评估结果:
  1. 如果用户未提供PR编号,询问用户获取该编号。
  2. 执行
    check-async-review.sh
    脚本,将PR编号作为第一个参数传入:
    bash
    .gemini/skills/async-pr-review/scripts/check-async-review.sh <PR_NUMBER>
  3. 评估输出:读取脚本的输出内容。
    • 如果输出包含
      STATUS: IN_PROGRESS
      ,告知用户仍在运行的任务有哪些。
    • 如果输出包含
      STATUS: COMPLETE
      ,使用文件读取工具(
      read_file
      )从输出中指定的
      LOG_DIR
      目录下获取
      final-assessment.md
      review.md
      pr-diff.diff
      npm-test.log
      test-execution.log
      文件的内容。
    • 最终评估:读取这些文件,综合其结果,向用户提供简洁的建议,说明该PR是否构建成功、通过测试,以及基于评审结果是否建议批准该PR。