Produce a standardized three-part review report.Read-only: do not modify the reviewed code, and do not run the reviewed code itself; for the reviewed code, only allow executing yarn type-check and yarn test:vitest ... --run, and additionally allow yarn cli install within a temporary worktree to install dependencies. If tsc / vitest have not actually been run, do not mark ✅ in the report and do not fabricate results. Do not conceal discovered issues, and do not downgrade functional bugs to warnings.
Trigger
- Semantics: such as "review", "review this PR / current branch", "compare with origin/master", "check before merge".
/code-review, may carry parameters (such as/code-review review PR 4198)。- Called by another skill (such as create-pr):If the scope is already specified, execute directly without showing a dialog. Return the full text of the three-part report to the caller; writing to disk still requires user consent.
Interaction conventions
When user selection or confirmation is needed, prioritize interaction tools available in the current environment and permitted for that purpose (such as AskUserQuestion、request_user_input_async); if no applicable tool exists, ask in the conversation. Adopt existing explicit authorization directly without repeated confirmation. An unanswered asynchronous inquiry does not count as consent; during the wait, only continue work that does not depend on the answer.
1. Determine the review target
If it can be determined, use it directly; do not ask repeatedly:
| Priority | Condition | Mode |
|---|---|---|
| 1 | Contains a PR number ("review 4198", "review #4198") | PR |
| 2 | Contains a branch or baseline ("review dev", "compare with feat-x") | Branch |
| 3 | An external skill has already specified the diff scope | Adopt directly, no dialog |
| 4 | None of the above | Ask according to the interaction conventions |
CHECKPOINT: when the review scope is unclear, obtain the user's choice before reviewing. Options: current branch vs origin/master; uncommitted changes in the working tree. Note in the question that a PR number or another baseline branch name may also be entered.
| Mode | Obtain changes | Report file name (repository root) |
|---|---|---|
| PR | gh pr view <编号> --repo yaklang/yakit --json title,headRefName,headRefOid,baseRefName,baseRefOid,files + gh pr diff <编号>. Must record baseRefOid / headRefOid for step 4 |
PR-<编号>-review.md |
| Branch | git diff <基线>...HEAD + git log --oneline <基线>..HEAD, baseline defaults to origin/master, must not be automatically replaced with the local master |
<分支名>-review.md(/ → -) |
| Working tree | git diff HEAD + git status --short untracked new files (read the content and include them in the review) |
working-tree-review.md |
gh not installed or not logged in: PR mode reports an error and stops; if the local branch happens to correspond to that PR, downgrade to branch mode after obtaining user confirmation according to the interaction conventions.
2. Collect and classify
git diff --stat(or the PR files list) to list all changes. Classify: source code (ts/tsx/js/jsx), tests, styles (less/css/scss), dependencies (package.json / yarn.lock), configuration, documentation.diff is empty → state that there are no changes and stop. Files > 50: prioritize reviewing source code/dependencies/configuration, sample-check styles and copy, and state the coverage at the beginning of the report.
PR mode only has the diff, no local context: review in conjunction with the file list; if a corresponding branch exists locally, read the local files to supplement, otherwise note "review based on diff only". Verification must still be run twice in OID worktrees, not using results from the current directory.
3. Six-dimension check
For each dimension, first read the references/check-dimensions.md corresponding section.
| # | Dimension | Trigger | When not involved |
|---|---|---|---|
| 1 | Code logic | Source code changes present | Mark ⏭️ N/A in the summary table |
| 2 | TS definitions | ts/tsx changes present | Same as above |
| 3 | UI references and Props | Component / props changes present | Same as above |
| 4 | CSS styles | Style file or in-tsx style changes present | Same as above |
| 5 | Dependency version impact | Only when changes include package.json | ⏭️ N/A (no dependency changes) |
| 6 | Config item impact | Only when changes include config files | ⏭️ N/A (no config changes) |
Dimensions 5 and 6 cannot be relaxed: without package.json, do not review dependencies; without config files, do not review configuration. N/A rows must appear in the summary table; a whole row must not disappear. Config files:tsconfig*.json、vite/vitest、electron-builder、.github/workflows/、scripts/、cli/、.env*、.husky/、.lintstagedrc etc.; changes to the package.json scripts section trigger both dimensions 5 and 6.
4. Mandatory verification (required every time)
Workspace / branch: run in the current working directory.
In PR mode it is forbidden to run in the current working directory(the local checkout may not be the PR head). Must use base / head dual snapshots:
- Use the
baseRefOid/headRefOid,git fetch origin <OID>from step 1 (use the OID, not the branch name). git worktree add --detach <临时目录> <OID>Create two isolated worktrees, head and base, without touching the user's current state.- Run in both places theexactly identicaltsc / vitest; if dependencies are not ready, run in the corresponding subproject
yarn cli install; if it still cannot run → "environment abnormal, degraded". - After finishing,
git worktree remove <临时目录>。
Attribution: head fails and base fails on the same item → pre-existing baseline issue,do not record as a P0 for this PR(note "base also fails, not introduced by this PR", may be recorded as a warning); head fails and base passes → ❌ P0; head passes → ✅. If fetch / worktree fails and the snapshot cannot be constructed → environment abnormal, degraded,must not be marked ✅, and must not use current-directory results as a substitute。
TS
Run a full subproject type-check (not a single file) for the subproject containing the changes:
| Change location | Command |
|---|---|
app/renderer/src/main/ |
cd app/renderer/src/main && yarn type-check |
app/renderer/engine-link-startup/ |
cd app/renderer/engine-link-startup && yarn type-check |
Only app/main/ or no TS subproject |
Skip, note the reason (main process is pure JS with no tsconfig / no TS this time) |
Pass → 1 ✅; fail → 1 ❌ P0 (include 文件:行号 summary); in PR mode, if head fails but base also fails, do not record a P0.
Tests
Use the same three rules as CI (scripts/ci-select-vitest-tests.js) to select relevant tests:
- The changed file itself is
__test__/under*.test.*/*.spec.*→ include; - A business file in the same directory has
__test__/<stem>.(test|spec).*present → include; __test__/A test case imports a changed module (grep path /@renderer/@engineetc.) → include.
The above rules are used to locate candidate tests; if existing Vitest tests elsewhere are found to actually cover the changed logic, include them in verification as well. Coverage must be confirmed by reading the test cases and assertions, not judged merely by file name or import.
Run at the repository root (in PR mode, run the same commands in each of the base / head worktrees):
yarn test:vitest <测试文件...> --run
All pass → 1 ✅ (note the number of files and test cases); any failure → ❌ P0 for each failing test case (test case name + assertion summary); in PR mode, failures that also fail on base are not recorded as P0. No relevant tests found → summary table "⏭️ No relevant tests".
Environment anomaly downgrade
tsc / vitest cannot run due to the environment (dependencies not installed, node version, etc.) rather than a code error: mark the summary table as ⚠️ "Verification environment anomaly" and indicate yarn cli install。it must be marked neither ✅ nor counted as a code problem. In PR mode, also downgrade when a snapshot cannot be constructed.
5. Missing test cases
Cases needed: new/modified logic branches, pure utility functions, state transitions, complex component interactions, bug fixes (regression prevention). Not needed: pure styling, pure copy/i18n, type declarations, build/CI configuration itself.
Locate and read relevant tests per step 4, and accept the valid coverage of *.test.*、*.spec.* and existing tests elsewhere. Cases needed but assertions covering the changed logic are missing → ❌ P1 "Missing test cases", point out the uncovered branches or behaviors, prefer recommending supplementing existing relevant tests; when there are no relevant tests, recommend the path <业务目录>/__test__/<stem>.test.ts. The existence of a file with the same name does not mean coverage is sufficient, and the absence of tests in the same directory does not automatically mean missing tests.
Severity
| Level | Meaning | Typical | Effect on conclusion |
|---|---|---|---|
| ❌ P0 | Must fix | Security vulnerabilities, clear functional bugs, TS/test verification failures | Any present means fail |
| ❌ P1 | Needs fixing | Boundary defects, props not matching definitions, missing tests | Any present requires fixing |
| ⚠️ Warning | Non-blocking | Style deviations, redundancy, naming, dependency upgrades lacking rationale | Does not affect the conclusion |
6. Output a three-part report
First output it in full in the conversation.CHECKPOINT: user authorization is required before writing the report. If the user has not yet authorized writing to disk, ask per the interaction agreement whether to write to a local file (filename see step 1); write only if agreed, otherwise keep it in the conversation only. Layout:
# Code Review 报告:<PR 标题 / 分支名 / 工作区改动>
## 一、Review 结果汇总
| 检查项 | 结果 |
| --- | --- |
| 代码逻辑检查 | ✅ / ❌ / ⏭️ N/A |
| TS 定义检查 | ✅ / ❌ / ⏭️ N/A |
| UI 引用与 Props 检查 | ✅ / ❌ / ⏭️ N/A |
| CSS 样式检查 | ✅ / ❌ / ⏭️ N/A |
| 依赖版本影响检查 | ✅ / ❌ / ⏭️ N/A(无 package.json 改动) |
| 配置项影响检查 | ✅ / ❌ / ⏭️ N/A(无配置文件改动) |
| TS 验证(tsc) | ✅ 通过 / ❌ 失败 / ⚠️ 基线遗留(base 同样失败) / ⚠️ 环境异常 / ⏭️ 跳过(原因) |
| 测试验证(vitest) | ✅ N 个文件全通过 / ❌ 失败 / ⚠️ 基线遗留(base 同样失败) / ⚠️ 环境异常 / ⏭️ 无相关测试 |
| 测试用例缺失检查 | ✅ 齐全 / ❌ 缺失 N 处 |
**统计:正确 X 项 / 问题 Y 项(P0 a 项 / P1 b 项)/ 警告 Z 项**
## 二、明细解释
> 每项固定两行:第一行定位,第二行缩进两格写原因。第一行末尾两个空格(markdown hard break;下方 `··` 表示这两个空格,不要真写点号)。不得并成一行,也不得超过两行;细节压缩进第二行。
### ✅ 正确项
- 内容描述(确认了什么)··
原因结果(为什么正确 / 验证依据)
### ❌ 问题项
行号必须写(函数定义行等);缺测试用关键函数行号。不允许只写路径。
- [P0] `文件:行号`··
原因结果:<问题是什么> → <修复建议>
- [P1] `文件:行号`··
原因结果:<问题是什么> → <修复建议>
### ⚠️ 警告项
- `文件:行号` 或 <一句话标题>··
原因结果:<说明与建议>
## 三、合并结论
**结论:不通过 / 需要修复 / 可以合并**
<只允许这三种,不得出现「修复后可合并」等中间态>
Statistics: each dimension that passes overall counts as 1 correct item; each problem/warning counts as 1 item; each of tsc / vitest passing counts as 1 correct item. ⏭️ N/A and ⚠️ environment anomalies are not counted in the three statistics.
| Situation | Conclusion |
|---|---|
| Any P0 | Fail |
| No P0, has P1 | Needs fixing |
| Warnings only or all correct | Can merge |