К основному содержанию
скилл CX Codex

implementation-design-patterns — скилл для Claude Code

Скилл implementation-design-patterns для Claude Code помогает определить паттерн Gang of Four по описанию задачи и понять, когда его применять или избегать.

MIT 151 установок ★ 227 обновлён 2026-08-15

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add pproenca/dot-skills --skill implementation-design-patterns -a claude-code
Открыть на GitHub

Что делает implementation-design-patterns

Скилл содержит полный набор Creational, Structural и Behavioral паттернов: 5 для создания объектов, 7 для их композиции, 10 для взаимодействия. Каждый паттерн описан с целью, проблемой, которую он решает, готовым кодом на TypeScript, шагами реализации и связями с похожими паттернами. Главное — раздел «Когда НЕ использовать» защищает от переусложнения.

Триггеры работают по фразам, а не только по названиям: «класс разросся через наследование», «гигантский switch по типам», «нужна undo/redo», «древовидная модель». Паттерны — это словарь конструкторских решений, не приказ. Применяй, когда критерии применимости из справочника совпадают с твоей задачей.

Примеры используют учебные имена (ConcreteStrategyA, Receiver), которые нужно переименовать в доменные термины перед интеграцией. На каждый паттерн ссылка на отдельный файл с полной справкой.

Какие задачи решает

  • Выбрать паттерн по описанию задачи без названия паттерна
  • Узнать, когда паттерн помогает, а когда вредит
  • Написать TypeScript код, следуя проверенной структуре
  • Разобраться, какие паттерны решают одну проблему по-разному
  • Рефакторить код с неявным паттерном, сделав его явным

Примеры запросов агенту

  • Мой класс User разросся на наследование от Role и Permission, комбинаций уже 15. Какой паттерн?
  • Нужно обернуть API какой-то библиотеки, чтобы она работала с моим интерфейсом. Что посоветуешь?
  • У меня в коде гигантский switch по kind, код дублирует логику. Как рефакторить?

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

1Через Skills CLI (Vercel)

npx skills add pproenca/dot-skills --skill implementation-design-patterns -a claude-code

2Вручную: положить файлы

~/.claude/skills/implementation-design-patterns/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/implementation-design-patterns/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы об implementation-design-patterns

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

Выполни npx skills add pproenca/dot-skills --skill implementation-design-patterns -a claude-code. Скилл появится в ~/.claude/skills/implementation-design-patterns/SKILL.md.

Что такое implementation-design-patterns?

Справочник по 22 паттернам Gang of Four с полным описанием, примерами TypeScript кода, критериями применимости и указаниями, когда паттерн ненужен. Каждый паттерн — отдельный файл в категории Creational, Structural или Behavioral.

Как узнать паттерн, если я не знаю его названия?

Скилл реагирует на фразы-триггеры вроде «класс разросся», «гигантский switch», «нужна undo», «древовидная структура». Назови суть проблемы — скилл предложит подходящие паттерны и объяснит, когда их применять.

Исходный текст

SKILL.md · MIT
---
name: implementation-design-patterns
description: 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.
---

# 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`](references/creational-factory-method.md) — Subclasses decide which concrete product to create. *"I need to add new product types without touching the creator code."* — **HIGH**
- [`creational-abstract-factory`](references/creational-abstract-factory.md) — 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`](references/creational-builder.md) — Construct complex objects step by step. *"My constructor has 10+ parameters or I have a telescoping-constructor smell."* — **HIGH**
- [`creational-prototype`](references/creational-prototype.md) — Clone objects through their own `clone()` method. *"I need to copy objects without depending on their concrete class."* — **MEDIUM**
- [`creational-singleton`](references/creational-singleton.md) — 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`](references/structural-adapter.md) — Translate one interface to another. *"I need to use a library whose API doesn't match what my code expects."* — **HIGH**
- [`structural-bridge`](references/structural-bridge.md) — Split abstraction from implementation so they can vary independently. *"I have two orthogonal dimensions and the subclass count is exploding."* — **MEDIUM**
- [`structural-composite`](references/structural-composite.md) — 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`](references/structural-decorator.md) — Wrap an object to add behavior without subclassing. *"I want to layer behaviors (logging + caching + auth) on the same interface at runtime."* — **HIGH**
- [`structural-facade`](references/structural-facade.md) — Expose a simple interface over a complex subsystem. *"My client code is tangled in initialization and orchestration of a third-party library."* — **HIGH**
- [`structural-flyweight`](references/structural-flyweight.md) — Share common state across many objects to save memory. *"I'm spawning millions of similar objects and running out of RAM."* — **LOW-MEDIUM**
- [`structural-proxy`](references/structural-proxy.md) — Substitute for another object to control access. *"I need lazy loading, access control, caching, or logging without touching the real subject."* — **MEDIUM-HIGH**

### 3. Behavioral Patterns (collaboration)

- [`behavioral-chain-of-responsibility`](references/behavioral-chain-of-responsibility.md) — Pass a request along a chain of handlers. *"I have a pipeline of validation / auth / parsing checks and want to add or reorder them dynamically."* — **MEDIUM-HIGH**
- [`behavioral-command`](references/behavioral-command.md) — Turn a request into a stand-alone object. *"I need undo/redo, queueing, scheduling, macro recording, or to decouple invoker from receiver."* — **HIGH**
- [`behavioral-iterator`](references/behavioral-iterator.md) — Traverse a collection without exposing its representation. *"I want clients to walk a structure without knowing if it's a list, tree, or graph."* — **HIGH**
- [`behavioral-mediator`](references/behavioral-mediator.md) — Centralize communication among components in a single hub. *"My form fields all reference each other directly and the coupling is unmanageable."* — **MEDIUM**
- [`behavioral-memento`](references/behavioral-memento.md) — Capture and restore an object's state without breaking encapsulation. *"I need snapshots for undo/redo or transactional rollback."* — **LOW-MEDIUM**
- [`behavioral-observer`](references/behavioral-observer.md) — Notify dependent objects when state changes. *"Many objects need to react when one object changes — events, reactive UI, pub/sub."* — **CRITICAL**
- [`behavioral-state`](references/behavioral-state.md) — Alter behavior when internal state changes. *"My class is a state machine with massive conditionals branching on a `status` field."* — **MEDIUM-HIGH**
- [`behavioral-strategy`](references/behavioral-strategy.md) — Make algorithms interchangeable at runtime. *"I have multiple algorithms (sort, route, pay, compress) and want to pick one without conditionals."* — **HIGH**
- [`behavioral-template-method`](references/behavioral-template-method.md) — Fix an algorithm's skeleton in a base class; subclasses override steps. *"Several classes share the same algorithm structure with minor step differences."* — **MEDIUM**
- [`behavioral-visitor`](references/behavioral-visitor.md) — Add operations to an object structure without modifying the classes. *"I'd need to add 5 unrelated operations across an AST but I can't touch the node classes."* — **LOW-MEDIUM**

## How to Choose Between Similar Patterns

Several patterns share a structural shape but solve different problems. Read each pattern's **Related Patterns** section, then apply these distinctions:

- **Adapter vs. Facade vs. Proxy vs. Decorator** — all four wrap a target. *Adapter* changes the interface. *Facade* simplifies a subsystem. *Proxy* keeps the interface and controls access/lifecycle. *Decorator* keeps the interface and adds behavior recursively.
- **Strategy vs. State** — both swap a delegated object. *Strategy* objects are independent; the client picks one. *State* objects know each other and trigger transitions on the context.
- **Strategy vs. Template Method** — both vary parts of an algorithm. *Strategy* uses composition (swap at runtime). *Template Method* uses inheritance (fixed at compile time).
- **Factory Method vs. Abstract Factory vs. Builder** — *Factory Method* returns one product through a single method. *Abstract Factory* returns a family of related products through several methods. *Builder* assembles one complex product step by step.
- **Composite vs. Decorator** — both wrap children recursively. *Composite* sums or aggregates child results. *Decorator* adds responsibilities and passes through.
- **Chain of Responsibility vs. Command vs. Mediator vs. Observer** — all connect senders and receivers. *CoR* passes a request along a chain. *Command* makes the request a first-class object. *Mediator* centralizes mutual communication. *Observer* establishes one-publisher-to-many-subscribers notification.

## Related Skills

- **[`implementation-functional-patterns`](../implementation-functional-patterns/SKILL.md)** — TypeScript's functional answer (HOFs, lambdas, pipelines, streams, composition) for problems where this catalog reaches for a class. Most Strategy / Iterator / Command / Chain-of-Responsibility / Decorator / Template-Method shapes have a lighter functional form in idiomatic TS; consult it before introducing a new class hierarchy.

## References

1. [Refactoring Guru — Design Patterns Catalog](https://refactoring.guru/design-patterns/catalog)
2. [Refactoring Guru — TypeScript Examples](https://refactoring.guru/design-patterns/typescript)
3. [Refactoring Guru — Creational Patterns](https://refactoring.guru/design-patterns/creational-patterns)
4. [Refactoring Guru — Structural Patterns](https://refactoring.guru/design-patterns/structural-patterns)
5. [Refactoring Guru — Behavioral Patterns](https://refactoring.guru/design-patterns/behavioral-patterns)

© pproenca · MIT · pproenca/dot-skills

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

Все скиллы по теме «Код-ревью и рефакторинг» →
design-patterns-implementation aj-geddes Скилл design-patterns-implementation для Claude Code и Codex подбирает и применяет паттерны проектирования к архитектурным задачам. Включается при рефакторинге, на код-ревью архитектуры и при построении расширяемых систем. CX Codex +1 601установок gof-design-patterns markpitt Скилл gof-design-patterns подбирает паттерн GoF под вашу задачу и выдаёт готовую реализацию на одном из восьми языков. CX Codex +1 145установок golang-design-patterns samber Скилл golang-design-patterns подсказывает идиоматичные Go-паттерны для API, жизненного цикла ресурсов, graceful shutdown и архитектуры. Пригодится при проектировании и ревью кода. CX Codex +1 44 600установок python-design-patterns Seth Hobson Скилл python-design-patterns помогает выбирать структуру Python-кода, разделять обязанности и решать, когда выносить повторяющуюся логику в абстракцию. Пригодится при проектировании и рефакторинге. CX Codex +1 22 842установок design-patterns rtk-ai Скилл design-patterns подбирает архитектурные паттерны Rust для CLI-модулей фильтрации RTK. Помогает структурировать парсеры вывода, конфигурации и работу с ресурсами. CX Codex +1 2 000установок oop-design-patterns официальный github Правило oop-design-patterns для GitHub Copilot задаёт ориентиры по ООП, GoF-паттернам и принципам SOLID при генерации и рефакторинге кода. Оно применяется к файлам Python, Java, TypeScript, JavaScript и C#. «Как установить» CX Codex +1 ★ 41 430звёзд репо

Из того же набора139

Весь набор →
codex-goals Скилл codex-goals для Codex помогает формулировать и проверять долгосрочные цели: задавать измеримый результат, способ проверки и условие остановки. Описывает постановку многошаговых задач с понятным финалом. CX Codex +1 158установок expo-design-system Скилл expo-design-system для Claude Code помогает строить и проверять общие компоненты Expo и React Native для веба и iOS. Подключается при работе с токенами, темами и повторно используемым интерфейсом. CX Codex +1 156установок complexity-optimizer Скилл complexity-optimizer находит узкие места алгоритмической сложности в коде и готовит отчёт с безопасными исправлениями. CX Codex +1 156установок nextjs-bundle-optimizer Скилл nextjs-bundle-optimizer для Claude Code измеряет размер бандла и время сборки Next.js и помогает проверять оптимизации по одной. Проверяет оптимизации при росте First Load JS или замедлении сборки. CX Codex +1 152установок better-auth Скилл по Better Auth для TypeScript: помогает поднять инстанс, выбрать адаптер, настроить сессии и перейти с другой auth-библиотеки. CX Codex +1 150установок diataxis Скилл diataxis раскладывает техническую документацию на четыре режима: туториал, инструкция, справочник, объяснение. Помогает решить, что писать на конкретной странице. CX Codex +1 149установок drizzle-sqlite-scaffold Скилл drizzle-sqlite-scaffold генерирует готовый boilerplate для Drizzle ORM + SQLite: конфиг, клиент с прагмами, схемы таблиц, CRUD-модули и валидаторы. Срабатывает на фразы вроде «добавь таблицу для X» или «настрой БД». CX Codex +1 149установок same-results-less-code Скилл same-results-less-code помогает находить лишнюю сложность при ревью и рефакторинге, сохраняя поведение кода. Он дополняет линтеры анализом структуры и моделей. CX Codex +1 148установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой