重构顾问 - 识别代码坏味道并提供重构方案
Scanned 5/27/2026
Install to Claude Code
npx -y skills add laolaoshiren/claude-code-skills-zh --skill refactor-advisor --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Refactor Advisor?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/laolaoshiren-refactor-advisor)More formats (shields.io, HTML) on the badges page.
---
name: refactor-advisor
description: 重构顾问 - 识别代码坏味道并提供重构方案
---
# 代码重构顾问
## 触发条件
当用户要求重构代码、优化代码结构、改善代码质量、消除技术债务时激活此技能。
## 常见坏味道检测
| 坏味道 | 特征 | 重构手法 |
|--------|------|---------|
| 长方法 | 函数超过 50 行 | 提取方法 (Extract Method) |
| 大类 | 类超过 300 行 | 提取类 (Extract Class) |
| 重复代码 | 相似代码块出现 3+ 次 | 提取公共方法 |
| 过长参数 | 函数参数超过 4 个 | 引入参数对象 |
| 嵌套过深 | if/for 嵌套 3+ 层 | 卫语句 (Guard Clause) |
| 魔法数字 | 硬编码的数字 | 提取为常量 |
| 过长链式调用 | a.b.c.d.e | 提取中间变量 |
## 输出格式
为每个问题提供:
1. 📍 定位(文件 + 行号)
2. 🔍 问题描述
3. 🛠️ 重构方案(含 before/after 代码)
4. ⚠️ 注意事项
No comments yet. Be the first to comment!