Design patterns implementation

From aj-geddes/useful-ai-prompts · View interactive version

Design patterns implementation is an AI agent skill from the GitHub repository aj-geddes/useful-ai-prompts. Apply appropriate design patterns (Singleton, Factory, Observer, Strategy, etc.) to solve architectural problems. Use when refactoring code architecture, implementing extensible systems, or following SOLID principles.

How to use this skill

Skill file

Design Patterns Implementation

Table of Contents

Overview

Apply proven design patterns to create maintainable, extensible, and testable code architectures.

When to Use

Quick Start

Minimal working example:

class DatabaseConnection {
  private static instance: DatabaseConnection;
  private connection: any;

  private constructor() {
    this.connection = this.createConnection();
  }

  public static getInstance(): DatabaseConnection {
    if (!DatabaseConnection.instance) {
      DatabaseConnection.instance = new DatabaseConnection();
    }
    return DatabaseConnection.instance;
  }

  private createConnection() {
    return {
      /* connection logic */
    };
  }
}

// Usage
const db1 = DatabaseConnection.getInstance();
const db2 = DatabaseConnection.getInstance();
// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

| Guide | Contents |

|---|---|

| Singleton Pattern | Singleton Pattern |

| Factory Pattern | Factory Pattern |

| Observer Pattern | Observer Pattern |

| Strategy Pattern | Strategy Pattern |

| Decorator Pattern | Decorator Pattern |

| Repository Pattern | Repository Pattern |

| Dependency Injection | Dependency Injection |

Best Practices

✅ DO

❌ DON'T

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.