以下为本文档的中文说明

该技能用于实现异步的Pull Request代码审查工作流。它利用AI能力对PR中的代码变更进行自动分析,发现潜在问题、安全漏洞和代码质量缺陷,并以异步方式提供审查意见。适用于开发团队希望在CI/CD流水线中集成自动化代码审查、提高代码质量和团队协作效率的场景,有效减轻人工审查的负担。异步处理机制使得代码审查不会阻塞开发流程,开发人员可以在收到审查结果后再处理反馈,实现了质量保障与开发效率的平衡。该技能将AI能力集成到Pull Request审查流程中,实现了自动化的代码质量检查。它能够自动分析PR中的代码变更,检测潜在的安全漏洞(如SQL注入、XSS攻击)、代码质量问题(重复代码、复杂度过高)、最佳实践违反(命名规范、设计模式)和性能隐患。与同步审查不同,异步处理机制意味着AI分析在后台进行,不会阻塞开发流程,开发人员可以在方便的时候查看审查结果。技能还支持自定义审查规则和严重级别配置,团队可以根据自身需求调整审查的严格程度,在质量保障与开发效率之间取得平衡。该技能通过AI技术实现自动化的Pull Request审查,将代码质量检查融入日常开发流程。技能支持多种审查规则的配置,团队可以根据项目特点定制检查项的启用和禁用,以及各检查项的严重级别。在安全方面,技能能够检测常见的安全漏洞,包括SQL注入、跨站脚本等;在代码质量方面,技能关注代码重复率、圈复杂度、异常处理完整性和API设计一致性等方面。异步处理的特性使得审查不会阻塞开发流程,开发人员可以在方便时查看结果并处理反馈。


Async PR Review

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.

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.

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.
    .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.

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:
    .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.3e:[“","","","L41”,null,{“content”:“$42”,“frontMatter”:{“name”:“async-pr-review”,“description”:“Trigger this skill when the user wants to start an asynchronous PR review, run background checks on a PR, or check the status of a previously started async PR review.”}}]

3f:[“KaTeX parse error: Expected '}', got 'EOF' at end of input: …,"children":[["”,“div”,null,{“className”:“flex items-center justify-between border-b border-border bg-muted/30 px-4 py-2.5”,“children”:[[“KaTeX parse error: Expected '}', got 'EOF' at end of input: …","children":["”,“span”,null,{“className”:“truncate text-xs font-medium text-muted-foreground”,“children”:“同仓库更多 Skills”}]}],[“KaTeX parse error: Expected 'EOF', got '}' at position 88: …ldren":"同仓库"}]]}̲],["”,“div”,null,{“className”:“p-4 sm:p-5”,“children”:[[“","h2",null,"id":"related−skills−heading","className":"text−2xlfont−semiboldtracking−normaltext−foreground","children":"同仓库更多Skills"],["","h2",null,{"id":"related-skills-heading","className":"text-2xl font-semibold tracking-normal text-foreground","children":"同仓库更多 Skills"}],["","h2",null,"id":"relatedskillsheading","className":"text2xlfontsemiboldtrackingnormaltextforeground","children":"同仓库更多Skills"],["”,“div”,null,{“className”:“mt-4 grid gap-3 sm:grid-cols-2”,“children”:[“L43","L43","L43","L44”,“L45","L45","L45","L46”,“L47","L47","L47","L48”]}]]}]]}]

49:I[206516,[“/_next/static/chunks/051aanbhrv4br.js”,“/_next/static/chunks/0mizr60h7ayzt.js”,“/_next/static/chunks/0v9lm1dmbdoo-.js”,“/_next/static/chunks/0rxr1j1j3j-.r.js”,“/_next/static/chunks/02ftybezfvqjd.js”,“/_next/static/chunks/0.v9ksvnnj8ia.js”,“/_next/static/chunks/0bn6id96nx3k.js",“/_next/static/chunks/13ybnhn37c.tc.js”,“/_next/static/chunks/0_fnrdtruz8uf.js”,“/_next/static/chunks/0r6l15utt1mwb.js”,“/_next/static/chunks/0dm9a5into854.js”,"/_next/static/chunks/07k6hqoibtcn.js”,“/next/static/chunks/0b4cao.4y…j.js”,“/_next/static/chunks/02i-n28z7kjd0.js”],“default”]

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐