code-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCode Review
代码评审
Orchestrates code review across GitHub PRs, GitLab MRs, and Gerrit changes. Auto-detects the platform from git remote configuration and provides focused review feedback on security, maintainability, and architectural fit.
This is a workflow skill -- it contains no scripts and instead guides the agent through a multi-step review process using the appropriate platform skill.
可协调完成跨GitHub PR、GitLab MR和Gerrit变更的代码评审工作。会从git远程配置中自动检测平台,针对安全性、可维护性和架构适配性提供针对性的评审反馈。
这是一个工作流技能——它不包含任何脚本,而是通过调用对应平台的技能引导Agent完成多步骤的评审流程。
Authentication
身份验证
This skill delegates authentication to the underlying platform skill:
- GitHub: Requires (see the github skill)
gh auth login - GitLab: Requires (see the gitlab skill)
glab auth login - Gerrit: Requires configuration (see the gerrit skill)
git-review
Ensure the relevant platform skill is authenticated before using code-review.
该技能将身份验证委托给底层的平台技能:
- GitHub:需要执行(参考github技能说明)
gh auth login - GitLab:需要执行(参考gitlab技能说明)
glab auth login - Gerrit:需要完成配置(参考gerrit技能说明)
git-review
使用代码评审功能前,请确保相关平台技能已完成身份验证。
Commands
命令
review
review
Review a change by number or URL.
Usage:
Review PR #123
Review this MR: https://gitlab.com/org/repo/-/merge_requests/42
Review Gerrit change 456789The agent follows the Workflow steps: detects the platform from git remotes or the provided URL, fetches the change metadata, CI status, and diff, then provides structured review feedback. Optionally posts review comments.
通过编号或URL评审变更。
用法:
Review PR #123
Review this MR: https://gitlab.com/org/repo/-/merge_requests/42
Review Gerrit change 456789Agent会遵循工作流步骤:从git远程地址或提供的URL中检测平台,拉取变更元数据、CI状态和差异内容,然后提供结构化的评审反馈。可选发布评审评论。
remember
remember
Save additional context for the current repository's reviews. This persists information that should be considered in future reviews of the same repo.
Usage:
Remember that this repo follows the Google Python Style Guide
Remember: authentication changes must be reviewed by the security team
Remember https://internal-docs.example.com/api-conventions as a reference for API design
Remember that the data layer uses the Repository pattern, not Active RecordKeyword: The word remember at the start of a message triggers saving. The context is stored in under the current repository's remote URL.
~/.config/agent-skills/code-review.yamlWhat to save: Coding standards, architectural decisions, external documentation links, team conventions, review policies, or any context that should inform future reviews.
为当前仓库的评审保存额外上下文。该信息会被持久化,后续评审同一仓库时会被纳入考量。
用法:
Remember that this repo follows the Google Python Style Guide
Remember: authentication changes must be reviewed by the security team
Remember https://internal-docs.example.com/api-conventions as a reference for API design
Remember that the data layer uses the Repository pattern, not Active Record触发关键词: 消息开头的remember单词会触发保存操作。上下文会存储在中,以当前仓库的远程URL作为键。
~/.config/agent-skills/code-review.yaml可保存的内容: 编码规范、架构决策、外部文档链接、团队约定、评审政策,或任何能为后续评审提供参考的上下文信息。
forget
forget
Remove previously saved context for the current repository.
Usage:
Forget the note about the Google Python Style Guide
Forget all saved context for this repo移除当前仓库之前保存的上下文。
用法:
Forget the note about the Google Python Style Guide
Forget all saved context for this reposhow context
show context
Display all saved context for the current repository.
Usage:
Show review context for this repo展示当前仓库所有已保存的上下文。
用法:
Show review context for this repocheck
check
Verify that the required platform skill is available and authenticated.
bash
undefined验证所需的平台技能是否可用且已完成身份验证。
bash
undefinedFor GitHub repos
针对GitHub仓库
skills/github/scripts/github.py check
skills/github/scripts/github.py check
For GitLab repos
针对GitLab仓库
skills/gitlab/scripts/gitlab.py check
skills/gitlab/scripts/gitlab.py check
For Gerrit repos
针对Gerrit仓库
skills/gerrit/scripts/gerrit.py check
undefinedskills/gerrit/scripts/gerrit.py check
undefinedRepository Context
仓库上下文
Per-repository context is persisted in , keyed by the remote fetch URL from . This context is loaded at the start of every review (see Step 0 in Workflow).
~/.config/agent-skills/code-review.yamlgit remote get-url originyaml
undefined每个仓库的上下文会持久化存储在中,以返回的远程拉取URL作为键。每次评审开始时会加载该上下文(参考工作流的第0步)。
~/.config/agent-skills/code-review.yamlgit remote get-url originyaml
undefined~/.config/agent-skills/code-review.yaml
~/.config/agent-skills/code-review.yaml
repositories:
"git@github.com:myorg/myrepo.git":
references:
- "https://internal-docs.example.com/api-conventions"
- "https://google.github.io/styleguide/pyguide.html"
standards:
- "All API endpoints must validate input with Pydantic models"
- "Authentication changes require security team review"
notes:
- "Data layer uses Repository pattern, not Active Record"
- "Legacy modules in src/compat/ are exempt from new style rules"
"https://gitlab.com/myorg/other-repo.git":
references:
- "https://docs.example.com/other-repo/architecture"
standards: []
notes:
- "Migrating from REST to GraphQL -- new endpoints should use GraphQL"
When the user provides out-of-repo context during a review, suggest using the **remember** command to persist it.repositories:
"git@github.com:myorg/myrepo.git":
references:
- "https://internal-docs.example.com/api-conventions"
- "https://google.github.io/styleguide/pyguide.html"
standards:
- "All API endpoints must validate input with Pydantic models"
- "Authentication changes require security team review"
notes:
- "Data layer uses Repository pattern, not Active Record"
- "Legacy modules in src/compat/ are exempt from new style rules"
"https://gitlab.com/myorg/other-repo.git":
references:
- "https://docs.example.com/other-repo/architecture"
standards: []
notes:
- "Migrating from REST to GraphQL -- new endpoints should use GraphQL"
如果用户在评审过程中提供了仓库外的上下文,建议使用**remember**命令将其持久化保存。Workflow
工作流
Step 0: Load Repository Context
第0步:加载仓库上下文
Before starting the review, check for saved context:
bash
git remote get-url originRead and look up the remote URL. If context exists, load it and keep it in mind throughout the review:
~/.config/agent-skills/code-review.yaml- references: Consult these when evaluating architectural decisions
- standards: Actively check compliance with each standard
- notes: Factor these into review feedback
If no context file exists or the repo has no entries, proceed without additional context.
开始评审前,检查是否有已保存的上下文:
bash
git remote get-url origin读取并查找对应远程URL的配置。如果存在上下文,加载并在整个评审过程中参考这些信息:
~/.config/agent-skills/code-review.yaml- references:评估架构决策时参考这些内容
- standards:主动检查代码是否符合每一项规范
- notes:将这些内容纳入评审反馈的考量因素
如果不存在上下文文件,或仓库没有对应条目,无需额外上下文直接继续。
Step 1: Detect Platform
第1步:检测平台
Determine the code hosting platform from the repository context:
bash
undefined从仓库上下文中确定代码托管平台:
bash
undefinedCheck git remotes
检查git远程地址
git remote -v
- If remote contains `github.com` -> use the **github** skill
- If remote contains `gitlab` -> use the **gitlab** skill
- If `.gitreview` file exists -> use the **gerrit** skill
- If a URL is provided, detect from the URL hostnamegit remote -v
- 如果远程地址包含`github.com` -> 使用**github**技能
- 如果远程地址包含`gitlab` -> 使用**gitlab**技能
- 如果存在`.gitreview`文件 -> 使用**gerrit**技能
- 如果提供了URL,从URL的主机名检测平台Step 2: Fetch Change Metadata and CI Status
第2步:拉取变更元数据和CI状态
GitHub:
bash
skills/github/scripts/github.py prs view <number> --repo OWNER/REPO
skills/github/scripts/github.py prs checks <number> --repo OWNER/REPOGitLab:
bash
skills/gitlab/scripts/gitlab.py mrs view <number> --repo GROUP/REPO
skills/gitlab/scripts/gitlab.py pipelines list --repo GROUP/REPOGerrit:
bash
skills/gerrit/scripts/gerrit.py changes view <change-number>GitHub:
bash
skills/github/scripts/github.py prs view <number> --repo OWNER/REPO
skills/github/scripts/github.py prs checks <number> --repo OWNER/REPOGitLab:
bash
skills/gitlab/scripts/gitlab.py mrs view <number> --repo GROUP/REPO
skills/gitlab/scripts/gitlab.py pipelines list --repo GROUP/REPOGerrit:
bash
skills/gerrit/scripts/gerrit.py changes view <change-number>Step 3: Assess CI/Test Status
第3步:评估CI/测试状态
Before reviewing, check whether CI/tests have passed:
- If CI is passing: proceed with full review
- If CI is failing: note the failures, skip reviewing concerns that would be caught by tests, and focus on issues tests cannot catch (security, architecture, design)
- If CI is pending: note it and proceed with review
评审前,检查CI/测试是否通过:
- 如果CI通过:继续完成全量评审
- 如果CI失败:标注失败内容,跳过评审会被测试覆盖的问题,重点关注测试无法发现的问题(安全性、架构、设计)
- 如果CI运行中:标注该状态后继续评审
Step 4: Fetch the Diff
第4步:拉取差异内容
GitHub:
bash
gh pr diff <number>GitLab:
bash
glab mr diff <number>Gerrit:
bash
git diff HEAD~1GitHub:
bash
gh pr diff <number>GitLab:
bash
glab mr diff <number>Gerrit:
bash
git diff HEAD~1Step 5: Review the Changes
第5步:评审变更
Focus review feedback on these areas, in priority order. See references/review-checklist.md for the full checklist.
- Security concerns: injection vulnerabilities, authentication/authorization gaps, data exposure, unsafe deserialization, hardcoded secrets
- Maintainability: excessive complexity, poor naming, missing separation of concerns, code duplication that harms readability
- Good coding practices: error handling gaps, resource leaks, race conditions, missing input validation at system boundaries
- Architectural fit: consistency with existing codebase patterns, appropriate abstraction level, dependency direction
Do not flag:
- Style/formatting issues (leave to linters)
- Minor naming preferences without clear readability impact
- Test coverage gaps (leave to CI coverage tools)
- Issues already caught by failing CI
按照优先级顺序,重点关注以下领域的评审反馈。完整检查清单可参考references/review-checklist.md。
- 安全问题:注入漏洞、身份验证/授权缺口、数据暴露、不安全的反序列化、硬编码密钥
- 可维护性:过度复杂、命名不规范、缺少关注点分离、影响可读性的代码重复
- 良好编码实践:错误处理缺失、资源泄漏、竞态条件、系统边界缺少输入验证
- 架构适配性:与现有代码库模式的一致性、合理的抽象层级、依赖方向正确
无需标注的问题:
- 代码风格/格式问题(交给linter处理)
- 无明显可读性影响的小型命名偏好问题
- 测试覆盖缺口(交给CI覆盖率工具处理)
- 已被失败CI捕获的问题
Step 6: Present Findings
第6步:展示评审结果
Format findings as a structured review:
markdown
undefined将结果格式化为结构化的评审内容:
markdown
undefinedCode Review: PR #<number> - <title>
代码评审:PR #<number> - <title>
Summary
摘要
<1-2 sentence summary of the change and overall assessment>
<1-2句话说明变更内容和整体评估>
CI Status
CI状态
<passing/failing/pending -- note any failures>
<passing/failing/pending -- 标注所有失败项>
Findings
评审发现
Security
安全
- <finding with file:line reference>
- <标注具体文件:行号的问题>
Maintainability
可维护性
- <finding with file:line reference>
- <标注具体文件:行号的问题>
Coding Practices
编码实践
- <finding with file:line reference>
- <标注具体文件:行号的问题>
Architecture
架构
- <finding with file:line reference>
- <标注具体文件:行号的问题>
Verdict
结论
<APPROVE / REQUEST_CHANGES / COMMENT -- with brief rationale>
If the user requests it, post the review as comments on the PR/MR using the platform skill:
**GitHub:**
```bash
gh pr review <number> --comment --body "<review>"<APPROVE / REQUEST_CHANGES / COMMENT -- 附带简要理由>
如果用户要求,可使用平台技能将评审内容作为评论发布到PR/MR上:
**GitHub:**
```bash
gh pr review <number> --comment --body "<review>"Or approve/request changes:
或批准/请求变更:
gh pr review <number> --approve --body "<review>"
gh pr review <number> --request-changes --body "<review>"
**GitLab:**
```bash
glab mr note <number> --message "<review>"gh pr review <number> --approve --body "<review>"
gh pr review <number> --request-changes --body "<review>"
**GitLab:**
```bash
glab mr note <number> --message "<review>"Or approve:
或批准:
glab mr approve <number>
undefinedglab mr approve <number>
undefinedExamples
示例
Review a GitHub PR
评审GitHub PR
Review PR #42The agent will run , detect GitHub, fetch the PR with , check CI with , fetch the diff with , and provide structured review feedback.
git remote -vskills/github/scripts/github.py prs view 42skills/github/scripts/github.py prs checks 42gh pr diff 42Review PR #42Agent会执行,检测到GitHub平台,使用拉取PR信息,使用检查CI状态,使用拉取差异内容,然后提供结构化的评审反馈。
git remote -vskills/github/scripts/github.py prs view 42skills/github/scripts/github.py prs checks 42gh pr diff 42Review a GitLab MR by URL
通过URL评审GitLab MR
Review https://gitlab.com/myorg/myrepo/-/merge_requests/15Review https://gitlab.com/myorg/myrepo/-/merge_requests/15Review with Posting Comments
评审并发布评论
Review PR #42 and post your findings as a review commentReview PR #42 and post your findings as a review commentReview Focusing on Security Only
仅关注安全问题的评审
Review PR #42, focus only on security concernsReview PR #42, focus only on security concernsSave Context for Future Reviews
为后续评审保存上下文
Remember that this repo uses the Twelve-Factor App methodology
Remember https://wiki.example.com/team/coding-standards as a reference
Remember: all database migrations must be backwards-compatibleRemember that this repo uses the Twelve-Factor App methodology
Remember https://wiki.example.com/team/coding-standards as a reference
Remember: all database migrations must be backwards-compatibleShow Saved Context
展示已保存的上下文
Show review context for this repoShow review context for this repoModel Guidance
模型指南
This skill coordinates multiple sub-skills and requires reasoning about multi-step workflows. A higher-capability model is recommended for best results.
该技能会协调多个子技能,需要处理多步骤工作流的推理能力。为获得最佳效果,建议使用能力更强的模型。
Troubleshooting
故障排查
Platform not detected
平台未检测
Ensure you are running from within a git repository with a remote configured:
bash
git remote -v确保你在已配置远程地址的git仓库中运行命令:
bash
git remote -vAuthentication errors
身份验证错误
Verify the underlying platform skill is authenticated:
bash
undefined验证底层平台技能已完成身份验证:
bash
undefinedGitHub
GitHub
gh auth status
gh auth status
GitLab
GitLab
glab auth status
undefinedglab auth status
undefinedNo diff available
无可用差异内容
Ensure the PR/MR number is correct and the change exists:
bash
undefined确认PR/MR编号正确且变更存在:
bash
undefinedGitHub
GitHub
skills/github/scripts/github.py prs view <number>
skills/github/scripts/github.py prs view <number>
GitLab
GitLab
skills/gitlab/scripts/gitlab.py mrs view <number>
undefinedskills/gitlab/scripts/gitlab.py mrs view <number>
undefined