async-pr-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAsync 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":
- Native Background Shells vs Headless Inference: While Gemini CLI can natively spawn and detach background shell commands (using the tool with
run_shell_command), 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 theis_background: trueexecutable headlessly usinggemini. This offloads the AI tasks to independent worker agents.-p - Dynamic Git Scoping: The review scripts avoid hardcoded paths. They use to automatically resolve the root of the user's current project.
git rev-parse --show-toplevel - Ephemeral Worktrees: Instead of checking out branches in the user's main workspace, the skill provisions temporary git worktrees in . This prevents git lock conflicts and namespace pollution.
.gemini/tmp/async-reviews/pr-<number> - Agentic Evaluation (): 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.
check-async-review.sh
该Skill提供了一套用于异步评审Pull Request(PR)的工具。它会创建一个后台任务来运行项目的预检检查、执行由Gemini驱动的测试计划,并使用自定义提示词执行全面的代码评审。
该Skill旨在展示一种高级的「Agentic Asynchronous Pattern」:
- 原生后台Shell与无头推理:虽然Gemini CLI可以原生生成并分离后台Shell命令(使用工具并设置
run_shell_command),但标准的bash后台任务无法执行LLM推理。要在后台进行AI驱动的代码评审和测试生成,Shell脚本必须使用is_background: true参数以无头模式调用-p可执行文件。这会将AI任务卸载到独立的工作者智能体(worker agents)。gemini - 动态Git范围界定:评审脚本避免使用硬编码路径。它们使用来自动解析用户当前项目的根目录。
git rev-parse --show-toplevel - 临时工作树(Ephemeral Worktrees):该Skill不会在用户的主工作区中检出分支,而是在目录下创建临时的Git工作树。这可以避免Git锁定冲突和命名空间污染。
.gemini/tmp/async-reviews/pr-<number> - 智能体评估():检查脚本会输出清晰的JSON/文本状态,供主智能体解析。交互式智能体本身会根据生成的日志文件动态合成最终评估结果。
check-async-review.sh
Workflow
工作流程
- 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.
- 确定操作:判断用户是想要启动新的异步评审,还是查看现有评审的状态。
- 如果用户说“为PR #123启动异步评审”或类似表述,进入启动评审环节。
- 如果用户说“查看我为PR #123启动的异步评审状态”或类似表述,进入查看状态环节。
Start Review
启动评审
If the user wants to start a new async PR review:
- Ask the user for the PR number if they haven't provided it.
- Execute the script, passing the PR number as the first argument. Be sure to run it with the
async-review.shflag set to true to ensure it immediately detaches.is_backgroundbash.gemini/skills/async-pr-review/scripts/async-review.sh <PR_NUMBER> - Inform the user that the tasks have started successfully and they can check the status later.
如果用户想要启动新的异步PR评审:
- 如果用户未提供PR编号,询问用户获取该编号。
- 执行脚本,将PR编号作为第一个参数传入。确保设置
async-review.sh标志为true,以确保脚本立即分离到后台运行。is_backgroundbash.gemini/skills/async-pr-review/scripts/async-review.sh <PR_NUMBER> - 告知用户任务已成功启动,他们可以稍后查看状态。
Check Status
查看状态
If the user wants to check the status or view the final assessment of a previously started async review:
- Ask the user for the PR number if they haven't provided it.
- Execute the script, passing the PR number as the first argument:
check-async-review.shbash.gemini/skills/async-pr-review/scripts/check-async-review.sh <PR_NUMBER> - Evaluate Output: Read the output from the script.
- If the output contains , tell the user which tasks are still running.
STATUS: IN_PROGRESS - If the output contains , use your file reading tools (
STATUS: COMPLETE) to retrieve the contents ofread_file,final-assessment.md,review.md,pr-diff.diff, andnpm-test.logfiles from thetest-execution.logspecified in the output.LOG_DIR - 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.
- If the output contains
如果用户想要查看之前启动的异步评审的状态或最终评估结果:
- 如果用户未提供PR编号,询问用户获取该编号。
- 执行脚本,将PR编号作为第一个参数传入:
check-async-review.shbash.gemini/skills/async-pr-review/scripts/check-async-review.sh <PR_NUMBER> - 评估输出:读取脚本的输出内容。
- 如果输出包含,告知用户仍在运行的任务有哪些。
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。
- 如果输出包含