refactor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRefactor Command
重构命令
Execute automated refactoring for $ARGUMENTS using agent.
refactor:code-simplifier使用 Agent对$ARGUMENTS执行自动化重构。
refactor:code-simplifierPre-operation Checks
操作前检查
Goal: Ensure scope resolution is deterministic before launching the agent.
Actions:
- Run and continue even if false when explicit paths are provided
git rev-parse --is-inside-work-tree - Normalize arguments by trimming whitespace and preserving quoted path segments
- Treat an empty argument list as "recent changes" mode
目标:在启动Agent前确保范围解析的确定性。
操作步骤:
- 运行,即使结果为false,若提供了明确路径则继续执行
git rev-parse --is-inside-work-tree - 标准化参数:修剪空格并保留带引号的路径段
- 将空参数列表视为“最近更改”模式
Phase 1: Determine Target Scope
阶段1:确定目标范围
Goal: Identify files to refactor based on arguments or session context.
Actions:
- If arguments provided: verify as file/directory paths using Glob
- If paths exist: use them directly as refactoring scope
- If paths don't exist: treat arguments as semantic query, search codebase with Grep
- If no arguments: run to find recently modified code files
git diff --name-only - If no recent changes found: inform user and exit without refactoring
See for search strategies and edge cases.
references/scope-determination.md目标:根据参数或会话上下文识别需要重构的文件。
操作步骤:
- 若提供参数:使用Glob验证是否为文件/目录路径
- 若路径存在:直接将其作为重构范围
- 若路径不存在:将参数视为语义查询,使用Grep搜索代码库
- 若无参数:运行查找最近修改的代码文件
git diff --name-only - 若未找到最近更改:告知用户并不执行重构即退出
有关搜索策略和边缘情况,请参阅。
references/scope-determination.mdPhase 2: Launch Refactoring Agent
阶段2:启动重构Agent
Goal: Execute agent with aggressive mode enabled.
refactor:code-simplifierActions:
- Launch agent with target scope and aggressive mode flag
refactor:code-simplifier - Pass scope determination method (paths, semantic query, or session context)
- Agent auto-loads skill and applies language-specific patterns
refactor:best-practices
See for detailed Task parameters.
references/agent-configuration.md目标:启用激进模式,启动 Agent。
refactor:code-simplifier操作步骤:
- 启动带有目标范围和激进模式标志的Agent
refactor:code-simplifier - 传递范围确定方法(路径、语义查询或会话上下文)
- Agent会自动加载Skill并应用特定语言的模式
refactor:best-practices
有关详细任务参数,请参阅。
references/agent-configuration.mdPhase 3: Summary
阶段3:总结
Goal: Report comprehensive summary of changes.
Actions:
- Report total files refactored and changes categorized by improvement type
- List best practices applied and legacy code removed
- Suggest tests to run and provide rollback command tailored to actual scope (for example: )
git restore --worktree --staged <files>
See for detailed summary format.
references/output-requirements.md目标:报告变更的全面总结。
操作步骤:
- 报告重构的文件总数,并按改进类型分类变更
- 列出应用的最佳实践和移除的遗留代码
- 建议运行的测试,并提供针对实际范围的回滚命令(例如:)
git restore --worktree --staged <files>
有关详细的总结格式,请参阅。
references/output-requirements.mdRequirements
要求
- Execute immediately without user confirmation
- Refactor ALL matching files when semantic search returns multiple results
- Direct users to for project-wide scope
/refactor-project - Preserve behavior and public interfaces unless user explicitly requests a behavior change
- 无需用户确认立即执行
- 当语义搜索返回多个结果时,重构所有匹配的文件
- 引导用户使用进行项目范围的重构
/refactor-project - 除非用户明确要求更改行为,否则保留现有行为和公共接口