Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

design-patterns

БесплатноБез исполняемых скриптовНе проверен

Use when designing software architecture, refactoring code structure, solving recurring design problems, or when code exhibits symptoms like tight coupling…

ratacatот ratacat★ 60 звёзд на GitHub12 установок в других каталогах

Об этом скилле

Design Patterns

Overview

Design patterns are proven solutions to recurring software design problems. They provide a shared vocabulary for discussing design and capture collective wisdom refined through decades of real-world use.

Core Philosophy: Patterns are templates you adapt to your context, not blueprints to copy. Use the right pattern when it genuinely simplifies your design—not to impress or over-engineer.

Foundational Principles

These principles underpin all good design:

Principle Meaning Violation Symptom
Encapsulate What Varies Isolate changing parts from stable parts Changes ripple through codebase
Program to Interfaces Depend on abstractions, not concretions Can't swap implementations
Composition Over Inheritance Build behavior by composing objects Deep rigid class hierarchies
Loose Coupling Minimize interdependency between objects Can't change one thing without breaking another
Open-Closed Open for extension, closed for modification Must edit existing code for new features
Single Responsibility One reason to change per class Classes doing too many things
Dependency Inversion High-level modules don't depend on low-level Business logic coupled to infrastructure

Pattern Selection Guide

By Problem Type

CREATING OBJECTS
├── Complex/conditional creation ──────────→ Factory Method
├── Families of related objects ───────────→ Abstract Factory
├── Step-by-step construction ─────────────→ Builder
├── Clone existing objects ────────────────→ Prototype
└── Single instance needed ────────────────→ Singleton (use sparingly!)

STRUCTURING/COMPOSING OBJECTS
├── Incompatible interface ────────────────→ Adapter
├── Simplify complex subsystem ────────────→ Facade
├── Tree/hierarchy structure ──────────────→ Composite
├── Add behavior dynamically ──────────────→ Decorator
└── Control access to object ──────────────→ Proxy

MANAGING COMMUNICATION/BEHAVIOR
├── One-to-many notification ──────────────→ Observer
├── Encapsulate requests as objects ───────→ Command
├── Behavior varies by internal state ─────→ State
├── Swap algorithms at runtime ────────────→ Strategy
├── Algorithm skeleton with hooks ─────────→ Template Method
├── Reduce N-to-N communication ───────────→ Mediator
└── Sequential handlers ───────────────────→ Chain of Responsibility

MANAGING DATA ACCESS
├── Abstract data source ──────────────────→ Repository
├── Track changes for atomic commit ───────→ Unit of Work
├── Ensure object identity ────────────────→ Identity Map
├── Defer expensive loading ───────────────→ Lazy Load
├── Map objects to database ───────────────→ Data Mapper
└── Shape data for transfer ───────────────→ DTO

By Symptom

Symptom Consider
Giant switch/if-else on type Strategy, State, or polymorphism
Duplicate code across classes Template Method, Strategy
Need to notify many objects of changes Observer
Complex object creation logic Factory, Builder
Adding features bloats class Decorator
Third-party API doesn't fit your code Adapter
Too many dependencies between components Mediator, Facade
Can't test without database/network Repository, Dependency Injection
Need undo/redo Command
Object behavior depends on state State
Request needs processing by multiple handlers Chain of Responsibility

Domain Logic: Transaction Script vs Domain Model

Factor Transaction Script Domain Model
Logic complexity Simple (< 500 lines) Complex, many rules
Business rules Few, straightforward Many, interacting
Operations CRUD-heavy Rich behavior
Team/timeline Small team, quick delivery Long-term maintenance
Testing Integration tests Unit tests on domain

Rule of thumb: Start with Transaction Script. Refactor to Domain Model when procedural code becomes hard to maintain.

Quick Reference

Tier 1: Essential Patterns (Master First)

Pattern One-Line When to Use Reference
Strategy Encapsulate interchangeable algorithms Multiple ways to do something, swap at runtime strategy.md
Observer Notify dependents of state changes Event systems, reactive updates observer.md
Factory Encapsulate object creation Complex/conditional instantiation factory.md
Decorator Add behavior dynamically Extend without inheritance decorator.md
Command Encapsulate requests as objects Undo/redo, queuing, logging command.md

Tier 2: Structural Patterns

Pattern One-Line When to Use Reference
Adapter Convert in
Полный SKILL.md на GitHub

Установить design-patterns в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

patterns/adapter.mdpatterns/builder.mdpatterns/chain-of-responsibility.mdpatterns/command.mdpatterns/composite.mdpatterns/decorator.mdpatterns/dto.mdpatterns/facade.mdpatterns/factory.mdpatterns/identity-map.mdpatterns/lazy-load.mdpatterns/mediator.mdpatterns/observer.mdpatterns/proxy.mdpatterns/repository.mdpatterns/service-layer.mdpatterns/state.mdpatterns/strategy.mdpatterns/template-method.mdpatterns/unit-of-work.md

FAQ

Что делает скилл design-patterns?

Use when designing software architecture, refactoring code structure, solving recurring design problems, or when code exhibits symptoms like tight coupling, rigid hierarchies, scattered responsibilities, or difficult-to-test components. Also use when choosing between architectural approaches or reviewing code for structural improvements.

Как установить скилл design-patterns?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл design-patterns запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить design-patterns с