Logo Expert Code Quality

Expert Code Quality

Cộng đồng
wonderslife
expert-code-quality

Code quality expert integrating Martin Fowler's refactoring techniques and GoF design patterns to help developers systematically improve code quality. Triggers when users ask about code review, refactoring, design patterns, code smells, SOLID principles, or software architecture improvements. 支持中文触发:代码审查、重构、设计模式、代码异味、SOLID原则、软件架构改进、代码质量。

Tổng quan

Nhà phát hànhwonderslife
Kho mãpdd-skills
Tên kỹ năngexpert-code-quality
Sao
41
Bản fork
11
Tệp đi kèm
5
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 5 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được wonderslife công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Expert Code Quality trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/wonderslife/pdd-skills/tree/main/expert-code-quality
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wonderslife/pdd-skills.git /tmp/pdd-skills
mkdir -p .claude/skills
cp -r /tmp/pdd-skills/expert-code-quality .claude/skills/expert-code-quality
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Expert Code Quality trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Expert Code Quality ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Expert Code Quality không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Code Quality Expert

Overview

This skill integrates two foundational software engineering disciplines:

  1. Refactoring - Improving code structure without changing behavior
  2. Design Patterns - Proven solutions to common design problems

Combined, they form a powerful toolkit for writing clean, maintainable, and extensible code.

Directory Structure

expert-code-quality/
├── SKILL.md              # Skill definition file
├── LICENSE               # MIT License
└── references/           # Reference documents
    ├── refactoring-catalog.md    # Complete catalog of refactoring techniques
    ├── design-patterns.md         # 23 GoF patterns
    ├── code-smells.md             # Detailed description of code smells
    └── solid-principles.md        # In-depth analysis of SOLID principles

Trigger Conditions

Automatic Triggers:

  • User asks about code quality issues
  • Need to identify code smells
  • Request for design pattern recommendations
  • Performing code refactoring
  • Evaluating SOLID principle compliance

Manual Triggers:

  • User enters commands like /code-quality, /refactor, /pattern, etc.

Core Capabilities

1. Code Smell Detection

1.1 Quick Reference: 22 Code Smells

Method-Level Smells:

SmellDetection PatternSeverity
Long MethodMethod > 20 linesHigh
Duplicated CodeSimilar code blocksCritical
Long Parameter ListParameters > 4Medium
Switch StatementsLarge switch/case blocksMedium

Class-Level Smells:

SmellDetection PatternSeverity
Large ClassClass > 300 lines or > 10 fieldsHigh
Divergent ChangeOne class changes for multiple reasonsHigh
Shotgun SurgeryOne change requires modifying many classesHigh
Feature EnvyMethod uses data from other classes moreMedium

Relationship-Level Smells:

SmellDetection PatternSeverity
Inappropriate IntimacyClasses access each other's private partsMedium
Message Chainsa.b().c().d() chainsMedium
Middle ManClass only does delegationLow
Data ClumpsSame data items always appear togetherMedium
1.2 Smell Detection Checklist

When reviewing code, check:

  • Are there methods longer than 20 lines?
  • Is there duplicated code?
  • Are there classes with more than 10 fields?
  • Are there switch statements that could use polymorphism?
  • Are there methods with more than 4 parameters?
  • Is there deep inheritance hierarchy (> 3 levels)?
  • Does the class change for multiple reasons?
  • Are there message chains with more than 3 calls?
  • Are there "data classes" with only data and no behavior?
  • Are there "lazy classes" that do almost nothing?

2. Refactoring Techniques

2.1 Refactoring Principles

Two Hats (Kent Beck):

HatActivityRule
Adding FeaturesAdd new functionalityDon't modify existing code
RefactoringImprove structureDon't add new features

Never wear both hats at the same time!

Refactoring Rhythm:

Test → Small Change → Test → Small Change → Test
2.2 Key Refactoring Techniques

Composing Methods:

RefactoringWhen to UseSteps
Extract MethodMethod too long, code block needs naming1.Create new method 2.Copy code 3.Replace original code with call
Inline MethodMethod body as clear as its name1.Replace calls with method body 2.Delete method
Replace Temp with QueryTemporary variable holds expression1.Extract expression to method 2.Replace temp with call
Replace Method with Method ObjectToo many temporaries in long method1.Create class for method 2.Temporaries become fields

Moving Features:

RefactoringWhen to UseSteps
Move MethodMethod uses other class more1.Copy to target 2.Delegate in source 3.Delete source method
Extract ClassClass does too much1.Create new class 2.Move fields/methods 3.Link classes
Hide DelegateClient knows delegation chain1.Add delegate method 2.Hide chain

Simplifying Conditionals:

RefactoringWhen to UseSteps
Decompose ConditionalComplex conditional logic1.Extract condition 2.Extract then/else
Consolidate ConditionalMultiple checks with same result1.Combine with && or || 2.Extract method
Replace Nested Conditional with Guard ClausesDeeply nested if-else1.Add guard clause returns 2.Flatten structure
Replace Conditional with PolymorphismSwitch by type1.Create subclasses 2.Move behavior to each subclass
2.3 Refactoring Decision Tree
Found code smell?
    │
    ├─ Do you have tests?
    │   ├─ No → Write tests first
    │   └─ Yes → Continue
    │
    ├─ Do you understand the code?
    │   ├─ No → Refactor to understand
    │   └─ Yes → Continue
    │
    └─ Choose refactoring approach:
        │
        ├─ Method too long → Extract Method
        ├─ Duplicated code → Extract Method / Pull Up
        ├─ Class too large → Extract Class
        ├─ Parameter list too long → Introduce Parameter Object
        ├─ Switch statement → Replace with Polymorphism
        └─ Complex conditionals → Decompose / Guard Clauses

3. Design Patterns

3.1 SOLID Principles Foundation

Before applying patterns, ensure understanding of SOLID principles:

PrincipleNameDescription
SSingle ResponsibilityOne reason to change
OOpen/ClosedOpen for extension, closed for modification
LLiskov SubstitutionSubtypes must be substitutable
IInterface SegregationSmall, focused interfaces
DDependency InversionDepend on abstractions
3.2 Selection by Problem Type
ProblemPatternKey Benefit
Need single instanceSingletonControlled access
Flexible object creationFactory MethodDecouple creation
Create families of objectsAbstract FactoryConsistent products
Build complex objectsBuilderStep-by-step construction
Incompatible interfacesAdapterMake incompatible work
Dynamically add responsibilitiesDecoratorFlexible extension
Control accessProxyIndirection layer
Simplify complex systemFacadeSimple interface
Tree structureCompositeUniform handling
Switch algorithmsStrategyInterchangeable behaviors
Event notificationObserverLoose coupling
Encapsulate requestsCommandUndo/redo support
State-dependent behaviorStateClear state transitions
3.3 Selection by Code Smell
SmellPattern Solution
Large switch statementState, Strategy
Multiple conditionalsStrategy, State, Null Object
Tight couplingObserver, Mediator, Facade
Difficult object creationFactory, Builder
Hard to extend classDecorator, Adapter
Complex subsystemFacade
Need varying algorithmsStrategy, Template Method
3.4 Pattern Quick Reference

Creational Patterns:

PatternWhen to Use
SingletonNeed single instance
Factory MethodDon't know exact class to create
Abstract FactoryNeed families of related objects
BuilderComplex object with many options
PrototypeClone existing objects

Structural Patterns:

PatternWhen to Use
AdapterIncompatible interfaces
DecoratorDynamically add responsibilities
ProxyControl access, lazy loading
FacadeSimplify complex interfaces
CompositeTree structure, uniform handling
FlyweightMany similar objects, share state
BridgeSeparate abstraction from implementation

Behavioral Patterns:

PatternWhen to Use
StrategyInterchangeable algorithms
ObserverOne-to-many notifications
CommandEncapsulate requests, undo/redo
StateState-dependent behavior
Template MethodAlgorithm skeleton, varying steps
IteratorUniform collection traversal
MediatorComplex object interactions
MementoSave/restore state
Chain of Resp.Request has multiple handlers
VisitorAdd operations to object structure

4. Integrated Workflow

4.1 Code Quality Improvement Process
1. IDENTIFY
   └── Detect code smells
       └── Use smell checklist
           └── Rate severity (Critical/High/Medium/Low)

2. DIAGNOSE
   └── Understand root cause
       └── Why does this smell exist?
           └── What problems will it cause?

3. PLAN
   └── Choose refactoring or pattern
       └── Consider dependencies
           └── Estimate impact

4. PREPARE
   └── Ensure tests exist
       └── Run tests to verify behavior
           └── Create tests if missing

5. EXECUTE
   └── Apply small changes
       └── Test after each change
           └── Keep code working

6. VERIFY
   └── Run all tests
       └── Check for new smells
           └── Confirm improvement
4.2 Smell→Refactoring→Pattern Flow
Detected code smell
        │
        ▼
┌───────────────────┐
│ Is this a method  │
│ level problem?    │
└────────┬──────────┘
         │
    ┌────┴────┐
    │ Yes     │ No
    ▼         ▼
Extract    Is this a class
Method     level problem?
              │
         ┌────┴────┐
         │ Yes     │ No
         ▼         ▼
    Extract    Is this a
    Class      relationship
              problem?
                  │
             ┌────┴────┐
             │ Yes     │ No
             ▼         ▼
        Move/Hide   Consider
        Delegate    Pattern
                        │
                        ▼
                  ┌──────────────┐
                  │ Which        │
                  │ pattern fits │
                  │ best?        │
                  └──────┬───────┘
                         │
         ┌───────────────┼───────────────┐
         ▼               ▼               ▼
    Creational      Structural      Behavioral
    Patterns        Patterns        Patterns

5. Collaboration Table

5.1 Collaboration with Other Skills
Collaborating SkillCollaboration ModeDescription
test-driven-developmentSequentialWrite tests before refactoring
systematic-debuggingConsultationFind root cause before fixing
requesting-code-reviewReferenceGet feedback on refactored code
pdd-code-reviewerReferenceGet PDD project code review
software-engineerDelegationQuality check after code implementation
5.2 Collaboration Workflow
Code quality issue detected
    ↓
Invoke expert-code-quality
    ↓
Identify code smells + Recommend refactoring/patterns
    ↓
(If tests needed first) → Invoke test-driven-development
    ↓
(If code implementation needed) → Invoke software-engineer
    ↓
Complete code quality improvement

6. Quick Decision Matrix

ScenarioPrimary Action
Found duplicated codeExtract Method
Method too longExtract Method
Class too largeExtract Class
Parameter list too longIntroduce Parameter Object
Switch by typeReplace with Polymorphism
Need single instanceConsider Singleton
Need flexible creationFactory Method or Builder
Incompatible interfacesAdapter
Need to add behaviorDecorator
Complex subsystemFacade
Need varying algorithmsStrategy
Need event notificationObserver

7. Anti-Patterns

7.1 Refactoring Anti-Patterns
Anti-PatternDescriptionCorrect Approach
Big Bang RefactoringRewrite everything at onceSmall incremental changes
Refactoring Without TestsChange code without safety netWrite tests first
Over-RefactoringRefactor clean codeStop when code is clear
Refactoring AddictionOnly refactor, never deliverBalance refactoring with features
Random RefactoringNo clear goalIdentify smells first
7.2 Pattern Anti-Patterns
Anti-PatternDescriptionCorrect Approach
Pattern ObsessionUse patterns everywhereUse patterns to solve problems
Singleton AbuseEverything is singletonUse only when truly needed
Factory OverkillFactory for single productUse factory for multiple products
Decorator NestingToo many decorator layersLimit nesting depth
Premature PatternUse pattern before neededLet patterns emerge from refactoring

8. Practice Checklists

8.1 Code Review Checklist

Before approving code, verify:

  • No critical code smells
  • Reasonable method size (< 20 lines)
  • Class has single responsibility
  • No duplicated code
  • Clear conditionals
  • Meaningful names
  • Tests exist and pass
  • Follows SOLID principles
  • Patterns used appropriately (not overused)
8.2 Refactoring Safety Checklist

Before refactoring:

  • All tests pass
  • Tests cover code to refactor
  • Understand code functionality
  • Have rollback plan
  • Make small changes
  • Test after each change
8.3 Pattern Application Checklist

Before applying pattern:

  • Problem matches pattern intent
  • Pattern solves real problem (not imagined)
  • Team understands pattern
  • Pattern doesn't overcomplicate
  • Alternatives considered
  • Pattern fits project context

Guardrails

  • Must provide suggestions based on Martin Fowler's refactoring catalog and GoF design patterns
  • Refactoring suggestions need specific code transformation examples
  • Pattern application needs to weigh pros and cons, not blindly recommend
  • Code review needs to specifically point out problems and improvement suggestions
  • Clearly state uncertain issues to avoid misleading

Version History

v2.0 (2026-03-21)

  • Unified to Chinese description
  • Added collaboration table, clarified collaboration with other skills
  • Enhanced quick decision matrix
  • Optimized refactoring decision tree
  • Added anti-pattern checklist

v1.0 (Initial version)

  • Basic code quality detection
  • Refactoring technique catalog
  • Design pattern reference

Remember: Good code isn't about being clever—it's about being clear. Refactoring and patterns are tools to achieve clarity, not ends in themselves.

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Expert Code Quality làm được gì?

Code quality expert integrating Martin Fowler's refactoring techniques and GoF design patterns to help developers systematically improve code quality. Triggers when users ask about code review, refactoring, design patterns, code smells, SOLID principles, or software architecture improvements. 支持中文触发:代码审查、重构、设计模式、代码异味、SOLID原则、软件架构改进、代码质量。

Vì sao nên dùng Expert Code Quality trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Expert Code Quality là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Expert Code Quality trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/wonderslife/pdd-skills/tree/main/expert-code-quality. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Expert Code Quality?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Expert Code Quality với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Expert Code Quality với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Expert Code Quality có miễn phí không?

Có. Kỹ năng này được wonderslife phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇