用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/seikaikyo/dash-skills --skill refactor-cleaner命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Use when reviewing code for security vulnerabilities, implementing authentication/authorization, handling user input, or discussing web application security. Covers OWASP Top 10:2025, ASVS 5.0, LLM Top 10 (2025), and Agentic AI security (2026).
Guides authoring of high-quality YARA-X detection rules for malware identification. Use when writing, reviewing, or optimizing YARA rules. Covers naming conventions, string selection, performance optimization, migration from legacy YARA, and false positive reduction. Triggers on: YARA, YARA-X, malware detection, threat hunting, IOC, signature, crx module, dex module.
Throwaway HTML mockups: 2-3 design variants to compare.
基于 SOC 职业分类
正在显示 SKILL.md
| name | refactor-cleaner |
| description | 死代碼清理與整合專家。用於移除未使用的程式碼、重複程式碼和重構。執行分析工具 (knip, depcheck, ts-prune) 識別死代碼並安全移除。 |
| source | everything-claude-code (MIT License) |
| original_author | affaan-m |
| updated | "2026-01-22T00:00:00.000Z" |
在以下情況使用此 Skill:
# knip - 找出未使用的檔案、exports、依賴
npx knip
# depcheck - 識別未使用的 npm 依賴
npx depcheck
# ts-prune - 找出未使用的 TypeScript exports
npx ts-prune
# eslint - 檢查未使用的變數
npx eslint . --report-unused-disable-directives
a) 平行執行檢測工具
b) 收集所有發現
c) 依風險分類:
- 安全: 未使用的 exports、依賴
- 小心: 可能透過動態 import 使用
- 風險: 公開 API、共用工具
對每個要移除的項目:
a) 只從「安全」項目開始
b) 一次移除一個類別:
1. 未使用的 npm 依賴
2. 未使用的內部 exports
3. 未使用的檔案
4. 重複程式碼
c) 每批次後執行測試
d) 每批次建立 git commit
a) 找出重複的元件/工具
b) 選擇最佳實作:
- 功能最完整
- 測試最完善
- 最近使用的
c) 更新所有 imports 使用選定版本
d) 刪除重複
e) 驗證測試仍通過
建立/更新 docs/DELETION_LOG.md:
# 程式碼刪除日誌
## [YYYY-MM-DD] 重構作業
### 移除的依賴
- package-name@version - 最後使用: 從未, 大小: XX KB
- another-package@version - 已被取代: better-package
### 刪除的檔案
- src/old-component.tsx - 取代為: src/new-component.tsx
- lib/deprecated-util.ts - 功能移至: lib/utils.ts
### 整合的重複程式碼
- src/components/Button1.tsx + Button2.tsx -> Button.tsx
- 原因: 兩個實作完全相同
### 移除的 Exports
- src/utils/helpers.ts - 函數: foo(), bar()
- 原因: 程式碼庫中無引用
### 影響
- 刪除檔案: 15
- 移除依賴: 5
- 移除程式碼行數: 2,300
- 套件大小減少: ~45 KB
### 測試
- 所有單元測試通過
- 所有整合測試通過
- 手動測試完成
移除任何東西前:
每次移除後:
// 移除未使用的 imports
import { useState, useEffect, useMemo } from 'react' // 只用到 useState
// 只保留使用的
import { useState } from 'react'
// 移除不可達程式碼
if (false) {
// 永遠不會執行
doSomething()
}
// 移除未使用的函數
export function unusedHelper() {
// 程式碼庫中無引用
}
// 多個相似元件
components/Button.tsx
components/PrimaryButton.tsx
components/NewButton.tsx
// 整合為一個
components/Button.tsx (使用 variant prop)
// 已安裝但未 import 的套件
{
"dependencies": {
"lodash": "^4.17.21", // 無處使用
"moment": "^2.29.4" // 已被 date-fns 取代
}
}
如果移除後出錯:
# 1. 立即回滾
git revert HEAD
npm install
npm run build
npm test
# 2. 調查原因
# - 什麼失敗了?
# - 是動態 import?
# - 檢測工具遺漏了什麼?
# 3. 修正向前
# - 標記為「禁止移除」
# - 記錄為何檢測工具遺漏
# - 加上明確類型註解
## 重構: 程式碼清理
### 摘要
死代碼清理,移除未使用的 exports、依賴和重複。
### 變更
- 移除 X 個未使用的檔案
- 移除 Y 個未使用的依賴
- 整合 Z 個重複元件
- 詳見 docs/DELETION_LOG.md
### 測試
- [x] 建構通過
- [x] 所有測試通過
- [x] 手動測試完成
- [x] 無 console 錯誤
### 影響
- 套件大小: -XX KB
- 程式碼行數: -XXXX
- 依賴: -X 套件
### 風險等級
低 - 僅移除可驗證的未使用程式碼
詳見 DELETION_LOG.md。
清理作業後: