Files
everything-claude-code-zh/commands/refactor-clean.md

29 lines
828 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 重构清理 (Refactor Clean)
安全地识别并通过测试验证移除死代码Dead Code
1. 运行死代码分析工具:
- knip查找未使用的导出和文件
- depcheck查找未使用的依赖
- ts-prune查找未使用的 TypeScript 导出
2.`.reports/dead-code-analysis.md` 中生成详细报告
3. 按严重程度对结果进行分类:
- 安全SAFE测试文件、未使用的工具类
- 谨慎CAUTIONAPI 路由、组件
- 危险DANGER配置文件、主入口点
4. 仅建议进行安全的删除
5. 在每次删除之前:
- 运行完整的测试套件
- 验证测试通过
- 应用更改
- 重新运行测试
- 如果测试失败则回滚
6. 显示已清理项的摘要
严禁在未运行测试的情况下删除代码!