agent-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCode Review Skill
代码审查Skill
Use this skill when you need to get human feedback on code changes you've made.
当你需要获取人工对代码变更的反馈时,可以使用这个Skill。
When to Use This Skill
使用场景
- After implementing features or fixes
- Before committing significant changes
- When you want user feedback on your approach
- When the user explicitly asks for a code review
- 完成功能开发或问题修复后
- 提交重大代码变更前
- 希望获取用户对实现方案的反馈时
- 用户明确要求进行代码审查时
Installation
安装步骤
If agent-review isn't installed:
bash
npm install -g agent-review如果未安装agent-review:
bash
npm install -g agent-reviewor run directly: npx agent-review
或直接运行:npx agent-review
undefinedundefinedHow to Use
使用方法
Step 1: Run the Code Review Tool
步骤1:运行代码审查工具
CRITICAL: Always run agent-review inline (not in background) with a long timeout:
typescript
Bash({
command: "npx agent-review",
description: "Start code review session",
timeout: 600000, // 10 minutes - user needs time to review
})DO NOT:
- ❌ Use
run_in_background: true - ❌ Use default timeout (2 minutes is too short)
- ❌ Poll bash output with BashOutput
WHY:
- The tool blocks until user submits review
- Running inline means you automatically get output when done
- User needs time to review code and add comments
- Feedback is printed to stdout when complete
重要提示: 请始终以内联方式(而非后台运行)运行agent-review,并设置较长的超时时间:
typescript
Bash({
command: "npx agent-review",
description: "启动代码审查会话",
timeout: 600000, // 10分钟 - 用户需要足够的审查时间
})禁止操作:
- ❌ 使用
run_in_background: true - ❌ 使用默认超时时间(2分钟过短)
- ❌ 使用BashOutput轮询bash输出
原因:
- 该工具会阻塞运行,直到用户提交审查结果
- 内联运行可在审查完成后自动获取输出
- 用户需要时间审查代码并添加评论
- 完成后反馈会打印到标准输出
Step 2: Automatically Read the Review Feedback
步骤2:自动读取审查反馈
After the tool completes, read the structured JSON feedback:
typescript
Read({
file_path: "/path/to/project/.agent-review/latest-review.json"
})This gives you structured data with:
- Line-by-line comments (file, line number, comment text)
- General feedback
- Review statistics
工具运行完成后,读取结构化的JSON反馈:
typescript
Read({
file_path: "/path/to/project/.agent-review/latest-review.json"
})你将获得包含以下内容的结构化数据:
- 逐行评论(文件路径、行号、评论内容)
- 整体反馈
- 审查统计信息
Step 3: Act on the Feedback
步骤3:处理反馈
Process the review feedback:
- Read line comments - Address each specific suggestion
- Read general feedback - Consider overall recommendations
- Make changes - Implement requested fixes
- Explain - Tell the user what you changed and why
处理审查反馈的步骤:
- 读取逐行评论 - 处理每一条具体建议
- 读取整体反馈 - 考虑全局性的改进建议
- 修改代码 - 实现要求的修复
- 说明变更 - 告知用户你修改了什么以及原因
Example Workflow
示例工作流
typescript
// 1. Run code review (inline, long timeout)
const result = await Bash({
command: "npx agent-review",
description: "Request code review from user",
timeout: 600000, // 10 min
});
// 2. Read structured feedback
const reviewData = await Read({
file_path: ".agent-review/latest-review.json"
});
// 3. Parse and process
const review = JSON.parse(reviewData);
// 4. Address feedback
for (const comment of review.feedback.lineComments) {
console.log(`${comment.file}:${comment.line} - ${comment.comment}`);
// Make changes based on comment
}
// 5. Report back to user
"I've addressed your feedback:
- Fixed the issue in src/app.ts:42 (using const instead of let)
- Updated error handling as suggested
..."typescript
// 1. 运行代码审查(内联模式,长超时)
const result = await Bash({
command: "npx agent-review",
description: "向用户发起代码审查请求",
timeout: 600000, // 10分钟
});
// 2. 读取结构化反馈
const reviewData = await Read({
file_path: ".agent-review/latest-review.json"
});
// 3. 解析并处理
const review = JSON.parse(reviewData);
// 4. 处理反馈
for (const comment of review.feedback.lineComments) {
console.log(`${comment.file}:${comment.line} - ${comment.comment}`);
// 根据评论修改代码
}
// 5. 向用户反馈处理结果
"我已处理你的反馈:
- 修复了src/app.ts:42的问题(将let改为const)
- 按照建议更新了错误处理逻辑
..."Review Data Structure
审查数据结构
The file contains:
.agent-review/latest-review.jsonjson
{
"id": "review-1234567890",
"timestamp": "2026-02-03T17:23:33.377Z",
"diff": { /* full git diff data */ },
"feedback": {
"timestamp": "2026-02-03T17:23:33.377Z",
"lineComments": [
{
"file": "src/app.ts",
"line": 42,
"oldLine": 41,
"comment": "Consider using const instead of let",
"context": "let x = calculateTotal();"
}
],
"generalFeedback": "Overall looks good!",
"stats": {
"filesReviewed": 5,
"commentsAdded": 3
}
}
}.agent-review/latest-review.jsonjson
{
"id": "review-1234567890",
"timestamp": "2026-02-03T17:23:33.377Z",
"diff": { /* 完整的git diff数据 */ },
"feedback": {
"timestamp": "2026-02-03T17:23:33.377Z",
"lineComments": [
{
"file": "src/app.ts",
"line": 42,
"oldLine": 41,
"comment": "Consider using const instead of let",
"context": "let x = calculateTotal();"
}
],
"generalFeedback": "Overall looks good!",
"stats": {
"filesReviewed": 5,
"commentsAdded": 3
}
}
}Best Practices
最佳实践
- Always run inline - Never use background mode
- Use long timeout - 600000ms (10 min) minimum
- Auto-read feedback - Don't ask user to tell you the feedback
- Address all comments - Go through each line comment
- Summarize changes - Tell user what you fixed
- 始终内联运行 - 切勿使用后台模式
- 设置长超时时间 - 至少600000ms(10分钟)
- 自动读取反馈 - 不要让用户手动告知你反馈内容
- 处理所有评论 - 逐一处理每条逐行评论
- 总结变更内容 - 告知用户你修复了哪些问题
Common Mistakes to Avoid
需避免的常见错误
❌ Running in background:
typescript
// WRONG - you won't get the output automatically
Bash({
command: "npx agent-review",
run_in_background: true
})❌ Short timeout:
typescript
// WRONG - will timeout before user finishes
Bash({
command: "npx agent-review",
timeout: 120000 // 2 min too short
})❌ Asking user for feedback:
typescript
// WRONG - feedback is already in the JSON file!
"What feedback do you have?"✅ Correct usage:
typescript
// RIGHT - inline, long timeout, auto-read
await Bash({
command: "npx agent-review",
timeout: 600000
});
const review = await Read({
file_path: ".agent-review/latest-review.json"
});❌ 后台运行:
typescript
// 错误 - 无法自动获取输出
Bash({
command: "npx agent-review",
run_in_background: true
})❌ 超时时间过短:
typescript
// 错误 - 用户完成前就会超时
Bash({
command: "npx agent-review",
timeout: 120000 // 2分钟过短
})❌ 询问用户反馈:
typescript
// 错误 - 反馈已在JSON文件中!
"你有什么反馈?"✅ 正确用法:
typescript
// 正确 - 内联运行、长超时、自动读取
await Bash({
command: "npx agent-review",
timeout: 600000
});
const review = await Read({
file_path: ".agent-review/latest-review.json"
});Tips
小贴士
- Before review: Tell user what changed: "I've implemented X feature across 5 files. Ready for review?"
- During review: The tool auto-opens browser and waits for user
- After review: Process feedback immediately and show user your changes
- Commit option: User can choose to commit during review - check the bash output
Remember: Always run inline with long timeout, then auto-read the JSON feedback!
- 审查前: 告知用户变更内容:"我在5个文件中实现了X功能,准备好审查了吗?"
- 审查中: 工具会自动打开浏览器并等待用户操作
- 审查后: 立即处理反馈并向用户展示你的修改
- 提交选项: 用户可在审查过程中选择提交代码 - 请检查bash输出
切记: 始终以内联模式运行并设置长超时时间,然后自动读取JSON反馈!