Skip to content
Back to skills

Design Patterns

ASecurity

Use when picking or implementing a named pattern: Strategy, Observer, Adapter, Decorator, Factory, Repository, Unit of Work, Dependency injection, Retry with backoff, Circuit Breaker, Idempotency key, Outbox, Result type. Not for whether to abstract at all (use engineering-principles), SOLID refactors (use solid-principles), aggregates (use domain-driven-design), CQRS, event sourcing, sagas, event-driven design, service boundaries or service-to-service communication (use code-architectures).

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 13, 2026
developmenttypescriptpythongoapidatabase

Works with

  • api

Security analysis

A100/100

Pro scans all 20 files and shows the line behind each finding

Scanned November 13, 2026

npx -y skills add joeblackwaslike/agent-skills --skill design-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Design Patterns?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Design Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/joeblackwaslike-design-patterns/badge)](https://www.skillsdirectory.com/skills/joeblackwaslike-design-patterns)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: design-patterns
description: >-
  Use when picking or implementing a named pattern: Strategy, Observer, Adapter, Decorator, Factory, Repository, Unit of Work, Dependency injection, Retry with backoff, Circuit Breaker, Idempotency key, Outbox, Result type. Not for whether to abstract at all (use engineering-principles), SOLID refactors (use solid-principles), aggregates (use domain-driven-design), CQRS, event sourcing, sagas, event-driven design, service boundaries or service-to-service communication (use code-architectures).
metadata:
  last_updated: "2026-11-11"
---

# Design Patterns

A catalog of the patterns that show up in production code, with one reference per pattern in Python and TypeScript. Most are a function, a closure or a `Protocol` in these languages, not a class hierarchy.

Python examples assume 3.12 or later.

## Default to no pattern

Start with a plain function, a dict of functions, or an `if`. A second CSV export format is a function argument. Reach for a pattern when the plain version has already hurt: the third `elif` on a provider name, a notification call copied into four callers, a module that cannot be tested without the database.

If the request names a variant-selection pattern (Strategy, Factory, State, Command, Chain of Responsibility), count the real variants or callers, including any this change adds. With fewer than three, write the plain version and say so in one line. Resilience and data-access patterns (Retry, Circuit Breaker, Idempotency key, Outbox, Unit of Work) are triggered by a failure mode, not a count: one call site that can double-charge or lose an event already needs them. Observer is triggered by a coupling boundary, not a count: subscribers the publisher should not import.

Every reference has an early "Do you need this?" section that names the plain alternative and the signal that tips you over. If you cannot point at that signal, skip the pattern.

## What to load

Open only the file the task needs. [catalog.md](references/catalog.md) lists every pattern with a one-line summary and how common it is.

| You are... | Read |
|---|---|
| Choosing a pattern, or refreshing what one is | [catalog.md](references/catalog.md) |
| Choosing an implementation once, by name or config, at construction (payment provider, exporter) | [factory.md](references/creational/factory.md) |
| Constructing an object with many optional parts | [builder.md](references/creational/builder.md) |
| Passing collaborators in instead of creating them inside, so tests can swap them | [dependency-injection.md](references/creational/dependency-injection.md) |
| Tempted by a global instance | [singleton.md](references/creational/singleton.md) |
| Making a third-party API or legacy module fit your interface, or putting one simple front (Facade) on a messy subsystem | [adapter.md](references/structural/adapter.md) |
| Wrapping one call with logging, caching, auth or timing without editing it | [decorator.md](references/structural/decorator.md) |
| Standing in for an object with the same interface to control access: lazy load, remote stand-in, permission gate | [proxy.md](references/structural/proxy.md) |
| Choosing an algorithm per call at runtime (pricing, routing, sorting) | [strategy.md](references/behavioral/strategy.md) |
| Notifying other modules when something happens | [observer.md](references/behavioral/observer.md) |
| Queuing, undoing or replaying an action as data | [command.md](references/behavioral/command.md) |
| Sending one request through an ordered list of handlers, each able to stop it (middleware, validation) | [chain-of-responsibility.md](references/behavioral/chain-of-responsibility.md) |
| Behavior that depends on a lifecycle status (order or payment states) | [state.md](references/behavioral/state.md) |
| Fixed skeleton with steps that vary | [template-method.md](references/behavioral/template-method.md) |
| Walking a collection lazily or in pages | [iterator.md](references/behavioral/iterator.md) |
| Hiding persistence behind a domain-shaped interface (a repository inside an aggregate belongs to `domain-driven-design`) | [repository.md](references/data-access/repository.md) |
| Several writes that must commit or roll back together | [unit-of-work.md](references/data-access/unit-of-work.md) |
| Separating wire or database shapes from domain objects | [dto-mapper.md](references/data-access/dto-mapper.md) |
| Calling something flaky | [retry-backoff.md](references/resilience/retry-backoff.md) |
| Stopping calls to a dependency that is down | [circuit-breaker.md](references/resilience/circuit-breaker.md) |
| Making a retried request safe to repeat | [idempotency-key.md](references/resilience/idempotency-key.md) |
| Writing to the database and publishing an event atomically | [outbox.md](references/resilience/outbox.md) |
| Returning errors or absence without exceptions or null checks, or substituting a do-nothing default object (Null Object) | [result-option.md](references/value-modeling/result-option.md) |

Facade is described inside the adapter file and Null Object inside the result-option file. Abstract Factory, Prototype, Bridge, Composite, Flyweight, Memento, Mediator, Visitor and Interpreter are catalog-only; the catalog says what to use instead.

## Related skills

- `engineering-principles`: whether to abstract at all, and how much. Read it first if you are unsure a pattern is warranted.
- `solid-principles`: the SRP/OCP/LSP/ISP/DIP treatment that most patterns apply, plus the anti-patterns for needless indirection.
- `domain-driven-design`: aggregates and repositories inside aggregates.
- `code-architectures`: layering, CQRS, event sourcing and service boundaries. Architecture-level material lives there, not here.

Files in this skill

  • SKILL.md5.6 KB
  • references/behavioral/chain-of-responsibility.md6 KB
  • references/behavioral/command.md4.9 KB
  • references/behavioral/iterator.md5.2 KB
  • references/behavioral/observer.md6.3 KB
  • references/behavioral/state.md5.6 KB
  • references/behavioral/strategy.md5.6 KB
  • references/behavioral/template-method.md5.2 KB
  • references/catalog.md5.3 KB
  • references/creational/builder.md7.2 KB
  • references/creational/dependency-injection.md6.5 KB
  • references/creational/factory.md5.4 KB
  • references/creational/singleton.md6.5 KB
  • references/data-access/dto-mapper.md6.6 KB
  • references/data-access/repository.md7 KB
  • references/data-access/unit-of-work.md7.2 KB
  • references/resilience/circuit-breaker.md10.1 KB
  • references/resilience/idempotency-key.md11 KB
  • references/resilience/outbox.md13.4 KB
  • references/resilience/retry-backoff.md13.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.