skills/gof-design-patterns/SKILL.md
Provides all 23 Gang of Four patterns as a decision guide: maps code symptoms to patterns, then loads the structural recipe for the selected pattern.
npx skillsauth add ryanthedev/code-foundations gof-design-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
23 Gang of Four patterns as a decision guide. Identify the symptom or goal, pick the pattern, then read its reference file for the structural recipe.
| Code Smell | Pattern(s) |
|---|---|
| if/else or switch on object type | Strategy, Visitor |
| if/else or switch on object state | State |
| Telescoping constructors | Builder |
| Subclass explosion for feature combinations | Decorator, Strategy, Bridge |
| new ConcreteClass() scattered throughout codebase | Factory Method, Abstract Factory |
| Hard-coded class names | Factory Method, Prototype |
| Subsystem complexity leaking into client code | Facade |
| Complex many-to-many object communication | Mediator |
| Manual state propagation to multiple dependents | Observer |
| Duplicated algorithm structure across subclasses | Template Method |
| Large conditional routing requests to handlers | Chain of Responsibility |
| High memory cost from many fine-grained objects | Flyweight |
| What you want | Pattern | |---|---| | Hide how objects are created | Factory Method, Abstract Factory, Builder, Prototype | | Ensure exactly one instance globally | Singleton | | Make incompatible interfaces work together | Adapter | | Decouple abstraction from implementation | Bridge | | Treat individual objects and groups uniformly | Composite | | Add behavior dynamically without subclassing | Decorator | | Simplify a complex subsystem API | Facade | | Lazy-load, cache, or control access to an object | Proxy | | Make requests undoable, queueable, or loggable | Command (+ Memento for undo state) | | Traverse a collection without exposing internals | Iterator | | Encapsulate an interchangeable algorithm | Strategy | | Change behavior when internal state changes | State | | Notify dependents automatically on state change | Observer | | Add operations to a stable object structure | Visitor |
| Choosing between | Key distinction | |---|---| | Strategy vs Template Method | Composition (delegate whole algorithm) vs inheritance (override steps) | | State vs Strategy | State transitions itself; Strategy is chosen by the client | | Adapter vs Facade | Adapting a single class vs simplifying an entire subsystem | | Decorator vs Proxy | Adding behavior vs controlling access | | Factory Method vs Abstract Factory | Single product type vs product families | | Command vs Chain of Responsibility | Encapsulate and invoke an action vs route a request to a handler |
Creational (5) — control what gets created and how
Abstract Factory · Builder · Factory Method · Prototype · Singleton
Structural (7) — compose classes and objects into larger structures
Adapter · Bridge · Composite · Decorator · Facade · Flyweight · Proxy
Behavioral (11) — define communication and responsibility between objects
Chain of Responsibility · Command · Interpreter · Iterator · Mediator · Memento · Observer · State · Strategy · Template Method · Visitor
Every pattern adds indirection. Apply one only when:
"If a straightforward solution works, use it." — GoF
Each pattern has a full file in ${CLAUDE_SKILL_DIR}/references/:
foundations.md — GoF principles (program to interface, favor composition, encapsulate what varies)techniques.md — master table, pattern relationships, alternative-pattern decision guidegof-<pattern-name>.md — structure, participants, when to use, consequences, exampleRead the relevant pattern file when implementing. This SKILL.md is for selection; the reference files are for execution.
devops
Implements the Standard/Full planning pipeline for Medium and Complex tasks: multi-step discovery, phase decomposition with skill matching, cross-cutting concerns, and plan emission with Gate fields.
development
Applies Code Complete's scientific debugging method: STABILIZE → LOCATE → HYPOTHESIZE → EXPERIMENT → FIX → TEST → SEARCH. For active bug investigation, not QA process design or test coverage planning.
development
Generates or updates docs/code-standards.md by scanning the codebase for actual conventions. Produces an example-rich standards file optimized for LLM consumers, grounded in the project's real patterns.
development
Safely modifies untested legacy code by getting it under test first: characterization tests, seam identification, sprout/wrap techniques, and pinch-point testing before any production changes.