agentleFS
cookieMonsterDevcookieMonsterDev/agents-skills/skills/architecture/design-patterns/SKILL.md

design-patterns

Skill7 starsChanged 15 days agoMITView on GitHub

Gang of Four (GoF) design patterns, with a reference and runnable examples per pattern. Use when a question names a pattern (singleton, factory, builder, observer, strategy, adapter...), describes a design problem a pattern might solve, compares patterns, or asks to review or refactor code using patterns.

33 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use logging-patterns, tdd-rust and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • DIL8654Skill

    logging-patterns

    Keep logs structured, correlated, low-noise, and safe for production support. Use when adding operational logging, reviewing observability, or improving diagnostics in .NET services.

    Also in 7 projects that use this

  • FlorianBruniauxSkill

    tdd-rust

    Also in 3 projects that use this

  • nek1987Skill

    solid-principles

    SOLID object-oriented design principles for maintainable code

    Also in 5 projects that use this

  • mstuder-slalomSkill

    jpa-patterns

    JPA/Hibernate patterns for entity design, relationships, query optimization, transactions, auditing, indexing, pagination, and pooling in Spring Boot.

    Also in 6 projects that use this

  • ufodev-ioSkill

    security-guardian

    Comprehensive security layer for all interactions with Claude: audits code, dependencies, commands, configs, and AI-generated output for vulnerabilities. Protects against prompt injection, data leaks, unsafe advice, and social engineering. Works in Cursor, Claude Code, claude.ai, and API contexts. Use always as a background security protocol in any Claude-powered environment.

    Also in 3 projects that use this

  • DIL8654Skill

    api-contract-review

    Review ASP.NET Core Web API contracts for HTTP semantics, versioning, backward compatibility, and response consistency. Use when the user asks to review an API, check endpoints, validate REST behavior, or before releasing contract changes.

    Also in 3 projects that use this

The file

Files
SKILL.md

Design Patterns

Ground every pattern answer in this skill's reference files, not in improvised definitions. A pattern is the answer to specific forces in a design problem: recommend one only when the user's problem shows the forces it resolves.

Workflow

For code reviews or refactoring, first read review and refactoring to trace callers, preserve contracts, and verify a concrete improvement.

  1. Identify the pattern(s) in the catalog below, by name or by the forces in the user's problem. Done when every pattern the question names or implies is listed, or when no pattern's forces are present; then answer with the plain function, data structure, or language feature that solves the problem.
  2. Read each identified reference at references/<pattern>.md in full. When comparing patterns, read every one compared and contrast their intent, not their structure.
  3. Read the language example at examples/<pattern>/<pattern>.<ext> for the user's language. For a language without an example, use the reference's Language Notes for the idiomatic form.
  4. Answer with what the pattern does, the forces that call for it, the simpler alternative and when it wins, and code adapted to the user's domain (their own code, when refactoring). Write the language's idiomatic form rather than a literal GoF class diagram: closures for Strategy in JavaScript, enums for State in Rust, sync.Once for Singleton in Go. Done when every identified pattern has all four parts.

Pattern Catalog

Creational

Patterns that abstract the instantiation process.

PatternIntentReference
Abstract FactoryCreate families of related objects without specifying concrete classesreferences/abstract-factory.md
BuilderConstruct complex objects step by step, separating construction from representationreferences/builder.md
Factory MethodLet subclasses decide which class to instantiatereferences/factory-method.md
PrototypeCreate objects by cloning an existing instancereferences/prototype.md
SingletonEnsure a class has one instance with a global access pointreferences/singleton.md

Structural

Patterns that compose classes and objects into larger structures.

PatternIntentReference
AdapterConvert one interface into another that clients expectreferences/adapter.md
BridgeDecouple an abstraction from its implementation so both can varyreferences/bridge.md
CompositeTreat individual objects and compositions uniformly in tree structuresreferences/composite.md
DecoratorAttach responsibilities to objects dynamically without subclassingreferences/decorator.md
FacadeProvide a simple unified interface to a complex subsystemreferences/facade.md
FlyweightShare fine-grained objects to support large numbers efficientlyreferences/flyweight.md
ProxyProvide a surrogate that controls access to another objectreferences/proxy.md

Behavioral

Patterns that assign responsibilities and manage communication between objects.

PatternIntentReference
Chain of ResponsibilityPass a request along a chain of handlers until one handles itreferences/chain-of-responsibility.md
CommandEncapsulate a request as an object, enabling queues and undoreferences/command.md
InterpreterDefine a grammar and an interpreter for a small languagereferences/interpreter.md
IteratorAccess elements of a collection sequentially without exposing its internalsreferences/iterator.md
MediatorCentralize complex communication between objects in one mediatorreferences/mediator.md
MementoCapture and restore an object's internal state without breaking encapsulationreferences/memento.md
ObserverNotify dependents automatically when an object's state changesreferences/observer.md
StateLet an object change its behavior when its internal state changesreferences/state.md
StrategyDefine interchangeable algorithms behind a common interfacereferences/strategy.md
Template MethodDefine an algorithm's skeleton, deferring some steps to subclassesreferences/template-method.md
VisitorAdd operations to an object structure without modifying its classesreferences/visitor.md

Examples

Examples are self-contained and runnable, in Python, C, C++, Java, C#, JavaScript, Rust, Go, PHP, and Swift. Each is written in its language's idiom: C emulates objects with structs and function pointers; Rust and Go use traits, interfaces, and composition in place of inheritance.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.