design-patterns/SKILL.md
Enforces correct application of software design patterns including all 23 Gang of Four patterns and modern additions. Use when selecting a creational, structural, or behavioral pattern, evaluating whether a pattern is appropriate, refactoring toward patterns, reviewing code for pattern-itis or over-engineering, or deciding between pattern-based and language-native solutions.
npx skillsauth add kayaman/skills 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.
Reference: Design Patterns (GoF), Head First Design Patterns (Freeman & Robson), Refactoring to Patterns (Kerievsky)
Every pattern decision MUST be guided by these two principles:
Select based on what varies in object creation:
| Pattern | Intent | Use When | Avoid When | |---------|--------|----------|------------| | Abstract Factory | Create families of related objects without specifying concrete classes | Multiple product families must be interchangeable (e.g., UI themes, platform adapters) | Only one product family exists | | Builder | Separate construction of complex objects from representation | Object has many optional parameters or multi-step construction | Constructor with 1–3 required params suffices | | Factory Method | Let subclasses decide which class to instantiate | The exact type depends on runtime context or configuration | A simple constructor call is clear enough | | Prototype | Create objects by cloning an existing instance | Creating from scratch is expensive or involves complex setup | Object graphs are simple and cheap to construct | | Singleton | Ensure one instance with global access | Almost never — prefer DI container-managed lifecycle | Testing, concurrency, or coupling matter (most cases) |
Select based on how objects and classes are composed:
| Pattern | Intent | Use When | Avoid When | |---------|--------|----------|------------| | Adapter | Convert an incompatible interface into one clients expect | Integrating third-party code or legacy systems | You control both interfaces and can change one | | Bridge | Decouple abstraction from implementation so both vary independently | Two orthogonal dimensions of variation (e.g., shape × renderer) | Only one dimension varies | | Composite | Treat individual objects and compositions uniformly as a tree | Recursive part-whole hierarchies (file systems, UI components, org charts) | The structure is flat, not tree-shaped | | Decorator | Attach behavior dynamically without subclassing | Adding optional, combinable responsibilities at runtime | Behavior is always required — just put it in the class | | Facade | Simplified interface to a complex subsystem | Clients need a streamlined entry point; subsystem internals should be hidden | The subsystem is already simple | | Flyweight | Share fine-grained objects to save memory | Thousands of similar objects with shared intrinsic state | Object count is small; optimization is premature | | Proxy | Surrogate controlling access (lazy loading, caching, protection, remote) | Access control, expensive initialization, or cross-network access | Direct access has no cost or risk |
Select based on how objects communicate and assign responsibility:
| Pattern | Intent | Use When | Avoid When |
|---------|--------|----------|------------|
| Chain of Responsibility | Pass request along a chain until handled | Middleware pipelines, event processing, validation chains | A single handler always processes the request |
| Command | Encapsulate a request as an object | Undo/redo, queuing, logging, transaction replay | The action is simple and needs no history |
| Interpreter | Define grammar and interpret sentences | Small, domain-specific languages (query filters, rules engines) | The grammar is complex — use a parser generator |
| Iterator | Sequential access without exposing internals | Built into virtually all modern languages — rarely implement manually | Language-native iteration exists |
| Mediator | Centralize complex inter-object communication | Many objects with complex, many-to-many interactions | Objects have simple, direct relationships |
| Memento | Capture and restore state without breaking encapsulation | Undo, snapshots, time-travel debugging | State is trivial to reconstruct |
| Observer | Notify dependents when state changes | Event-driven systems, reactive UI, pub-sub | Use framework-native reactive patterns (RxJS, signals, hooks) |
| State | Alter behavior when internal state changes | Object behaves differently in distinct states with defined transitions | A simple if/else on one flag suffices |
| Strategy | Interchangeable algorithm family | Multiple algorithms for the same task, selected at runtime | In FP languages, just pass a lambda/function |
| Template Method | Algorithm skeleton with overridable steps | Fixed workflow with varying steps across subclasses | Composition with Strategy achieves the same without inheritance |
| Visitor | Add operations to elements without modifying their classes | New operations are frequent; element types are stable | Element hierarchy changes often — every Visitor breaks |
| Pattern | Intent | Context |
|---------|--------|---------|
| Dependency Injection | Supply dependencies externally rather than creating them internally | Enables testing, decoupling, and DIP compliance |
| Null Object | Provide a no-op implementation instead of null checks | Eliminates if (x != null) scattered through code |
| Repository | Collection-like interface for aggregate persistence | DDD — one repository per aggregate root |
| Unit of Work | Coordinate writes across repositories in a single transaction | Ensuring consistency across multiple aggregates |
| Specification | Composable, reusable business rule objects | Complex query/validation logic that must be combined |
Pattern-itis — applying patterns speculatively — is worse than the problems patterns solve.
Norvig's observation: 16 of 23 GoF patterns are simplified or eliminated by dynamic language features. Before applying a pattern, ask: "Does my language already solve this?"
Before applying or recommending a pattern, verify:
| Book | Author(s) | Publisher | Year | |------|-----------|-----------|------| | Design Patterns: Elements of Reusable OO Software | Gamma, Helm, Johnson, Vlissides | Addison-Wesley | 1994 | | Head First Design Patterns (2nd ed.) | Freeman & Robson | O'Reilly | 2021 | | Patterns of Enterprise Application Architecture | Martin Fowler | Addison-Wesley | 2002 | | Refactoring to Patterns | Joshua Kerievsky | Addison-Wesley | 2004 | | Dive Into Design Patterns | Alexander Shvets | Refactoring.Guru | 2021 | | Game Programming Patterns | Robert Nystrom | Genever Benning | 2014 | | Fundamentals of Software Architecture | Mark Richards, Neal Ford | O'Reilly | 2020 | | Software Architecture: The Hard Parts | Ford, Richards, Sadalage, Dehghani | O'Reilly | 2021 |
tools
Guidance for designing charts, graphs, plots, dashboards, and data visualizations that communicate clearly and persuade. Use when creating or reviewing a visualization, choosing a chart type, picking a color palette, decluttering a busy graphic, fixing misleading axes or proportions, building a dashboard, annotating a figure, or turning data into a presentation, report, or data-driven story. Grounded in the standard data-visualization literature (Knaflic, Tufte, Cleveland & McGill, Cairo, Wilke, Munzner, Few, Berinato). Covers chart selection, graphical perception and encoding, color and accessibility, decluttering, graphical integrity, dashboards, and narrative. Does NOT cover building data pipelines or ETL, statistical modeling or analysis methods, BI tool/vendor selection, or general UI/UX layout (see ux-design-principles). Tool-agnostic, with optional Python recipes.
development
Architect and implement production-grade microservices systems in TypeScript (NestJS) and Python (FastAPI), including resilience, observability, testing, deployment, and migration guidance.
development
--- name: databricks-genie-spaces-best-practices description: Design, configure, curate, govern, monitor, and integrate Databricks AI/BI Genie Spaces — the natural-language-to-SQL surface over Unity Catalog. Covers space scoping, general instructions, parameterized example SQL, SQL functions, trusted assets, JOIN configuration, knowledge store, certified queries, benchmarks, monitoring tab, feedback loops, the Genie Conversation API, governance via Unity Catalog (row filters, column masks, embed
tools
Implement OTP and passwordless authentication on AWS for TypeScript projects using Cognito CUSTOM_AUTH triggers (default) or a custom DynamoDB-backed flow, with SES (email) and SNS (SMS) delivery. Use when the user mentions OTP, one-time password, passwordless login, magic link, Cognito custom auth, DefineAuthChallenge, CreateAuthChallenge, VerifyAuthChallengeResponse, SES verification email, SNS SMS code, or MFA over email/SMS. Covers architecture decision (Cognito vs custom), Lambda trigger handlers, SES/SNS notifiers, DynamoDB schema with TTL, rate limiting, constant-time comparison, threat model (enumeration, replay, brute force), and aws-sdk-client-mock testing.