Agent Skill
2/7/2026

design-patterns

Gang of Four (GoF) design patterns reference covering all 23 classic patterns. Use when implementing, refactoring, or discussing software design patterns. Triggers on phrases like "use X pattern", "implement factory", "refactor to strategy", "which pattern for...", "design pattern help", or when code structure suggests a pattern would help (complex conditionals suggesting State/Strategy, object creation issues suggesting Factory/Builder, many similar objects suggesting Flyweight).

T
twiced
0GitHub Stars
1Views
npx skills add twiced-technology-gmbh/seedr

SKILL.md

Namedesign-patterns
DescriptionGang of Four (GoF) design patterns reference covering all 23 classic patterns. Use when implementing, refactoring, or discussing software design patterns. Triggers on phrases like "use X pattern", "implement factory", "refactor to strategy", "which pattern for...", "design pattern help", or when code structure suggests a pattern would help (complex conditionals suggesting State/Strategy, object creation issues suggesting Factory/Builder, many similar objects suggesting Flyweight).

name: design-patterns description: > Gang of Four (GoF) design patterns reference covering all 23 classic patterns. Use when implementing, refactoring, or discussing software design patterns. Triggers on phrases like "use X pattern", "implement factory", "refactor to strategy", "which pattern for...", "design pattern help", or when code structure suggests a pattern would help (complex conditionals suggesting State/Strategy, object creation issues suggesting Factory/Builder, many similar objects suggesting Flyweight).

Design Patterns

Quick reference for the 23 Gang of Four design patterns organized by category.

Pattern Selection Guide

ProblemConsider
Complex object creationFactory Method, Abstract Factory, Builder
Clone existing objectsPrototype
Single shared instanceSingleton
Incompatible interfacesAdapter
Separate abstraction from implementationBridge
Tree structuresComposite
Add behavior dynamicallyDecorator
Simplify complex subsystemsFacade
Many similar objects (memory)Flyweight
Control access/lazy loadingProxy
Sequential handlersChain of Responsibility
Encapsulate requests as objectsCommand
Traverse collectionsIterator
Reduce coupling between componentsMediator
Save/restore state (undo)Memento
Event notificationObserver
Object behavior varies by stateState
Interchangeable algorithmsStrategy
Algorithm skeleton with variable stepsTemplate Method
Operations on object structuresVisitor

Pattern Categories

Creational Patterns

Object creation mechanisms. See references/creational.md.

PatternIntent
Factory MethodDefer instantiation to subclasses
Abstract FactoryCreate families of related objects
BuilderConstruct complex objects step-by-step
PrototypeClone existing objects
SingletonEnsure single instance with global access

Structural Patterns

Object composition and relationships. See references/structural.md.

PatternIntent
AdapterConvert interface to another expected interface
BridgeSeparate abstraction from implementation
CompositeTreat individual objects and compositions uniformly
DecoratorAdd responsibilities dynamically
FacadeSimplified interface to complex subsystem
FlyweightShare state to support many fine-grained objects
ProxyPlaceholder controlling access to another object

Behavioral Patterns

Object interaction and responsibility distribution. See references/behavioral.md.

PatternIntent
Chain of ResponsibilityPass request along handler chain
CommandEncapsulate request as object
IteratorSequential access without exposing representation
MediatorCentralize complex communications
MementoCapture and restore object state
ObserverNotify dependents of state changes
StateAlter behavior when state changes
StrategyInterchangeable algorithm family
Template MethodDefine algorithm skeleton, defer steps to subclasses
VisitorAdd operations without modifying classes

Quick Implementation Examples

Factory Method (TypeScript)

interface Product { operation(): string }

abstract class Creator {
  abstract createProduct(): Product
  doSomething(): string {
    const product = this.createProduct()
    return product.operation()
  }
}

class ConcreteCreator extends Creator {
  createProduct(): Product { return new ConcreteProduct() }
}

Strategy (TypeScript)

interface Strategy { execute(data: string[]): string[] }

class Context {
  constructor(private strategy: Strategy) {}
  setStrategy(strategy: Strategy) { this.strategy = strategy }
  doWork(data: string[]): string[] { return this.strategy.execute(data) }
}

// Usage: context.setStrategy(new SortAscending())

Observer (TypeScript)

interface Observer { update(state: any): void }

class Subject {
  private observers: Observer[] = []
  attach(o: Observer) { this.observers.push(o) }
  detach(o: Observer) { this.observers = this.observers.filter(x => x !== o) }
  notify(state: any) { this.observers.forEach(o => o.update(state)) }
}

Decorator (TypeScript)

interface Component { operation(): string }

class ConcreteComponent implements Component {
  operation() { return 'base' }
}

class Decorator implements Component {
  constructor(protected component: Component) {}
  operation() { return this.component.operation() }
}

class ConcreteDecorator extends Decorator {
  operation() { return `decorated(${super.operation()})` }
}

Resources

For detailed explanations, participants, and when-to-use guidance:

Skills Info
Original Name:design-patternsAuthor:twiced