Use when architecting solutions, identifying recurring problems, or improving code structure with proven patterns.
---
name: design-patterns
description: Use when architecting solutions, identifying recurring problems, or improving code structure with proven patterns.
version: 1.0.0
author: Kintama
license: MIT
metadata:
hermes:
tags: [design-patterns, GoF, architecture, OOP, structure]
related_skills: [solid-principles, refactoring-techniques, clean-code-principles]
---
# Design Patterns
## Creational Patterns
- **Singleton** — one instance globally (use sparingly, hard to test)
- **Factory Method** — delegate instantiation to subclasses
- **Abstract Factory** — families of related objects
- **Builder** — step-by-step complex object construction
- **Prototype** — clone existing objects
## Structural Patterns
- **Adapter** — incompatible interfaces compatibility
- **Decorator** — add behavior without modifying class
- **Facade** — simplified interface to complex subsystem
- **Proxy** — control access to another object
- **Composite** — tree structures, treat individual/group uniformly
## Behavioral Patterns
- **Observer** — event subscription/notification
- **Strategy** — swap algorithms at runtime
- **Command** — encapsulate actions as objects
- **Chain of Responsibility** — pass request through handler chain
- **Template Method** — define skeleton, let subclasses fill in
- **State** — change behavior when internal state changes
- **Iterator** — traverse collection without exposing internals
## Modern Patterns
- **Repository** — abstract data layer from business logic
- **Unit of Work** — batch DB operations into a transaction
- **CQRS** — separate read and write models
- **Saga** — distributed transaction management
- **Circuit Breaker** — prevent cascading failures
## Anti-Patterns to Avoid
- God Object — class that knows too much
- Spaghetti Code — no clear structure
- Golden Hammer — using one pattern for everything
- Premature Optimization — optimizing before profiling
don't have the plugin yet? install it then click "run inline in claude" again.