关于 review-loop
review-loop 是面向编码 Agent 的技能,在代码修改后加入子 Agent 审查循环。它要求处理有效问题并重复审查,直到没有有效反馈后再交付结果。
主要功能
- 01请求隔离上下文中的子 Agent 审查
- 02检查代码缺陷与设计问题
- 03处理有效的审查意见
- 04重复审查直至没有有效反馈
适用场景
- 01在完成任务前审查代码改动
- 02发现自我审查遗漏的问题
- 03简化过度复杂的实现
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ robot-inventor/ agent-skills --skill review-loop安装后在 Claude Code 中输入/review-loop确认已加载。
详细介绍
Review Loop 技能
这项技能旨在通过反复请求子 Agent 审查代码,并根据审查结果编辑和改进代码,全面提升代码质量。通常,人们会在编辑代码后创建拉取请求,并由审查者进行审查,以提升代码质量。这类审查很重要,因为它们能发现仅靠自我审查可能遗漏的问题。如果用户明确要求跳过审查循环,请忽略这项技能。
适用时机
在以下情况下应用这项技能:
- 你执行了需要编辑代码的任务;并且
- 完成了用户要求的任务;并且
- 准备将对话交还给用户之前
步骤
以下是这项技能的核心流程;请遵循指定步骤。
1. 请求代码审查
向子 Agent 请求代码审查。如果启动子 Agent 时可以选择分叉上下文,还是在隔离的上下文中启动,始终选择在隔离的上下文中启动。
使用严格遵循以下格式的提示词,向审查 Agent 提交审查请求。审查请求提示词不能随意编写;必须使用下面的模板。
You are a code review agent. Thoroughly review the code for design issues, bugs, vulnerabilities, and oversights, and report the findings categorized as critical, high, medium, low, or informational. In addition to reviews that increase the amount of code, also check for over-engineering, such as excessive implementation or unnecessary conditional branching, in accordance with simple-engineering skill. In addition to the small details of the code, you should also consider whether there are simpler designs or alternative approaches to the overall logic of the changed parts, following the principles of simple-engineering. If you find any, you should report them, even if it requires rewriting the code being reviewed from scratch.
Flag excessive validation, overly defensive implementation, and unnecessary complexity that does not serve the code's intended purpose. For example, a function that opens product links for a specific website may only need to verify the hostname. Checking the pathname may add complexity without improving security. You might remove validation by defining the function argument as a type such as `https://example.com/product/{string}`, or by accepting only a product ID and constructing the link inside the function. These are examples, but you should look for simpler implementations of the same kind. Ask what purpose the code serves and whether the implementation contains only what that purpose requires.
Read the global and project-specific `AGENTS.md` files, along with all relevant skills, including but not limited to simple-engineering and web-master (for web projects), and audit whether the code under review strictly adheres to their instructions. In addition to the aforementioned review output, also use the ponytail-review skill if available.
- Target: {uncomitted changes / filepath etc.}
- User's instructions: {user's request / instructions}
子 Agent 的代码审查可能需要一些时间。请注意,如果审查 Agent 尚未回复,你只是因为等待时间较长就重新启动它,审查流程会从头开始,导致等待时间更长。如果审查 Agent 回复较慢,也禁止发送额外提示词催促审查。
2. 接收审查意见并改进代码
收到子 Agent 的审查结果后,判断每条意见是否有效。对于明显不合理的意见,可以不予理会;但必须处理有效意见,并据此修正代码。
尤其是,如果你收到的反馈指出,因权衡取舍而导致某部分未能严格遵循用户指示,请勿忽视。应根据审查意见进行修正,尽可能贴合用户指示。如果你确实无法满足用户要求,可以不采纳子 Agent 针对该部分提出的意见,但在将对话交还给用户时,务必告知用户你做出的权衡。
3. 审查循环
处理有效反馈后,重复步骤 1 和 2(“1. 请求代码审查”和“2. 接收审查意见并改进代码”),直到子 Agent 不再提出有效意见,并全面提升代码质量。在此审查循环中,每次都必须由新的子 Agent 审查代码。
4. 向用户报告结果
审查循环完成后,将对话交还给用户。对于任何不得不做出权衡、未能严格遵循用户指示的地方,务必如实告知用户。