/design-patterns:pattern-selectionfrom design-patterns
INVOKE THIS FIRST before choosing, introducing, or reviewing any design pattern. Use when you are about to add a pattern, refactor toward one, or assess whether existing code uses the right one. Maps the friction you feel to the pattern that removes it — start from the pain, not from a pattern name.
Ships in design-patterns. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Source: Gang of Four — Design Patterns (1994); Martin Fowler — PoEAA (2002); Evans — DDD (2003)
Name the pain before naming the pattern. A pattern applied without a clear pain statement is speculation. Patterns fail not because they are wrong in theory, but because they were applied to a problem that did not exist yet, or the wrong problem.
Ask first: What is the friction I am trying to remove?
Signals:
| Further question | Pattern |
|---|---|
| Truly need exactly one shared instance? | Singleton — but only if stateless or safe to share |
| Construction is complex or easy to misuse? | Builder |
| Subclass/context decides the concrete type? | Factory Method |
| Need a family of related objects that must match? | Abstract Factory |
| Cloning a configured instance is cheaper than rebuilding? | Prototype |
→ Invoke the creational skill.
Signals:
| Further question | Pattern |
|---|---|
| Bridging two incompatible interfaces? | Adapter |
| Subsystem too complex or easy to misuse? | Facade |
| Need optional features without subclass explosion? | Decorator |
| Need lazy loading, auth, caching, or remoting behind an interface? | Proxy |
| Domain forms a hierarchy; leaves and containers need uniform treatment? | Composite |
| Many objects share identical intrinsic data at memory cost? | Flyweight |
| Two independent dimensions of variation causing subclass matrix? | Bridge |
→ Invoke the structural skill.
Signals:
if/switch branches that grow with each new case| Further question | Pattern |
|---|---|
| Request passes through independent steps, any of which may stop it? | Chain of Responsibility |
| Actions need to be queued, logged, retried, or undone? | Command |
| Same operation, multiple interchangeable algorithms? | Strategy |
| Behaviour is entirely driven by internal state and transitions? | State |
| One-to-many notification without tight coupling? | Observer |
| Need to save and restore object state without exposing internals? | Memento |
| Objects coordinate through a central point to avoid direct coupling? | Mediator |
| New operations over a stable object structure, without modifying it? | Visitor |
| Uniform traversal over a collection, hiding its internal structure? | Iterator |
| Algorithm has a fixed skeleton, steps vary by subclass? | Template Method |
→ Invoke the behavioural skill.
Signals:
→ Invoke the domain-modeling skill.
Signals:
→ Invoke the data-access skill.
Signals:
→ Invoke the service-layer skill.
Signals:
→ Invoke the anti-corruption skill.
Signals:
→ Invoke the domain-events or cqrs skill.
| These feel similar... | Distinction |
|---|---|
| Strategy vs State | Strategy: caller swaps algorithm. State: object transitions itself based on internal rules. |
| Decorator vs Proxy | Decorator adds domain behaviour. Proxy controls access or adds infrastructure concerns. |
| Facade vs Adapter | Facade simplifies. Adapter translates between incompatible interfaces. |
| Observer vs Domain Events | Observer is in-process, synchronous. Domain Events can cross boundaries, be async. |
| Factory Method vs Abstract Factory | Factory Method: one product type, subclass decides. Abstract Factory: a family of related products. |
| Command vs Strategy | Command represents an action as an object (queue, undo). Strategy represents an interchangeable algorithm. |
| Chain of Responsibility vs Decorator | Chain: each handler decides to stop or pass. Decorator: each wrapper always delegates, just adds behaviour. |
Before applying any pattern, confirm:
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub entelligentsia/skillforge --plugin design-patterns10 skills in this plugin
/anti-corruptionUse when external system types, vocabulary, or conventions bleed into your domain model, a single provider change would require touching many internal files, or a legacy system must keep running while a new one is built alongside it. Apply before writing any integration with an external API, legacy codebase, or third-party service. Covers Anti-Corruption Layer, Gateway, Facade, and Strangler Fig./behaviouralUse when behaviour varies across cases, accumulates conditionals, or needs to be decoupled, queued, undone, or observed. Apply when a method is growing if/switch branches, an algorithm differs per context, a pipeline needs flexible steps, or objects need to react to each other without tight coupling. Covers all 10 GoF behavioural patterns./cqrsUse when read and write performance requirements diverge significantly, complex reporting is painful through the domain model, or you need to scale reads and writes independently. Apply before splitting any command/query handler or building read-optimised projections. Covers Command Query Responsibility Segregation — including when it is overkill — with guidance on applying only as much separation as the problem demands./creationalUse when object creation is the source of pain — constructors growing too complex, the same setup repeated, unclear which concrete type to instantiate, or a shared instance causing hidden coupling. Apply before writing any factory, builder, or instantiation logic. Covers all 5 GoF creational patterns: Singleton, Builder, Factory Method, Abstract Factory, Prototype./data-accessUse when persistence logic bleeds into domain or business code, tests require a real database to verify business logic, ORM types appear in service or handler code, or switching storage would require touching domain classes. Apply before writing any database query, repository, or ORM integration. Covers Repository, Unit of Work, Data Mapper, and Active Record with explicit guidance on when each applies./domain-eventsUse when aggregates need to stay loosely coupled, side effects (emails, audit logs, projections) are tangled into domain operations, or one aggregate directly calls methods on another. Apply when something significant happens in the domain that other parts of the system need to react to without being tightly coupled. Covers Domain Events, publishing patterns, synchronous vs asynchronous handling, idempotency, and eventual consistency trade-offs.Other plugins' skills for the same job