principle-design-patterns

Select software design patterns for structuring and refactoring code.

2|8|Updated Apr 20, 2026
One-click install
npx skills add https://github.com/lugassawan/swe-workbench --skill principle-design-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: principle-design-patterns
Source: https://github.com/lugassawan/swe-workbench/tree/main/skills/principle-design-patterns
Command: npx skills add https://github.com/lugassawan/swe-workbench --skill principle-design-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Design patterns solve the problem of structuring software so that changing requirements, varying algorithms, and cross-cutting concerns don’t force widespread rewrites.

Core Features & Use Cases

  • Pattern selection guidance: Decide when to apply or avoid common GoF patterns (Strategy, Factory Method, Observer, Decorator, Adapter, Facade, Template Method, Command, Repository, Dependency Injection).
  • Refactoring toward structure: Use criteria like coupling, composition needs, construction complexity, and change vectors to move code toward the most appropriate pattern.
  • Pragmatic anti-pattern awareness: Identify named pitfalls (Singleton, God object, Pattern-itis) that often signal architectural problems.

Quick Start

Ask an AI to recommend the best pattern by describing the change scenario, the current coupling/complexity, and the interfaces involved, then request a concrete refactoring plan using the skill’s pattern “problem/use when/overkill when” framework.

Frequently Asked Questions about principle-design-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose the right software design pattern for refactoring my code?

You can identify software design patterns to avoid by checking for common anti-patterns like Singleton, God object, and Pattern-itis. These architectural pitfalls often signal unnecessary complexity or tight coupling, indicating when a pattern is overkill for your current refactoring scenario.

When do I need dependency injection in object-oriented design?

You need dependency injection in object-oriented design when designing dependency wiring for testability and decoupling construction. Using composition-root DI allows you to inject runtime behaviors, avoiding hardcoded dependencies and making your functional requirements easier to test.

What is the best way to adapt legacy interfaces without rewriting widespread code?

The best way to adapt legacy or third-party interfaces without widespread rewrites is using the Adapter or Facade pattern. These structural patterns map incompatible interfaces to your target object model, isolating legacy integration and preventing cross-cutting concerns from forcing rewrites.

Can I use functions or middleware instead of traditional GoF design patterns?

Yes, you can use functions, middleware, events, or reactive streams as modern alternatives to traditional GoF design patterns. When evaluating pattern selection, checking for overkill scenarios often reveals that functional composition or reactive streams provide simpler runtime behavior selection.

How do I organize persistence behind collections in object-oriented design?

To organize persistence behind collections in object-oriented design, you should apply the Repository pattern. This design pattern centralizes data access logic, abstracting persistence operations behind a collection-like interface to cleanly separate infrastructure from your domain object interactions.