Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

implementation-design-patterns

БесплатноБез исполняемых скриптовНе проверен

Implementation guide for the 22 Gang of Four design patterns in TypeScript, distilled from refactoring.guru. Use this skill when writing, refactoring, or…

pproencaот pproenca★ 231 звезда на GitHub

Об этом скилле

TypeScript Design Patterns Best Practices (Refactoring Guru)

Implementation reference for the 22 Gang of Four design patterns in TypeScript, distilled from refactoring.guru. Each of the 22 pattern files across 3 categories captures intent, problem, solution, applicability, a runnable TypeScript example, implementation steps, pros/cons, and relations to sibling patterns.

The patterns are a vocabulary for structural decisions, not a prescription. Reach for a pattern only when its applicability criteria match the problem at hand — every pattern entry includes a When NOT to Use section to guard against over-engineering.

When to Apply

  • Refactoring a class that has grown unwieldy via inheritance — combinatorial subclasses, conditional branching on type, or a "god class" with many responsibilities
  • Designing a new module whose collaborators are not yet fixed — you want to keep the interface stable while implementations vary
  • Integrating an incompatible third-party API, library, or legacy class into existing code
  • Modeling a tree-shaped domain (file systems, organization charts, expression ASTs, UI component trees) where leaves and branches must be treated uniformly
  • Adding cross-cutting behavior at runtime — logging, caching, access control, decoration — without subclassing
  • Selecting an algorithm or behavior variant at runtime based on configuration, user input, or environmental conditions
  • Implementing undo/redo, history snapshots, transactional rollback, or scheduling/queueing of operations
  • Coordinating many objects whose direct mutual references have become tangled — a hub that brokers communication
  • Notifying many subscribers when something changes — event systems, reactive data flows
  • Reviewing code that smells like a pattern is implicit (large switch on kind, parallel class hierarchies, identical algorithm skeletons across siblings) — make it explicit

Rule Categories

# Category Impact Patterns When to reach for this group
1 Creational HIGH 5 Object construction is non-trivial, varies by configuration, or risks tight coupling to concrete classes
2 Structural HIGH 7 Composing classes/objects into larger structures while keeping parts substitutable
3 Behavioral HIGH 10 Distributing responsibility and defining how objects collaborate at runtime

How to Use

  1. Recognize the shape. Read the Quick Reference below and identify which pattern's intent matches your problem. Most pattern-shaped problems sound like one of the listed phrases.
  2. Read the pattern reference. Open references/{category}-{pattern}.md. Confirm intent, then read Applicability and When NOT to Use before adopting.
  3. Adapt the example. The TypeScript example uses pedagogical names (ConcreteStrategyA, Receiver). Rename to domain terms before merging.
  4. Check the relations. Each entry ends with Related Patterns — siblings worth considering for the same problem.

Quick Reference

1. Creational Patterns (object instantiation)

  • creational-factory-method — Subclasses decide which concrete product to create. "I need to add new product types without touching the creator code." — HIGH
  • creational-abstract-factory — Produce families of related objects together. "My code must work with multiple matching variants (chair+sofa+table) and shouldn't mix families." — MEDIUM-HIGH
  • creational-builder — Construct complex objects step by step. "My constructor has 10+ parameters or I have a telescoping-constructor smell." — HIGH
  • creational-prototype — Clone objects through their own clone() method. "I need to copy objects without depending on their concrete class." — MEDIUM
  • creational-singleton — Guarantee a single shared instance with a global access point. "I need exactly one instance of this class — config, registry, pool." — MEDIUM

2. Structural Patterns (composition)

  • structural-adapter — Translate one interface to another. "I need to use a library whose API doesn't match what my code expects." — HIGH
  • structural-bridge — Split abstraction from implementation so they can vary independently. "I have two orthogonal dimensions and the subclass count is exploding." — MEDIUM
  • structural-composite — Treat individual objects and compositions uniformly. "I have a tree (folders/files, groups/items, components/children) and want one interface for leaves and branches." — HIGH
  • structural-decorator — Wrap an object to add behavior without
Полный SKILL.md на GitHub

Установить implementation-design-patterns в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

AGENTS.mdgotchas.mdmetadata.jsonreferences/_sections.mdreferences/behavioral-chain-of-responsibility.mdreferences/behavioral-command.mdreferences/behavioral-iterator.mdreferences/behavioral-mediator.mdreferences/behavioral-memento.mdreferences/behavioral-observer.mdreferences/behavioral-state.mdreferences/behavioral-strategy.mdreferences/behavioral-template-method.mdreferences/behavioral-visitor.mdreferences/creational-abstract-factory.mdreferences/creational-builder.mdreferences/creational-factory-method.mdreferences/creational-prototype.mdreferences/creational-singleton.mdreferences/structural-adapter.mdreferences/structural-bridge.mdreferences/structural-composite.mdreferences/structural-decorator.mdreferences/structural-facade.mdreferences/structural-flyweight.mdreferences/structural-proxy.md

FAQ

Что делает скилл implementation-design-patterns?

Implementation guide for the 22 Gang of Four design patterns in TypeScript, distilled from refactoring.guru. Use this skill when writing, refactoring, or reviewing TypeScript that exhibits a pattern-shaped problem — class-explosion from inheritance, conditionals switching on type, tight coupling to concrete classes, tree-shaped models, runtime algorithm selection, undo/redo, snapshot-and-restore, state-dependent behavior, subscriber notification, or hiding subsystem complexity. Each pattern entry includes intent, problem, solution, applicability (when to use AND when NOT to use), a runnable TypeScript example, implementation steps, pros/cons, and relations to sibling patterns. Trigger even when no pattern is named — cues like "class getting unwieldy," "giant switch," "swap implementations at runtime," "combinatorial subclasses," "need undo," or "traverse a tree" are pattern-shaped. Covers all 5 Creational, 7 Structural, and 10 Behavioral GoF patterns.

Как установить скилл implementation-design-patterns?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл implementation-design-patterns запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить implementation-design-patterns с