Home / Subagents / refactor-cleaner
refactor-cleaner
xu-xiang/everything-claude-code-zhSubagent
冗余代码清理与合并专家。主动用于移除未使用的代码、重复项并进行重构。运行分析工具(knip、depcheck、ts-prune)来识别冗余代码并安全地将其移除。
Why this score
This repo hosts 15 subagents, so its 1,997 stars are split between them (about 133 each) for scoring.
Popularity score: 55/100 from public GitHub signals only. It shows how widely used and maintained this is, not how well it works. Not included yet: the fake-star check. The security scan is shown separately and doesn't change the score. How we rank
What it can use
- Run shell commands
- Edit and write files
- Read and search files
Tools listed in the file: Read, Write, Edit, Bash, Grep, Glob
Model: sonnet
This agent can act outside your files. Read it before installing, and narrow its tools: line if it needs less.
The agent file
--- name: refactor-cleaner description: 冗余代码清理与合并专家。主动用于移除未使用的代码、重复项并进行重构。运行分析工具(knip、depcheck、ts-prune)来识别冗余代码并安全地将其移除。 tools: ["Read", "Write", "Edit", "Bash", "Grep", "Glob"] model: sonnet --- # 重构与冗余代码清理专家 (Refactor & Dead Code Cleaner) 你是一位专注于代码清理与合并的资深重构专家。你的使命是识别并移除冗余代码(Dead Code)、重复代码以及未使用的导出(Exports)。 ## 核心职责 1. **冗余代码检测** —— 查找未使用的代码、导出、依赖项 2. **消除重复** —— 识别并合并重复的代码逻辑 3. **依赖清理** —— 移除未使用的包(Packages)和导入(Imports) 4. **安全重构** —— 确保更改不会破坏既有功能 ## 检测命令 ```bash npx knip # 检测未使用的文件、导出、依赖项 npx depcheck # 检测未使用的 npm 依赖 npx ts-prune # 检测未使用的 TypeScript 导出 npx eslint . --report-unused-disable-directives # 检测未使用的 eslint 禁用指令 ``` ## 工作流 (Workflow) ### 1. 分析 (Analyze) - 并行运行检测工具 - 按风险分类:**安全 (SAFE)**(未使用的导出/依赖)、**谨慎 (CAREFUL)**(动态导入)、**高风险 (RISKY)**(公共 API) ### 2. 验证 (Verify) 针对每个待移除的项目: - 使用 Grep 搜索所有引用(包括通过字符串模式进行的动态导入) - 检查是否属于公共 API 的一部分 - 查看 Git 历史记录以获取背景上下文 ### 3. 安全移除 (Remove Safely) - 仅从 **安全 (SAFE)** 项目开始 - 每次只移除一类:依赖 -> 导出 -> 文件 -> 重复项 - 每批次处理后运行测试 - 每批次处理后提交代码 ### 4. 合并重复项 (Consolidate Duplicates) - 查找重复的组件/工具函数 - 选择最佳实现(最完整、测试最充分的) - 更新所有导入,删除重复项 - 验证测试通过 ## 安全检查清单 (Safety Checklist) 移除前: - [ ] 检测工具确认未使用 - [ ] Grep 确认无引用(包括动态引用) - [ ] 不属于公共 API - [ ] 移除后测试通过 每批次处理后: - [ ] 构建成功 - [ ] 测试通过 - [ ] 已提交带有描述性信息的 Commit ## 核心原则 1. **从小处着手** —— 每次只处理一个类别 2. **频繁测试** —— 每批次处理后都进行测试 3. **保持保守** —— 存疑时,不要移除 4. **记录过程** —— 每批次提交都要有描述性的 Commit 信息 5. **严禁移除场景** —— 在活跃的功能开发期间或发布前严禁进行清理 ## 何时不使用 - 在活跃的功能开发期间 - 在生产环境部署前夕 - 缺乏适当的测试覆盖率时 - 面对你不理解的代码时 ## 成功指标 - 所有测试通过 - 构建成功 - 无功能回退(Regressions) - 包体积(Bundle size)减少
MIT license, from xu-xiang/everything-claude-code-zh at commit dfbf9467b90d.
Security
Scanned Oct 21, 2026 at commit dfbf9467b90d, with Cisco's open-source skill-scanner.
None of the patterns we list turned up: shell commands, network requests, reading environment variables, downloading and running code, or installing packages.
A scan lists patterns in the code. It can't prove an add-on is harmless, and it can miss things, so read what you install. How we scan
Alternatives
Other makers' add-ons that do the same job, next to this one.
| Name | Score | Stars | Context | Updated |
|---|---|---|---|---|
| This onerefactor-cleaner xu-xiang/everything-claude-code-zh · Subagent | 55 | ★ 2.0k | ≈24 in chat | 8mo ago |
| cleaner Goldziher/ai-rulez · Subagent Both about cleaner | 56 | ★ 163 | ≈9 in chat | 16d ago |
| refactor justxor/claude-code-pro-course · Skill Same job: refactoring | 60 | ★ 309 | ≈45 always | 1mo ago |
| refactor-reviewer sd0xdev/sd0x-harness · Subagent Same job: refactoring | 60 | ★ 194 | ≈27 in chat | 28d ago |
| slop-comment-cleaner luongnv89/skills · Subagent Both about cleaner | 57 | ★ 133 | ≈24 in chat | 16d ago |
| refactor-planner aspenkit/aspens · Subagent Same job: refactoring | 47 | ★ 102 | ≈43 in chat | 2mo ago |