AgentSkillsCN

irefactor

遵循单一职责原则与设计模式重构代码。当需要分离功能、减少代码重复,或提升代码可维护性时,可使用此技能。

SKILL.md
--- frontmatter
name: irefactor
description: Refactor code following Single Responsibility Principle and design patterns. Use when separating functions, reducing duplication, or improving code maintainability.

This is user-defined command

This is user-defined command. You must refactor the code.

Arguments

$ARGUMENTS

This command can take options. Therefore, arguments can be passed as variadic parameters. Please refer to the details below.

The input can be in the form /irefactor @[file] [msg]. The [msg] option is for user-defined requests. Both the msg and file fields may or may not be provided.

If the msg field is provided, proceed with refactoring to satisfy those requirements. If the msg field is not provided, please refactor comprehensively.

If a file mentioned with the @ symbol is provided, please refactor only that file. If files related to that file need to be refactored, proceed with the refactoring and additionally report the files that were refactored.

If no file is mentioned with the @ symbol, refactor all files in the current directory and its subdirectories based on where the agent is located. If files in parent directories or other directories need to be refactored, proceed with the refactoring and additionally report the files that were refactored.

  • Please separate the code for functions that perform two roles so that each function adheres to the Single Responsibility Principle.
  • Use appropriate design patterns to increase maintainability.
  • Restructure the code to minimize duplication.

Command behavior

  • You must use refactorer and CodeReviewer agent unconditionally.

Before modifying code, use the refactorer to establish a plan and execute it. After code modifications are complete, verify the code through the CodeReviewer agent. If the CodeReviewer agent's approval conditions are not satisfied, explain the reasons for the disapproval. (No additional work such as refactoring will be performed thereafter.)