Skip to content
Agentmart
Submit a tool

dev-refactoring-catalog

程式碼重構目錄。提供基於 Martin Fowler 的重構模式、程式碼異味偵測到重構的對應、SOLID 原則違反識別,以及複雜度量測標準。適用於「重構」、「程式碼異味」、「SOLID 違反」、「複雜度」、「設計模式」、「程式碼品質」等程式碼結構改善審查任務。強化 architecture-reviewer 與…

Skill by vincent119

IndexedApache-2.0
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/vincent119-dev-refactoring-catalog

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

程式碼重構目錄。提供基於 Martin Fowler 的重構模式、程式碼異味偵測到重構的對應、SOLID 原則違反識別,以及複雜度量測標準。適用於「重構」、「程式碼異味」、「SOLID 違反」、「複雜度」、「設計模式」、「程式碼品質」等程式碼結構改善審查任務。強化 architecture-reviewer 與 performance-analyst 的分析能力。注意:直接修改程式碼與安全性分析不在此技能範圍內。

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/dev-refactoring-catalog

What's inside

Skill name
dev-refactoring-catalog
Description
程式碼重構目錄。提供基於 Martin Fowler 的重構模式、程式碼異味偵測到重構的對應、SOLID 原則違反識別,以及複雜度量測標準。適用於「重構」、「程式碼異味」、「SOLID 違反」、「複雜度」、「設計模式」、「程式碼品質」等程式碼結構改善審查任務。強化 architecture-reviewer 與 performance-analyst 的分析能力。注意:直接修改程式碼與安全性分析不在此技能範圍內。
License
Apache-2.0
Instructions
171 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Refactoring Catalog — 程式碼重構目錄

architecture-reviewer 與 performance-analyst 在程式碼結構分析時使用的程式碼異味到重構對應、SOLID 違反識別與複雜度指標參考。

## 此技能的功能

- 提供程式碼異味(Code Smells)識別與對應重構技術
- 提供 SOLID 原則違反的識別標準與修正方向
- 提供 Cyclomatic / Cognitive 複雜度量測標準
- 提供設計模式應用指南

## 適用時機

- 執行架構或效能程式碼審查
- 識別需要重構的程式碼結構
- 搭配 `dev-code-reviewer` 技能使用

## 觸發範例

- 「這個類別有哪些程式碼異味?」
- 「這段程式碼違反了哪些 SOLID 原則?」
- 「計算這個函式的 Cyclomatic Complexity」
- 「建議適合的設計模式」

---

## 程式碼異味到重構對應

### 大小相關異味

| 程式碼異味 | 症狀 | 重構技術 |
|-----------|------|---------|
| **Long Method** | 20+ 行 | Extract Method、Replace Temp with Query |
| **Large Class** | 300+ 行或 10+ 欄位 | Extract Class、Extract Subclass |
| **Long Parameter List** | 4+ 個參數 | Introduce Parameter Object、Builder Pattern |
| **Data Clumps** | 相同欄位群組重複出現 | Extract Class |
| **Primitive Obsession** | 用基本型別表達領域概念 | Value Object、Enum |

### 結構相關異味

| 程式碼異味 | 症狀 | 重構技術 |
|-----------|------|---------|
| **Feature Envy** | 過度使用另一個類別的資料 | Move Method |
| **Data Class** | 只有 getter/setter 的類別 | 將行為移入類別 |
| **Shotgun Surgery** | 一個變更影響多個類別 | Move Method/Field、Inline Class |
| **Divergent Change** | 一個類別因多種原因變更 | Extract Class(SRP) |
| **Duplicated Code** | 相同或相似程式碼重複 | Extract Method、Template Method |
| **Middle Man** | 只做委派的類別 | Remove Middle Man、Inline Class |
| **Inappropriate Intimacy** | 類別間過度耦合 | Move Method/Field、Extract Class |
| **Switch/If Chain** | 長條件分支 | Replace Conditional with Polymorphism、Strategy |
| **Refused Bequest** | 繼承但未使用的方法 | Replace Inheritance with Delegation |
| **Comments** | 複雜邏輯需要注釋解釋 | Extract Method(自我說明程式碼) |

---

## SOLID 原則違反識別

### S — 單一職責原則(SRP)

| 違反訊號 | 識別標準 | 重構方向 |
|---------|---------|---------|
| 類別名稱含 "And"、"Manager" | 暗示多重職責 | Extract Class |
| 2+ 個變更原因 | 「X 變更時這個類別要改,Y 變更時也要改」 | 依職責分離類別 |
| 高度多樣的 import | 同時 import DB、HTTP、UI、Logging | 層次分離 |

### O — 開放封閉原則(OCP)

| 違反訊號 | 識別標準 | 重構方向 |
|---------|---------|---------|
| 新增類型時修改 switch/if | 需要修改現有程式碼 | Strategy Pattern、Polymorphism |
| 硬編碼分支 | 每個新條件都加程式碼 | Plugin/Registry Pattern |

### L — Liskov 替換原則(LSP)

| 違反訊號 | 識別標準 | 重構方向 |
|---------|---------|---------|
| 子類別 override 拋出例外 | `NotImplementedError`、`UnsupportedOperationException` | Interface Segregation、繼承改組合 |
| 型別檢查後轉型 | `instanceof` / `typeof` 分支 | 用多型重新設計 |

### I — 介面隔離原則(ISP)

| 違反訊號 | 識別標準 | 重構方向 |
|---------|---------|---------|
| 空的介面實作 | `pass`、`{}`、`noop` | 介面隔離 |
| 「胖」介面 | 10+ 個方法 | 拆分為 Role Interfaces |

### D — 依賴反轉原則(DIP)

| 違反訊號 | 識別標準 | 重構方向 |
|---------|---------|---------|
| 直接實例化具體類別 | 硬編碼 `new ConcreteService()` | Dependency Injection |
| 上層模組 import 下層模組 | 業務邏輯直接使用 DB 函式庫 | Interface/Port 抽象 |

---

## 複雜度量測標準

### Cyclomatic Complexity

分支點(if/else/switch/for/while/catch)+ 1

| 分數 | 複雜度 | 行動 |
|------|--------|------|
| 1-5 | 低 | 適當 |
| 6-10 | 中 | 謹慎審查 |
| 11-20 | 高 | 建議重構 |
| 21+ | 極高 | 必須重構 |

### Cognitive Complexity

人類理解程式碼的難度,巢狀越深權重越高。

| 元素 | 基礎增量 | 巢狀加成 |
|------|---------|---------|
| if/else/switch | +1 | +巢狀層級 |
| for/while/do | +1 | +巢狀層級 |
| catch | +1 | +巢狀層級 |
| break/continue to label | +1 | — |
| 邏輯運算子鏈(&&、\|\|) | +1 | — |

From vincent119/ai-rules-kit, Apache-2.0.

More from vincent119/ai-rules-kit

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Sep 8, 2026 (1 month ago)

From GitHub (fetched Oct 24, 2026).

Details

License
Apache-2.0
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from vincent119

Cite this page

dev-refactoring-catalog skill. Agent Mart. https://agentmart.dev/skills/vincent119-dev-refactoring-catalog (last updated 2026-10-24)