review-gitcode-pr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReview GitCode PR
审查 GitCode PR
Run this skill when the review starts from a GitCode PR reference and must combine artifacts with local repository inspection.
oh-gc当审查从 GitCode PR 引用开始,且必须结合 产物与本地仓库检查时,运行此 skill。
oh-gcWorkflow
工作流
1. Resolve The PR
1. 解析 PR
Normalize the user input first.
- If the user gave a PR number, use it directly.
- If the user gave a URL, extract the PR number and, when possible, the .
OWNER/REPO - If the normalized result does not include ,
OWNER/REPOwill try to infer it from the current repository's GitCode remote URLs.scripts/collect_pr_context.py - If remote inference is ambiguous or the current checkout is not a GitCode clone, pass explicitly.
--repo OWNER/REPO - Use for this normalization step.
scripts/normalize_pr_ref.py
首先规范化用户输入。
- 如果用户提供了 PR 编号,直接使用。
- 如果用户提供了 URL,提取 PR 编号,并在可能的情况下提取 。
OWNER/REPO - 如果规范化结果不包含 ,
OWNER/REPO将尝试根据当前仓库的 GitCode remote URL 推断。scripts/collect_pr_context.py - 如果 remote 推断存在歧义,或当前 checkout 不是 GitCode clone,请显式传入 。
--repo OWNER/REPO - 使用 完成此规范化步骤。
scripts/normalize_pr_ref.py
2. Collect Remote Context
2. 收集远程上下文
Use to fetch and save the PR context before reviewing code manually.
scripts/collect_pr_context.pyThe script gathers:
oh-gc pr:view NUMBER --jsonoh-gc pr:diff NUMBER --jsonoh-gc pr:diff NUMBER --name-onlyoh-gc pr:diff NUMBER --color neveroh-gc pr:comments NUMBER --json --comment-type pr_commentoh-gc pr:comments NUMBER --json --comment-type diff_comment
Review the generated artifact directory before making claims. Read artifacts in this order:
- to identify changed files, parsed hunks, commentable new-side lines, and existing normalized context.
summary.json - to verify exact diff text and hunk boundaries for any candidate finding.
pr-diff.txt - for title, description, branch, and high-level PR metadata.
pr-view.json - or raw comments output only when the normalized summary is insufficient.
pr-diff.json
Do not load every artifact by default. Start from and only drill down when a finding needs more evidence.
summary.json使用 在手动审查代码前获取并保存 PR 上下文。
scripts/collect_pr_context.py该脚本收集:
oh-gc pr:view NUMBER --jsonoh-gc pr:diff NUMBER --jsonoh-gc pr:diff NUMBER --name-onlyoh-gc pr:diff NUMBER --color neveroh-gc pr:comments NUMBER --json --comment-type pr_commentoh-gc pr:comments NUMBER --json --comment-type diff_comment
在作出论断前,先检查生成的产物目录。按以下顺序读取产物:
- :识别变更文件、已解析的 hunk、可评论的 new-side 行以及现有的规范化上下文。
summary.json - :验证候选发现对应的准确 diff 文本和 hunk 边界。
pr-diff.txt - :获取标题、描述、分支和高层 PR 元数据。
pr-view.json - 仅当规范化摘要不足以提供所需信息时,才读取 或原始评论输出。
pr-diff.json
默认不要加载每个产物。先从 开始,仅在发现需要更多证据时再深入检查。
summary.json3. Read Local Code
3. 阅读本地代码
Do not review from the diff alone.
Use as the required checklist for depth, stopping conditions, and risk-specific review prompts.
references/deep-review-checklist.mdFor every changed file, assign exactly one review status before finishing:
- : the file and its relevant context were inspected deeply enough to support findings or a no-finding conclusion
reviewed - : the change is demonstrably mechanical and low-risk after verification against the checklist
mechanical-low-risk - : the file was not reviewed in depth, and the reason and residual risk are stated explicitly
skipped-with-reason
Do not stop after finding one or two issues. Keep reviewing until every changed file has one of the statuses above.
For each changed file that matters:
- Read the changed hunk.
- Read surrounding local code in the current repository.
- Follow imports, helpers, tests, and callers as far as needed to verify behavior, not just to form an initial suspicion.
Minimum depth rules:
- For production code changes, inspect at least one of: direct callers, direct callees, or related tests.
- For API, schema, persistence, concurrency, permission, cache, state-machine, or error-handling changes, inspect at least two of those areas and do not treat the diff in isolation as sufficient.
- For deleted or moved logic, verify that the previous responsibility still exists somewhere valid or that callers were updated accordingly.
- For new branches or new failure paths, verify whether tests cover both the success path and the new branch or explain why that verification was not possible.
Prioritize:
- Correctness bugs
- Behavior regressions
- Broken assumptions at call sites
- Missing or invalid tests
- Security or data handling issues
Prefer high-signal findings over style commentary.
Depth expectations:
- If a file appears low-risk, prove that with code context or tests instead of intuition.
- If a file appears high-risk, increase inspection depth before deciding there is no finding.
- If the repository context is insufficient, report that as a review limitation instead of silently reducing depth.
Use when deciding whether a candidate issue is a real finding, assigning severity, or explaining residual risk when no findings are confirmed.
references/review-rubric.md不要仅依据 diff 进行审查。
使用 作为审查深度、停止条件和风险特定审查提示的必需 checklist。
references/deep-review-checklist.md结束前,为每个变更文件分配且仅分配一个审查状态:
- :已对文件及其相关上下文进行足够深入的检查,能够支持审查发现或无发现结论。
reviewed - :根据 checklist 验证后,可以明确证明该变更是机械性且低风险的。
mechanical-low-risk - :未对该文件进行深入审查,并且已明确说明原因和剩余风险。
skipped-with-reason
不要在发现一两个问题后停止。继续审查,直到每个变更文件都具有上述状态之一。
对于每个重要的变更文件:
- 阅读变更的 hunk。
- 阅读当前仓库中周围的本地代码。
- 根据需要跟进 imports、helpers、tests 和 callers,以验证行为,而不只是形成初步怀疑。
最低审查深度规则:
- 对于 production code 变更,至少检查 direct callers、direct callees 或 related tests 中的一项。
- 对于 API、schema、persistence、concurrency、permission、cache、state machine 或 error handling 变更,至少检查上述两个领域,并且不得将 diff 孤立看待就认为已充分。
- 对于删除或移动的逻辑,验证原有职责是否仍存在于某个有效位置,或者 callers 是否已相应更新。
- 对于新分支或新的 failure path,验证 tests 是否覆盖成功路径和新分支,或者解释为何无法进行这种验证。
优先检查:
- 正确性缺陷
- 行为回归
- 调用点处被破坏的假设
- 缺失或无效的 tests
- 安全性或数据处理问题
优先提供高信号发现,而不是风格评论。
审查深度要求:
- 如果某个文件看起来风险较低,应通过代码上下文或 tests 证明这一点,而不是凭直觉判断。
- 如果某个文件看起来风险较高,应在决定没有发现之前加大审查深度。
- 如果仓库上下文不足,应将其作为审查限制报告出来,而不是在未说明的情况下降低审查深度。
在判断候选问题是否构成真实发现、确定严重程度,或在没有确认发现时说明剩余风险,请使用 。
references/review-rubric.md4. Produce Findings
4. 生成审查发现
Default output is issue-driven review, not a broad summary.
Use this template for each finding shown to the user:
Severity | Path:Line | Problem | Evidence | FixInclude:
- Severity: ,
high, ormediumlow - Path
- Best-effort line number on the new side of the diff
- Problem: what is wrong and why it matters
- Evidence: concrete code path, behavior, or missing test support
- Fix: what change would address it
If a valid diff line cannot be supported, fall back in this order:
- File-level comment with
path - General PR comment
Never invent a diff line number.
If no valid findings are discovered, state that explicitly and include:
- the review status for each changed file or file group
- the main code paths, callers, callees, or tests inspected
- any checklist categories that could not be verified
- residual uncertainty or testing gaps instead of padding with style feedback
Do not say "no actionable issues found" unless the file coverage and checklist pass were completed for the inspected scope.
Use as the default output shape when the inspected scope has no confirmed findings.
references/no-finding-template.mdWhen drafting comments that may be submitted back to GitCode:
- Write in Chinese by default unless the user explicitly asks for another language.
- Use concise Markdown, not a single pipe-delimited sentence.
- Separate conclusion, problem analysis, and suggested fix into short paragraphs or bullet points.
- Wrap identifiers such as parameters, files, and status codes in backticks.
默认输出采用以问题为导向的审查,而不是宽泛的总结。
对展示给用户的每项发现使用以下模板:
Severity | Path:Line | Problem | Evidence | Fix包括:
- Severity:、
high或mediumlow - Path
- diff new side 上尽力确定的行号
- Problem:问题是什么,以及它为什么重要。
- Evidence:具体的代码路径、行为或缺失的 test 支持。
- Fix:可以解决该问题的变更。
如果无法支持有效的 diff 行,请依次回退为:
- 带 的文件级评论。
path - PR 总体评论。
绝不要虚构 diff 行号。
如果没有发现有效问题,请明确说明,并包括:
- 每个变更文件或文件组的审查状态。
- 已检查的主要代码路径、callers、callees 或 tests。
- 无法验证的 checklist 类别。
- 剩余不确定性或测试缺口,而不是用风格反馈填充内容。
除非已完成检查范围内的文件覆盖和 checklist,否则不要声称“未发现可操作的问题”。
当检查范围中没有确认的发现时,使用 作为默认输出结构。
references/no-finding-template.md起草可能需要提交回 GitCode 的评论时:
- 默认使用中文编写,除非用户明确要求使用其他语言。
- 使用简洁的 Markdown,不要写成单个由管道符分隔的句子。
- 将结论、问题分析和修复建议拆分为短段落或 bullet points。
- 使用反引号包裹参数、文件和状态码等 identifiers。
5. Prepare Submission Draft
5. 准备提交草稿
This skill uses a two-step submission flow.
Default behavior:
- Review the PR
- Produce findings for the user
- If the user wants submission, create a structured draft first
Use for the draft shape and to validate it against the collected context.
references/review-draft-schema.mdscripts/prepare_review_submission.pyThe draft may include:
- One general PR summary comment
- Zero or more diff comments with and
pathline - Optional approval intent
Approval gate:
- Set only when no blocking or high-severity findings remain and the user explicitly wants approval.
approve: true - If the review contains blocking findings, submit comments only; do not call .
oh-gc pr:review
Important: only supports approval. It is not a general "submit review" endpoint.
oh-gc pr:reviewFor submitted comments, follow the Markdown and Chinese-writing rules in .
references/review-draft-schema.md此 skill 使用两步提交流程。
默认行为:
- 审查 PR。
- 向用户提供审查发现。
- 如果用户希望提交,先创建结构化草稿。
使用 定义草稿结构,并使用 根据收集到的上下文验证草稿。
references/review-draft-schema.mdscripts/prepare_review_submission.py草稿可以包括:
- 一条 PR 总体摘要评论。
- 零条或多条带有 和
path的 diff 评论。line - 可选的 approval intent。
Approval gate:
- 仅当没有剩余的 blocking 或 high-severity findings,并且用户明确希望 approval 时,才设置 。
approve: true - 如果审查包含 blocking findings,则仅提交评论;不要调用 。
oh-gc pr:review
重要提示: 仅支持 approval。它不是通用的“提交审查” endpoint。
oh-gc pr:review对于已提交的评论,请遵循 中的 Markdown 和中文编写规则。
references/review-draft-schema.md6. Submit Only After Confirmation
6. 仅在确认后提交
Never submit to GitCode implicitly.
When the user explicitly asks to submit:
- Build the draft JSON
- Run without
prepare_review_submission.pyto preview commands--execute - Show the user the exact summary and comment count you plan to post
- After confirmation, run the same command with
--execute
If execution fails partway through, report exactly which comments succeeded and which did not.
绝不要未经明确指示就提交到 GitCode。
当用户明确要求提交时:
- 构建草稿 JSON。
- 运行 ,但不要添加
prepare_review_submission.py,以预览命令。--execute - 向用户展示计划发布的准确摘要和评论数量。
- 获得确认后,运行同一命令并添加 。
--execute
如果执行到一半失败,请准确报告哪些评论已成功提交、哪些未成功提交。
Quick Flow
快速流程
Use these commands only as a compact reminder after reading the workflow above.
bash
python3 skills/review-gitcode-pr/scripts/collect_pr_context.py 123Primary review artifacts:
summary.jsonpr-diff.txtpr-view.json
Depth reminder:
- Read
summary.json - Classify each changed file by risk using
references/deep-review-checklist.md - Review every file until it has a final status
- Only then decide whether the review has zero findings
Preview a draft submission:
bash
python3 skills/review-gitcode-pr/scripts/prepare_review_submission.py \
--context-dir .review-gitcode-pr/pr-123 \
--draft review-draft.jsonExecute only after explicit user confirmation:
bash
python3 skills/review-gitcode-pr/scripts/prepare_review_submission.py \
--context-dir .review-gitcode-pr/pr-123 \
--draft review-draft.json \
--execute阅读上述工作流后,仅将这些命令用作简短提醒。
bash
python3 skills/review-gitcode-pr/scripts/collect_pr_context.py 123主要审查产物:
summary.jsonpr-diff.txtpr-view.json
审查深度提醒:
- 读取 。
summary.json - 使用 按风险对每个变更文件进行分类。
references/deep-review-checklist.md - 审查每个文件,直至其获得最终状态。
- 只有完成上述步骤后,才能判断审查是否为零发现。
预览草稿提交:
bash
python3 skills/review-gitcode-pr/scripts/prepare_review_submission.py \
--context-dir .review-gitcode-pr/pr-123 \
--draft review-draft.json仅在用户明确确认后执行:
bash
python3 skills/review-gitcode-pr/scripts/prepare_review_submission.py \
--context-dir .review-gitcode-pr/pr-123 \
--draft review-draft.json \
--executeFailure Handling
失败处理
Handle failures explicitly. For each blocker, report:
- : what failed and which command or assumption failed
Blocker - : what review scope remains possible
Fallback - : what the user or agent should do next
Next step
显式处理失败。对于每个 blocker,请报告:
- :失败的内容,以及失败的命令或假设。
Blocker - :仍可进行的审查范围。
Fallback - :用户或 agent 接下来应采取的操作。
Next step
oh-gc
unavailable
oh-gcoh-gc
不可用
oh-gc- Blocker: is missing from
oh-gcor cannot be executed.PATH - Fallback: do not attempt GitCode fetch or submission. Only continue if a previously collected artifact directory already exists locally and is sufficient for a non-submitting review.
- Next step: ask the user to install or expose , or point to existing artifacts to review offline.
oh-gc
- :
Blocker不在oh-gc中或无法执行。PATH - :不要尝试获取或提交 GitCode 数据。仅当本地已存在先前收集的产物目录,且其内容足以完成不提交的审查时,才可继续。
Fallback - :请用户安装
Next step或将其暴露到可执行路径,或者指向已有产物以进行离线审查。oh-gc
Authentication or permission failure
Authentication 或权限失败
- Blocker: returns authentication, authorization, or API permission errors for PR view, diff, or comments.
oh-gc - Fallback: keep any partial artifacts already collected. Continue only with successfully fetched diff/context that is sufficient for a non-submitting review. Do not attempt submission.
- Next step: tell the user which command failed and that they need to re-authenticate or obtain access before remote review or submission can continue.
- :
Blocker在查看 PR、diff 或评论时返回 authentication、authorization 或 API permission 错误。oh-gc - :保留已经收集的部分产物。仅当成功获取的 diff/context 足以完成不提交的审查时才可继续。不要尝试提交。
Fallback - :告知用户哪个命令失败,以及在继续远程审查或提交前需要重新进行身份验证或获得访问权限。
Next step
Local repository mismatch
本地仓库不匹配
- Blocker: the current repository does not match the PR repository, branch layout, or file set closely enough to verify behavior in local code.
- Fallback: do not claim code-level confidence from diff-only inspection. At most, provide a limited review explicitly labeled as diff-only if the user still wants that.
- Next step: ask the user to switch to the matching repository checkout or provide the correct local workspace before continuing with a full review.
- :当前仓库与 PR 仓库、分支布局或文件集不够匹配,无法验证本地代码中的行为。
Blocker - :不要声称仅凭 diff 检查即可获得代码层面的信心。最多在用户仍需要时,提供明确标注为 diff-only 的有限审查。
Fallback - :请用户切换到匹配的仓库 checkout,或提供正确的本地工作区,然后继续完整审查。
Next step
Diff JSON missing, malformed, or incomplete
Diff JSON 缺失、格式错误或不完整
- Blocker: changes shape, omits hunks, or cannot be parsed reliably enough for structured line mapping.
pr:diff --json - Fallback: use as the source of truth for diff reasoning. Only emit line comments when a new-side line can still be verified confidently from raw diff text; otherwise fall back to file-level or general comments.
pr-diff.txt - Next step: tell the user that structured diff parsing degraded and that submission precision may be reduced until the JSON format is fixed.
- :
Blocker的结构发生变化、遗漏 hunk,或无法可靠解析以进行结构化行映射。pr:diff --json - :使用
Fallback作为 diff 推理的事实来源。仅当仍能从原始 diff 文本中可靠确认 new-side 行时,才输出行评论;否则回退为文件级评论或总体评论。pr-diff.txt - :告知用户结构化 diff 解析能力已经降级,并且在 JSON 格式修复前,提交精度可能会降低。
Next step
Submission preview or execute failure
提交预览或执行失败
- Blocker: validation fails, preview commands do not match the draft, or
prepare_review_submission.pyfails for some comments.--execute - Fallback: keep the validated draft and any successful partial submission results. Do not silently retry with changed semantics.
- Next step: report the exact failed comment or command, which comments were already posted, and what must be corrected before retrying.
- :
Blocker验证失败、预览命令与草稿不匹配,或prepare_review_submission.py在提交部分评论时失败。--execute - :保留已验证的草稿和已成功提交的部分结果。不要在未说明的情况下使用改变语义的方式静默重试。
Fallback - :准确报告失败的具体评论或命令、已经发布的评论,以及重试前需要修正的内容。
Next step