mcpField
G
gof-patterns

gof-patterns

github.com/grndlvlDevelopment1764 installsUpdated 38w ago
Repository

About gof-patterns

gof-patterns is a language-agnostic reference skill for Gang of Four design patterns, aimed at developers choosing, learning, or implementing patterns. It combines categorized tables, selection guidance, and pseudocode that can be adapted to different programming languages.

Key features

  1. 01Covers creational, structural, and behavioral patterns
  2. 02Provides pattern selection guidance
  3. 03Explains when each pattern applies
  4. 04Includes pseudocode adaptable across languages

Use cases

  1. 01Choose a pattern for a design problem
  2. 02Evaluate structural changes during refactoring
  3. 03Adapt pattern examples to a project's language

MCP support

The input does not describe a relationship to MCP.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/grndlvl/software-patterns --skill gof-patterns

After installing, type/gof-patternsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

pattern-selection.md
gof-behavioral/
chain-of-responsibility.md
command.md
interpreter.md
iterator.md
mediator.md
memento.md
observer.md
state.md
strategy.md
template-method.md
visitor.md
gof-creational/
abstract-factory.md
builder.md
factory-method.md
prototype.md
singleton.md
gof-structural/
adapter.md
bridge.md
composite.md
decorator.md
facade.md
flyweight.md
proxy.md

Details

From the project README

GoF Design Patterns Reference

A comprehensive reference for the Gang of Four design patterns. This skill provides language-agnostic guidance with pseudocode examples that can be translated to any programming language.

When This Skill Activates

This skill automatically activates when you:

  • Ask about or need to implement a design pattern
  • Need to choose between patterns for a design problem
  • Are refactoring code and considering structural improvements
  • Discuss architecture, decoupling, or extensibility
  • Mention specific patterns: factory, singleton, observer, decorator, etc.

Quick Pattern Reference

Creational Patterns (Object Creation)
PatternIntentUse When
Abstract FactoryCreate families of related objectsNeed platform/theme independence
BuilderConstruct complex objects step-by-stepObject has many optional parts
Factory MethodLet subclasses decide which class to instantiateDon't know concrete types ahead of time
PrototypeClone existing objectsObject creation is expensive
SingletonEnsure single instanceNeed exactly one shared instance
Structural Patterns (Composition)
PatternIntentUse When
AdapterConvert interface to expected interfaceIntegrating incompatible interfaces
BridgeSeparate abstraction from implementationNeed to vary both independently
CompositeTreat individual and groups uniformlyHave tree structures
DecoratorAdd responsibilities dynamicallyNeed flexible extension
FacadeSimplified interface to subsystemComplex subsystem needs simple API
FlyweightShare common state efficientlyMany similar objects needed
ProxyControl access to objectNeed lazy loading, access control, logging
Behavioral Patterns (Communication)
PatternIntentUse When
Chain of ResponsibilityPass request along handler chainMultiple handlers, unknown which handles
CommandEncapsulate request as objectNeed undo, queue, or log operations
InterpreterDefine grammar and interpret sentencesHave a simple language to parse
IteratorSequential access without exposing internalsNeed to traverse collections
MediatorCentralize complex communicationsMany objects communicate in complex ways
MementoCapture and restore object stateNeed undo/snapshot functionality
ObserverNotify dependents of state changesOne-to-many dependency
StateAlter behavior when state changesObject behavior depends on state
StrategyEncapsulate interchangeable algorithmsNeed to swap algorithms at runtime
Template MethodDefine skeleton, let subclasses fill inAlgorithm structure fixed, steps vary
VisitorAdd operations without changing classesNeed to add many operations to stable structure

Decision Guide

See Pattern Selection Guide for help choosing the right pattern.

How to Use This Reference

  1. Choosing a pattern: Start with the decision guide or tables above
  2. Learning a pattern: Read the full documentation with examples
  3. Quick reminder: Use the tables above for at-a-glance reference
  4. Implementation: Follow the pseudocode, adapt to your language

Language Translation Notes

The pseudocode in this reference uses these conventions:

  • class for type definitions
  • function for methods/functions
  • -> for method calls on objects
  • // for comments
  • Type hints shown as name: Type

Translate to your language:

  • PHP: class, function, ->, //, type hints in docblocks or PHP 8+
  • JavaScript/TypeScript: class, function/arrow, ., //, TS types
  • Python: class, def, ., #, type hints
  • Java/C#: Direct mapping with new, generics

Based on concepts from "Design Patterns: Elements of Reusable Object-Oriented Software" by Gamma, Helm, Johnson, and Vlissides (Gang of Four), 1994.

Comments

Markdown supported