i18n/zh-TW/refactoring/SKILL.md
識別程式碼異味與重構程式碼的指引與技巧,基於 Refactoring.guru 原則,並針對 Vanilla JS Chrome 擴充功能調整。
npx skillsauth add tai-ch0802/skills-bundle refactoringInstall 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.
這項技能旨在幫助識別程式碼異味 (Code Smells) 並應用重構技術 (Refactoring Techniques) 來提升程式碼品質。基礎原則源自 Refactoring.guru,並針對本 Chrome 擴充功能專案的特性 (Vanilla JS, Modules, Side Panel) 進行了調整。
程式碼、方法或類別變得過於龐大,難以管理。
Long Method (過長函式)
sidepanel.js 中的大型事件監聽器,或 render() 函式。Large Class / Module (過大類別/模組)
modules/uiManager.js) 承擔過多指責。Long Parameter List (過長參數列)
錯誤地應用 OO 原則。
switch 或 if-else 鏈,用於判斷類型執行不同邏輯。修改一處需要同時修改多處。
無用或多餘的程式碼。
modules/ui/elements.js 或工具函式。86400 替換為 SECONDS_IN_DAY。if (a && b || c) 提煉為 if (isSpecialCase())。DOM 操作分離:
modules/stateManager.js) 中直接操作 DOM。*Renderer.js 模組中。modules/ui/elements.js (如果可能)。狀態管理:
window.globalVar。使用 stateManager 模組來保存跨模組狀態。Chrome API 封裝:
chrome.bookmarks.*。應透過 modules/apiManager.js 呼叫,以便未來替換或測試。樣式一致性:
element.style.color = 'red'。應使用 CSS class (element.classList.add('error')) 搭配 index.css。當使用者要求「Refactor this file」或「Clean up this code」時:
development
Unified testing skill — TDD workflow, unit/integration patterns, E2E/Playwright strategies. Replaces tdd-workflow + testing-patterns + webapp-testing.
testing
Security-first skill vetting for AI agents. Use before installing any skill from ClawdHub, GitHub, or other sources. Checks for red flags, permission scope, and suspicious patterns.
development
Spec-Driven Development (SDD): A structured workflow (Requirement -> Analysis -> Implementation) enforcing explicit documentation before coding.
development
Methodologies for System Analysis (SA), focusing on technical architecture, data flow modeling, and API design.