Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add laolaoshiren/claude-code-skills-zh --skill refactor-advisorgit clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zhWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/laolaoshiren/claude-code-skills-zh/refactor-advisor)<a href="https://agentmods.dev/skills/laolaoshiren/claude-code-skills-zh/refactor-advisor"><img src="https://agentmods.dev/badge/skills/laolaoshiren/claude-code-skills-zh/refactor-advisor/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/laolaoshiren/claude-code-skills-zh/refactor-advisor"><img src="https://agentmods.dev/badge/skills/laolaoshiren/claude-code-skills-zh/refactor-advisor.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00022 | $0.01046 |
| Opus 5 | $0.00011 | $0.00523 |
| Sonnet 5 | $0.00004 | $0.00209 |
| Haiku 4.5 | $0.00002 | $0.00105 |
Grade A, and why
refactor-advisor scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
代码重构顾问
触发条件
当用户要求重构代码、优化代码结构、改善代码质量、消除技术债务时激活此技能。
工作流程
第 1 步:扫描代码库
- 使用
grep/rg扫描目标目录,识别潜在坏味道 - 统计文件行数、函数长度、参数数量等指标
- 查找重复代码块(相似度 > 80%)
第 2 步:分类坏味道
按严重程度分类发现的问题:
| 等级 | 含义 | 说明 |
|---|---|---|
| 🔴 严重 | 必须立即修复 | 影响可维护性和稳定性 |
| 🟡 中等 | 建议尽快修复 | 降低代码可读性 |
| 🟢 轻微 | 可择机优化 | 不影响功能但有改进空间 |
第 3 步:优先级排序
按以下维度综合排序:
- 影响范围 — 被引用/调用次数越多,优先级越高
- 变更频率 — git log 频繁改动的文件优先
- 修复成本 — 成本低且收益高的优先处理
第 4 步:输出重构方案
常见坏味道检测
| 坏味道 | 特征 | 重构手法 | 等级 |
|---|---|---|---|
| 长方法 | 函数超过 50 行 | 提取方法 (Extract Method) | 🔴 |
| 大类 | 类超过 300 行 | 提取类 (Extract Class) | 🔴 |
| 重复代码 | 相似代码块出现 3+ 次 | 提取公共方法 | 🔴 |
| 过长参数 | 函数参数超过 4 个 | 引入参数对象 | 🟡 |
| 嵌套过深 | if/for 嵌套 3+ 层 | 卫语句 (Guard Clause) | 🟡 |
| 魔法数字 | 硬编码的数字 | 提取为常量 | 🟢 |
| 过长链式调用 | a.b.c.d.e | 提取中间变量 | 🟢 |
| 全局可变状态 | 全局变量被多处修改 | 封装为模块/引入依赖注入 | 🔴 |
| 过度耦合 | 模块间相互依赖 | 依赖反转、引入接口 | 🟡 |
输出格式
完整报告模板
# 代码重构报告
## 概要
- 扫描文件数: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:
function processUser(data) { const validated = validateUserData(data); return saveToDatabase(validated); }
重构路线图
| 阶段 | 内容 | 优先级 | 预估 |
|---|---|---|---|
| P1 | 修复 🔴 严重问题 | 高 | 2天 |
| P2 | 处理 🟡 中等问题 | 中 | 3天 |
| P3 | 优化 🟢 轻微问题 | 低 | 1天 |
## 注意事项
- 重构前确保有足够的测试覆盖
- 每次重构尽量小步提交,便于回滚
- 重构不应改变外部行为(行为保持)
- 大规模重构建议分阶段进行,每阶段独立可验证
- 关注重构过程中的性能回退风险
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 10d ago First seen · 99 lines · 22 tokens per session scan A 79e57f70f0bf
refactor-advisor is a skill published in the GitHub repository laolaoshiren/claude-code-skills-zh (828 stars, last pushed today), licensed MIT. It adds 22 tokens to every session and 1,046 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
resolve-pr-comments
Evaluate, fix, answer, and reply to GitHub pull request review comments and conversation comments. Handles both change requests (fix or skip) and reviewer questions (explain using reasoning recalled from past Claude Code transcripts). Use when the user asks to "resolve PR comments", "fix review comments", "address PR…
review-code
Review code for bugs, security vulnerabilities, API misuse, consistency issues, simplicity problems, or test coverage gaps by running internal reviews and a peer review in parallel and returning combined findings. Single-concern with a type argument, or full review with no argument. Use when the user asks to "review…
assess-technical-debt
Assess project-wide structural technical debt: complexity hotspots, deprecated API usage, duplication clusters, and architecture rot. Ranks findings by impact and refactor effort into a report at .turbo/technical-debt.md. Use when the user asks to "assess technical debt", "find technical debt", "review technical…
map-codebase
Deep architecture report that fans out parallel inspections across different aspects of the codebase (structure, tech stack, APIs, patterns, data flow, dependencies, testing) and synthesizes findings into a comprehensive document at .turbo/codebase-map.md and .turbo/codebase-map.html. Use when the user asks to "map…
peer-review
Run an independent peer review via Codex. Use when the user asks to "peer review", "peer review my code", "peer review my plan", "get a second opinion", or "independent review".
claude-print
Run a non-interactive Claude Code print-mode call from Codex. Use when the user asks to "claude print", "ask claude", "run claude", "consult claude", or when a Codex Turbo skill needs Claude as an independent peer reviewer.