Help us improve
Share bugs, ideas, or general feedback.
Safely detects and removes dead code using tools like knip, depcheck, and ts-prune, classifies by safety tier, verifies each deletion with tests, and reports cleanup summary.
npx claudepluginhub xu-xiang/everything-claude-code-zhHow this command is triggered — by the user, by Claude, or both
Slash command
/everything-claude-code:refactor-cleanThe summary Claude sees in its command listing — used to decide when to auto-load this command
# 重构清理 (Refactor Clean) 安全地识别并移除死代码(Dead Code),每一步都通过测试验证。 ## 第 1 步:检测死代码 根据项目类型运行分析工具: | 工具 (Tool) | 发现内容 | 命令 (Command) | |------|--------------|---------| | knip | 未使用的导出、文件、依赖 | `npx knip` | | depcheck | 未使用的 npm 依赖 | `npx depcheck` | | ts-prune | 未使用的 TypeScript 导出 | `npx ts-prune` | | vulture | 未使用的 Python 代码 | `vulture src/` | | deadcode | 未使用的 Go 代码 | `deadcode ./...` | | cargo-udeps | 未使用的 Rust 依赖 | `cargo +nightly udeps` | 如果没有可用工具,使用 Grep 查找导入次数为零的导出: ## 第 2 步:发现结果分类 将发现的结果按安全层级排序: | 层级 (Tier) | 示例 | 动作 (Action) | |------|----------|--------| | **安全 (SAFE)** | 未使用的工具函数、测...
/refactor-cleanSafely detects and removes dead code using tools like knip, ts-prune, vulture; verifies each deletion with full test suite; categorizes by risk and reports summary.
/refactor-cleanSafely identifies dead code using analysis tools, removes safe items with test verification at each step, handles risky ones cautiously, and reports cleanup summary.
/refactor-cleanSafely identifies and removes dead code with test verification after each change. Detects unused exports, files, and dependencies using project-specific tools, then deletes in a safe loop with automatic rollback on failure.
/refactor-cleanSafely identifies dead code using knip, depcheck, ts-prune; generates analysis report; removes safe items after test verification and shows cleanup summary.
/cleanupSafely identifies and removes unused exports, files, dependencies, and dead code using knip/depcheck/grep. Risk-assesses items, verifies builds/tests, logs deletions to DELETION_LOG.md, and commits changes. Supports --dry-run|--aggressive.
/refactor-cleanSafely identifies and removes dead Python code using vulture, pyflakes, ruff, and pytest verification. Generates analysis report and cleanup summary.
Share bugs, ideas, or general feedback.
安全地识别并移除死代码(Dead Code),每一步都通过测试验证。
根据项目类型运行分析工具:
| 工具 (Tool) | 发现内容 | 命令 (Command) |
|---|---|---|
| knip | 未使用的导出、文件、依赖 | npx knip |
| depcheck | 未使用的 npm 依赖 | npx depcheck |
| ts-prune | 未使用的 TypeScript 导出 | npx ts-prune |
| vulture | 未使用的 Python 代码 | vulture src/ |
| deadcode | 未使用的 Go 代码 | deadcode ./... |
| cargo-udeps | 未使用的 Rust 依赖 | cargo +nightly udeps |
如果没有可用工具,使用 Grep 查找导入次数为零的导出:
# 查找导出,然后检查它们是否在任何地方被导入
将发现的结果按安全层级排序:
| 层级 (Tier) | 示例 | 动作 (Action) |
|---|---|---|
| 安全 (SAFE) | 未使用的工具函数、测试辅助程序、内部函数 | 放心删除 |
| 慎重 (CAUTION) | 组件、API 路由、中间件 | 验证是否存在动态导入或外部使用者 |
| 危险 (DANGER) | 配置文件、入口点、类型定义 | 动之前先调查清楚 |
对于每个 安全 (SAFE) 项目:
git checkout -- <file> 还原并跳过此项在删除 慎重 (CAUTION) 项目之前:
import()、require()、__import__移除死代码后,寻找:
报告结果:
死代码清理 (Dead Code Cleanup)
──────────────────────────────
已删除: 12 个未使用的函数
3 个未使用文件
5 个未使用的依赖
已跳过: 2 项(测试失败)
已节省: 移除约 450 行代码
──────────────────────────────
所有测试均已通过 ✅