Agent skill · Audited from source
Refactor Advisor
skill · laolaoshiren/claude-code-skills-zhMIT licenceAudited 19 Oct 2026 · source 7d69626375c6
Is it safe? Yes — SAFE, grade B (89/100). We read this skill's source at commit 7d69626375c6 and found no filesystem, network or shell access and no hard-coded secrets. What it does: 重构顾问 - 识别代码坏味道并提供重构方案
Cite
Cite this page
ModelsAtlas. “Refactor Advisor (laolaoshiren/claude-code-skills-zh)”. Retrieved 19 Oct 2026. https://modelsatlas.com/skills/laolaoshiren/refactor-advisor
Trust audit
Audit 0.4.1 · source read 19 Oct 2026
SAFE means nothing in the source contradicts what the skill says it does. Grade B is shared by 13,985 of 14,816 audited skills.
What the source does
- FilesystemNone observedNo reads or writes in the source
- NetworkNone observedNo outbound calls in the source
- ShellNone observedNo commands run in the source
- DependenciesPinnedNothing floats
- SecretsNone foundNo keys in source
Five audit layers
| Layer | What we check | Result | Findings |
|---|---|---|---|
L0 Provenance | Repo owner, licence, archive status, activity | PASS | 0 |
L1 Static source | Secrets, path traversal, supply chain, hidden code | NA | 0 |
L2 Instructions | Prompt injection, authority framing, hidden directives | PASS | 0 |
L3 Inventory | The files and declarations match the source | PASS | 0 |
L4 Sandbox | Run in isolation and watch behaviour | SKIPPED why | 0 |
Gates applied: no behavioural pass.
Findings (0)
No findings at any severity. We re-audit when the source changes.
Audit 0.4.1 · source sha 7d69626375c6 · 19 Oct 2026Report an issue or request a re-scan
Provenance
Who published it, and what the verdict is pinned to
- Publisherlaolaoshiren GitHub userOwner of the repository this skill is read from
- Source folderlaolaoshiren/claude-code-skills-zh/skills/refactor-advisorThe exact folder we audited
- LicenceMITAs the repository states it
- Commit pinned for this verdict7d69626375c6A new audit runs when the source changes
- Repository statusNot archivedPushed today
- Sandboxed runNot runSkills are read, not executed; layer L4 is skipped
What it tells the agent
Full source on GitHub ↗Its description: 重构顾问 - 识别代码坏味道并提供重构方案
---
name: refactor-advisor
description: 重构顾问 - 识别代码坏味道并提供重构方案
---
# 代码重构顾问
## 触发条件
当用户要求重构代码、优化代码结构、改善代码质量、消除技术债务时激活此技能。
## 工作流程
### 第 1 步:扫描代码库
- 使用 `grep`/`rg` 扫描目标目录,识别潜在坏味道
- 统计文件行数、函数长度、参数数量等指标
- 查找重复代码块(相似度 > 80%)
### 第 2 步:分类坏味道
按严重程度分类发现的问题:
| 等级 | 含义 | 说明 |
|------|------|------|
| 🔴 严重 | 必须立即修复 | 影响可维护性和稳定性 |
| 🟡 中等 | 建议尽快修复 | 降低代码可读性 |
| 🟢 轻微 | 可择机优化 | 不影响功能但有改进空间 |
### 第 3 步:优先级排序
按以下维度综合排序:
1. **影响范围** — 被引用/调用次数越多,优先级越高
2. **变更频率** — git log 频繁改动的文件优先
3. **修复成本** — 成本低且收益高的优先处理
### 第 4 步:输出重构方案
## 常见坏味道检测
| 坏味道 | 特征 | 重构手法 | 等级 |
|--------|------|---------|------|
| 长方法 | 函数超过 50 行 | 提取方法 (Extract Method) | 🔴 |
| 大类 | 类超过 300 行 | 提取类 (Extract Class) | 🔴 |
| 重复代码 | 相似代码块出现 3+ 次 | 提取公共方法 | 🔴 |
| 过长参数 | 函数参数超过 4 个 | 引入参数对象 | 🟡 |
| 嵌套过深 | if/for 嵌套 3+ 层 | 卫语句 (Guard Clause) | 🟡 |
| 魔法数字 | 硬编码的数字 | 提取为常量 | 🟢 |
| 过长链式调用 | a.b.c.d.e | 提取中间变量 | 🟢 |
| 全局可变状态 | 全局变量被多处修改 | 封装为模块/引入依赖注入 | 🔴 |
| 过度耦合 | 模块间相互依赖 | 依赖反转、引入接口 | 🟡 |
## 输出格式
### 完整报告模板
```markdown
# 代码重构报告
## 概要
- 扫描文件数:XXX
- 发现问题数:XX(🔴 X / 🟡 X / 🟢 X)
- 预估工作量:X 天
## 问题列表
### 问题 1:[问题标题]
- **📍 位置**:`src/services/user.ts:45-120`
- **🔍 问题**:该函数长达 75 行,包含 3 层嵌套,职责不单一
- **🛠️ 重构方案**:
- 提取 `validateUserData()` 方法
- 提取 `saveToDatabase()` 方法
- 使用卫语句替代嵌套 if
- **⚠️ 风险评估**:
- 该函数被 12 处调用,需全面回归测试
- 建议先添加单元测试再重构
- **Before**:
```typescript
function processUser(data) { /* 75行... */ }
```
- **After**:
```typescript
function processUser(data) {
const validated = validateUserData(data);
return saveToDatabase(validated);
}
```
## 重构路线图
| 阶段 | 内容 | 优先级 | 预估 |
|------|------|--------|------|
| P1 | 修复 🔴 严重问题 | 高 | 2天 |
| P2 | 处理 🟡 中等问题 | 中 | 3天 |
| P3 | 优化 🟢 轻微问题 | 低 | 1天 |
```
## 注意事项
- 重构前确保有足够的测试覆盖
- 每次重构尽量小步提交,便于回滚
- 重构不应改变外部行为(行为保持)
- 大规模重构建议分阶段进行,每阶段独立可验证
- 关注重构过程中的性能回退风险Excerpt, first 1,820 characters of SKILL.md, verbatim from the audited commit. It is text from someone else’s repository, quoted so you can judge it before your agent reads it.
Install
Pinned to the audited commit 7d69626
git clone https://github.com/laolaoshiren/claude-code-skills-zh git -C claude-code-skills-zh checkout 7d69626375c6
The author documents no install command, so this uses the repository directly. Our verdict covers commit 7d69626375c6 only.
Works in
The author has not said which agents this skill supports, and we have not tested it in any.
Audit history
Every audit, every source change
- ✓SAFE B 89 / 100
first audit · source
7d69626375c6
Similar skills
All coding & review skills →laolaoshiren/claude-code-skills-zh
依据真实 OpenAPI、路由实现和现有测试生成并验证 API 测试。用于用户要求测试接口、补集成测试、验证 API 契约、生成回归用例或排查接口兼容性时;区分“生成测试”和“执行请求”的授权,不猜测状态码、响应结构或 SLA,不在未确认环境中发送写请求。
laolaoshiren/claude-code-skills-zh
Changelog 生成器 - 从 Git 历史自动生成 CHANGELOG
laolaoshiren/claude-code-skills-zh
数据库迁移助手 - Schema 对比、迁移脚本生成
laolaoshiren/claude-code-skills-zh
审计 Node.js、Python、Go、Rust、JVM、Ruby 项目的依赖漏洞、版本健康度与许可证事实;当用户要求检查 package.json、lockfile、requirements、go.mod、Cargo.toml、pom.xml、Gemfile.lock,或生成不改依赖的中文审计报告时使用
laolaoshiren/claude-code-skills-zh
项目目录结构地图 - 生成带说明的可视化目录树,快速理解任意代码库
laolaoshiren/claude-code-skills-zh
环境变量管理器:扫描、校验、同步 .env 文件,生成安全配置模板
Questions about Refactor Advisor
What does the Refactor Advisor skill do?
Is Refactor Advisor safe to install?
What can Refactor Advisor access on my machine?
How current is this page?
Sources
- github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/r — the audited source at commit 7d69626375c6 and every finding aboveObserved · 19 Oct 2026
Spotted something wrong? Report a correction · Methodology
Keep going in your AI
Opens with this page as the source. We add nothing else to the prompt.
- What does the Refactor Advisor skill do?
- Is Refactor Advisor safe to install?
- What can Refactor Advisor access on my machine?