review-loop
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReview Loop Skill
审查循环 Skill
This skill involves thoroughly improving code quality by repeatedly requesting a review from a sub-agent after editing and improving the code based on the results. Humans typically improve code quality by creating a pull request after editing code and having it reviewed by a reviewer. Such reviews are important because they can identify problems that might be missed through self-review alone.
此 skill 涉及在编辑代码并根据审查结果改进代码后,反复请求子 Agent 进行审查,从而全面提升代码质量。人类通常通过在编辑代码后创建 pull request,并交由审查者审查来提升代码质量。这类审查非常重要,因为它们能够发现仅靠自我审查可能遗漏的问题。
When to apply
适用场景
Apply this skill in the following situations:
- When you have performed a task that requires code editing, and
- After completing the task instructed by the user, and
- Before returning the conversation to the user
在以下情况下应用此 skill:
- 已完成需要编辑代码的任务;
- 已完成用户指示的任务;
- 即将把会话返回给用户之前。
Steps
步骤
The following is the core of this skill; please follow the specified steps.
以下是此 skill 的核心内容;请遵循指定的步骤。
1. Request a code review
1. 请求代码审查
Request a code review from the subagent.If you have the option to choose whether to fork the context or launch the subagent in an isolated context when starting it, always launch it in an isolated context.
Submit review requests to the review agent using a prompt that strictly adheres to the following format. Review request prompts are not free-form; you must use the template below.
md
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. 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}Code reviews by sub-agents can take time. Note that if you re-spawn a sub-agent currently undergoing a review simply because it has not yet responded, the review process will start over from scratch, resulting in even longer wait times. It is also prohibited to send additional prompts to urge a review when a review agent is taking a long time to respond.
向子 Agent 请求代码审查。如果启动时可以选择是否 fork 上下文或以隔离上下文启动子 Agent,则始终以隔离上下文启动。
使用严格遵循以下格式的提示词向审查 Agent 提交审查请求。审查请求提示词不能自由编写,必须使用下面的模板。
md
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. 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. Receive reviews and improve your code
2. 接收审查结果并改进代码
Once you receive the review results from the sub-agent, consider whether each point is valid. You may ignore clearly unreasonable points, but you must address valid points and correct the code accordingly.
In particular, if you receive feedback on a part that doesn't strictly follow the user's instructions as a result of compromises, do not ignore it. Instead, correct it according to the review to align with the user's instructions as much as possible. If you absolutely cannot comply with the user's request, you may ignore the sub-agent's point about that part, but be sure to inform the user of the compromise you made when you return the conversation to them.
收到子 Agent 的审查结果后,评估每个意见是否合理。你可以忽略明显不合理的意见,但必须处理合理的意见,并相应地修正代码。
尤其需要注意,如果由于某些妥协,审查意见指出代码的某一部分未严格遵循用户指示,则不要忽略该意见。相反,应根据审查结果修正代码,尽可能使其符合用户指示。如果确实无法满足用户请求,可以忽略子 Agent 关于该部分的意见,但在返回会话给用户时,必须说明所作的妥协。
3. Review loop
3. 审查循环
After addressing valid feedback from the subagent, repeat steps 1 and 2 ("1. Request a code review" and "2. Receive reviews and improve your code") until there is no more valid feedback from the subagent, thoroughly improving your code quality. In this review loop, always have a new subagent review your code each time.
处理完子 Agent 提出的合理反馈后,重复步骤 1 和步骤 2(“1. 请求代码审查”和“2. 接收审查结果并改进代码”),直到子 Agent 不再提出合理的反馈为止,从而全面提升代码质量。在此审查循环中,每次都必须创建一个新的子 Agent 来审查代码。
4. Report the results to the user
4. 向用户报告结果
Once the review loop is complete, return the conversation to the user. Be sure to honestly report to the user any points where you had to compromise and did not strictly follow their instructions.
审查循环完成后,将会话返回给用户。务必如实报告任何为了妥协而未能严格遵循用户指示的情况。