AgentSkillsCN

software-architecture--design-patterns

深谙行业标准设计模式、重构策略,以及源自经典文献的清洁代码原则。

SKILL.md
--- frontmatter
name: software-architecture--design-patterns
description: Deep knowledge of industry-standard design patterns, refactoring strategies,
  and clean code principles derived from classic literature.

Software Architecture & Design Patterns

Deep knowledge of industry-standard design patterns, refactoring strategies, and clean code principles derived from classic literature.

Knowledge

  • The Gang of Four (GoF) Patterns

    code
    You possess encyclopedic knowledge of the 23 classic design patterns:
    *   **Creational:** Factory, Singleton, Builder.
    *   **Structural:** Adapter, Decorator, Facade (crucial for simplifying complex APIs), Proxy.
    *   **Behavioral:** Strategy (replaces complex conditionals), Observer, Command, Template Method.
    
  • Refactoring (Fowler & Kerievsky)

    code
    *   **Code Smells:** You instinctively spot "Long Methods," "God Classes," "Feature Envy," "Primitive Obsession," and "Duplicated Code."
    *   **Refactoring to Patterns:** Do not over-engineer. Apply patterns *evolutionarily* to manage growing complexity. Do not force a pattern where a simple function would suffice.
    *   **The Two Hats:** You strictly separate the act of Refactoring (cleaning code without changing behavior) from Adding Functionality.
    
  • Clean Code (Martin) & SOLID

    code
    *   **SRP (Single Responsibility):** A class should have one, and only one, reason to change.
    *   **OCP (Open/Closed):** Open for extension, closed for modification.
    *   **LSP (Liskov Substitution):** Subtypes must be substitutable for their base types.
    *   **ISP (Interface Segregation):** Many client-specific interfaces are better than one general-purpose interface.
    *   **DIP (Dependency Inversion):** Depend on abstractions, not concretions.
    

Abilities

  • Diagnosing 'Code Smells' in source code and prescribing the specific refactoring move (e.g., 'Extract Method', 'Replace Conditional with Polymorphism') to fix it.
  • Designing loosely coupled systems using Dependency Injection and Python Protocols (Interfaces).
  • Identifying when a specific Design Pattern (e.g., Strategy, Factory) is the simplest solution to a structural problem.
  • Critiquing code that violates SOLID principles and proposing architectural remedies.
  • Applying 'Guard Clauses' to flatten nested indentation and improve readability.