Skip to content
Back to skills

Refactoring Assistant

ASecurity

[UDS] 引导重构决策与策略选择,包含「重构还是重写」这个判断。 Use when: 代码已经难以修改、在战术性与架构性重构之间做选择、要在老旧代码里安全地动手。 Not for: 换到不同框架或主版本——请用 /migrate;清除调试残留与死代码——请用 /sweep。 Keywords: refactor, rewrite, strangler, legacy code, technical debt, code smell, 重构, 重写, 技术债, 坏味道.

  • 86 stars
  • 0 votes
  • 2 copies
  • 20 views
  • Added February 8, 2026
developmentrefactoring

Security analysis

A100/100

Scanned November 9, 2026

npx -y skills add AsiaOstrich/universal-dev-standards --skill refactoring-assistant --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Refactoring Assistant?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Refactoring Assistant
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/asiaostrich-refactoring-assistant/badge)](https://www.skillsdirectory.com/skills/asiaostrich-refactoring-assistant)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
source: ../../../../skills/refactoring-assistant/SKILL.md
source_version: 2.0.0
translation_version: 2.1.0
last_synced: 2026-10-11
source_hash: 22be2c4ae81e
status: current
description: |
  [UDS] 引导重构决策与策略选择,包含「重构还是重写」这个判断。
  Use when: 代码已经难以修改、在战术性与架构性重构之间做选择、要在老旧代码里安全地动手。
  Not for: 换到不同框架或主版本——请用 /migrate;清除调试残留与死代码——请用 /sweep。
  Keywords: refactor, rewrite, strangler, legacy code, technical debt, code smell, 重构, 重写, 技术债, 坏味道.
---

# 重构助手

> **语言**: [English](../../../../skills/refactoring-assistant/SKILL.md) | 简体中文

引导重构决策、推荐策略,并提供逐步执行工作流程。

## 使用方式

| 命令 | 用途 |
|------|------|
| `/refactor` | 启动交互式重构引导 |
| `/refactor decide` | 执行重构 vs 重写决策树 |
| `/refactor tactical` | 建议战术性(日常)策略 |
| `/refactor strategic` | 引导战略性/架构重构 |
| `/refactor legacy` | 遗留代码安全策略 |
| `/refactor debt` | 技术债评估 |

## 策略快速参考

### 战术性策略(日常)

| 策略 | 使用时机 |
|------|---------|
| **准备式重构** | 新增被阻挡的功能之前 |
| **童子军法则** | 任何维护工作中 |
| **红-绿-重构** | TDD 开发循环 |

### 战略性策略(架构)

| 策略 | 使用时机 |
|------|---------|
| **绞杀者无花果** | 逐步替换整个系统 |
| **防腐层** | 与遗留系统集成 |
| **抽象分支** | 在主干上重构共享代码 |

### 安全防护策略(遗留代码)

| 策略 | 使用时机 |
|------|---------|
| **特征化测试** | 任何遗留代码重构之前 |
| **草稿式重构** | 理解黑盒代码 |
| **寻找接缝** | 在遗留代码中注入测试替身 |

## 工作流程

1. **评估** - 识别要重构的代码,评估测试覆盖率
2. **决策** - 需要时执行决策树(重构 vs 重写)
3. **选择策略** - 根据范围和风险选择适当策略
4. **执行** - 遵循逐步工作流程,包含安全检查
5. **验证** - 执行测试以确认行为未被改变

## 使用示例

```
User: /refactor src/legacy-auth/
AI: 正在分析 src/legacy-auth/...
    测试覆盖率:23% — 建议采用安全优先的做法。
    建议策略:特征化测试 + 准备式重构
```

```
User: /refactor decide
AI: 我来帮你决定该重构还是重写。
    问题 1:这段代码目前是否在生产环境中正常运行?[Y/N]
```

## 下一步引导

`/refactor` 完成后,AI 助手应建议:

> **重构完成。建议下一步:**
> - 执行 `/checkin` 通过品质关卡 ⭐ **推荐**
> - 执行 `/coverage` 确认重构后覆盖率不下降
> - 执行 `/commit` 提交重构变更

## 参考

- 详细指南:[guide.md](./guide.md)
- 核心规范:[refactoring-standards.md](../../../../core/refactoring-standards.md)

## AI 代理行为

> 完整的 AI 行为定义请参阅对应的命令文件:[`/refactor`](../commands/refactor.md#ai-代理行为)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.