skills/refactor-cleaner/SKILL.md
死代碼清理與整合專家。用於移除未使用的程式碼、重複程式碼和重構。執行分析工具 (knip, depcheck, ts-prune) 識別死代碼並安全移除。
npx skillsauth add seikaikyo/dash-skills refactor-cleanerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
在以下情況使用此 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。
清理作業後:
tools
Conduct comprehensive GDPR compliance assessments by evaluating data processing activities against EU Regulation 2016/679, including Article 30 records of processing, lawful basis validation, data subject rights implementation, Data Protection Impact Assessments (DPIAs) under Article 35, breach notification procedures, international transfer safeguards (SCCs, adequacy decisions), and technical/organizational measures under Article 32. Use when processing personal data of EU residents, preparing for supervisory authority audits, implementing privacy-by-design for new systems, scoping compliance gaps for M&A due diligence, assessing third-party processors, or responding to data subject access requests at scale. Incorporates 2026 guidance from ICO, EDPB, and post-Data (Use and Access) Act 2025 UK-GDPR considerations. Do not use for implementing specific Article 32 controls — use implementing-gdpr-data-protection-controls; or for DSAR automation — use implementing-gdpr-data-subject-access-request.
tools
Parse Windows forensic artifacts—$MFT/$J (MFTECmd), Prefetch (PECmd), registry hives (RECmd), shellbags, and Amcache—into normalized CSV/JSON with Eric Zimmerman's EZ Tools, then load results into Timeline Explorer for analysis. Use during DFIR/incident-response investigations, after triage collection (e.g. with KAPE), to establish program execution, file/folder access, and persistence evidence from acquired forensic images.
development
Build automated multi-turn adversarial attacks against conversational LLM targets using Microsoft PyRIT's RedTeamingOrchestrator, CrescendoOrchestrator (gradual escalation), and TreeOfAttacksWithPruningOrchestrator (adaptive branching), with scorer feedback loops and persisted conversation memory. Use when single-shot LLM scanning is insufficient and you need multi-turn, scorer-driven AI red-team campaigns against a chatbot or agent.
testing
Stand up MISP, enable and cache curated threat feeds (CIRCL, abuse.ch, Feodo Tracker), apply warninglists to suppress false positives, query indicators with PyMISP, and export attributes as auto-generated Suricata/Sigma/Wazuh detection rules. Use when maturing a MISP instance to actively drive detection, curating threat feeds with quality controls, or automating IOC-to-detection pipelines for the SIEM/IDS.