$npx -y skills add krzysztofsurdy/code-virtuoso --skill design-patternsComprehensive skill for all 26 Gang of Four design patterns with practical implementations and real-world examples. Use when the user asks to apply a design pattern, refactor code using patterns, choose between competing patterns, or review existing pattern usage. Covers creation
| 1 | # Design Patterns |
| 2 | |
| 3 | A thorough reference covering 26 design patterns organized by intent — creational, structural, and behavioral — featuring PHP 8.3+ implementations, UML guidance, and practical use cases. |
| 4 | |
| 5 | ## Pattern Index |
| 6 | |
| 7 | ### Creational Patterns |
| 8 | - **Abstract Factory** — Produce families of related objects without specifying their concrete classes → [reference](references/abstract-factory.md) |
| 9 | - **Builder** — Assemble complex objects through a step-by-step process → [reference](references/builder.md) |
| 10 | - **Factory Method** — Declare an interface for object creation, letting subclasses determine the concrete type → [reference](references/factory-method.md) |
| 11 | - **Prototype** — Duplicate existing objects without coupling to their concrete classes → [reference](references/prototype.md) |
| 12 | - **Singleton** — Guarantee that a class has exactly one instance → [reference](references/singleton.md) |
| 13 | - **Object Pool** — Recycle expensive-to-create objects for repeated use → [reference](references/object-pool.md) |
| 14 | |
| 15 | ### Structural Patterns |
| 16 | - **Adapter** — Translate one interface into another that clients expect → [reference](references/adapter.md) |
| 17 | - **Bridge** — Separate an abstraction from its implementation so both can evolve independently → [reference](references/bridge.md) |
| 18 | - **Composite** — Arrange objects into tree structures for uniform treatment → [reference](references/composite.md) |
| 19 | - **Decorator** — Layer new behaviors onto objects dynamically through wrapping → [reference](references/decorator.md) |
| 20 | - **Facade** — Offer a streamlined interface to a complex subsystem → [reference](references/facade.md) |
| 21 | - **Flyweight** — Minimize memory usage by sharing common state across many objects → [reference](references/flyweight.md) |
| 22 | - **Proxy** — Manage access to an object through a surrogate → [reference](references/proxy.md) |
| 23 | - **Private Class Data** — Limit access to class attributes → [reference](references/private-class-data.md) |
| 24 | |
| 25 | ### Behavioral Patterns |
| 26 | - **Chain of Responsibility** — Route requests through a chain of handlers → [reference](references/chain-of-responsibility.md) |
| 27 | - **Command** — Represent requests as standalone objects → [reference](references/command.md) |
| 28 | - **Interpreter** — Establish a grammar representation and an interpreter for it → [reference](references/interpreter.md) |
| 29 | - **Iterator** — Walk through elements without revealing the underlying structure → [reference](references/iterator.md) |
| 30 | - **Mediator** — Tame chaotic dependencies through a central coordinator → [reference](references/mediator.md) |
| 31 | - **Memento** — Snapshot and restore object state without breaking encapsulation → [reference](references/memento.md) |
| 32 | - **Null Object** — Supply a do-nothing default to eliminate null checks → [reference](references/null-object.md) |
| 33 | - **Observer** — Automatically inform dependents when state changes → [reference](references/observer.md) |
| 34 | - **State** — Change behavior when internal state transitions → [reference](references/state.md) |
| 35 | - **Strategy** — Make algorithms interchangeable at runtime → [reference](references/strategy.md) |
| 36 | - **Template Method** — Outline an algorithm skeleton and let subclasses fill in specific steps → [reference](references/template-method.md) |
| 37 | - **Visitor** — Introduce operations to objects without altering their classes → [reference](references/visitor.md) |
| 38 | |
| 39 | ## When to Use Which Pattern |
| 40 | |
| 41 | | Problem | Pattern | |
| 42 | |---------|---------| |
| 43 | | Need to create families of related objects | Abstract Factory | |
| 44 | | Complex object construction with many options | Builder | |
| 45 | | Want to defer instantiation to subclasses | Factory Method | |
| 46 | | Need copies of complex objects | Prototype | |
| 47 | | Need exactly one instance globally | Singleton | |
| 48 | | Incompatible interfaces need to work together | Adapter | |
| 49 | | Want to vary abstraction and implementation independently | Bridge | |
| 50 | | Tree structures with uniform treatment | Composite | |
| 51 | | Add responsibilities dynamically without subclassing | Decorator | |
| 52 | | Simplify a complex subsystem interface | Facade | |
| 53 | | Many similar objects consuming too much memory | Flyweight | |
| 54 | | Control access, add lazy loading, or log access | Proxy | |
| 55 | | Multiple handlers for a request, unknown which handles it | Chain of Responsibility | |
| 56 | | |