design-patterns

Diagnose structural code smells and refactor TypeScript monorepo code with design patterns.

Updated Apr 6, 2026
One-click install
npx skills add https://github.com/lety-ai/lety-skill-hub --skill design-patterns-lety-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: design-patterns
Source: https://github.com/lety-ai/lety-skill-hub/tree/main/plugins/design-patterns/skills/design-patterns
Command: npx skills add https://github.com/lety-ai/lety-skill-hub --skill design-patterns-lety-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill diagnoses structural code smells and refactors code to apply appropriate design patterns, reducing duplication, splitting responsibilities, and improving maintainability across frontend and backend parts of a monorepo.

Core Features & Use Cases

  • Smell identification: Detects duplicated conditionals, god services, mixed concerns, hidden coupling, and repeated validation or presentation logic.
  • Pattern-guided refactors: Recommends and implements Strategy, Facade, Observer, Custom Hook, Extract Shared Method, Container/Presenter, Factory/Builder, and Decorator patterns with concrete before/after TypeScript examples.
  • Practical outputs: Produces full working TypeScript snippets, file paths to add, and notes on project conventions to preserve (error handling, DI, naming).
  • Use case: Hand this Skill a long NestJS service or a stateful React component and receive a clear diagnosis plus a minimal, safe refactor that preserves behavior.

Quick Start

Analyze the following TypeScript/NestJS code, identify the primary code smell, and produce a concrete before/after refactor using the simplest appropriate design pattern.

Frequently Asked Questions about design-patterns

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

FAQPage Schema
How do I refactor a messy NestJS service with mixed concerns and duplicated conditionals?

To refactor a messy NestJS service, apply design patterns like Strategy or Facade to split responsibilities and reduce duplicated conditionals. This yields concrete before/after TypeScript examples while preserving existing error handling and dependency injection conventions.

What is the best way to fix a god service code smell in a TypeScript monorepo?

Fixing a god service code smell involves diagnosing the structural issue and applying an appropriate design pattern such as Extract Shared Method or Factory. This process splits unclear responsibilities, recommends a single pattern per session, and lists the new file paths needed for the refactor.

How do I separate presentation logic from stateful React components using design patterns?

Separate presentation logic from stateful React components by applying the Container/Presenter or Custom Hook design patterns. This refactoring approach diagnoses mixed concerns and outputs working TypeScript snippets that maintain your project's existing Zustand and CASL conventions.

Can I use design patterns to refactor TypeScript code without breaking existing gRPC and RabbitMQ integrations?

Yes, you can refactor TypeScript code using design patterns without breaking gRPC and RabbitMQ integrations. The refactoring process explicitly preserves existing error handling, dependency injection, and project conventions while applying structural improvements like Decorator or Observer patterns.

When should I use the Strategy pattern versus the Factory pattern to clean up duplicated TypeScript code?

Use the Strategy pattern to eliminate duplicated conditionals by encapsulating varying behaviors, whereas the Factory pattern is recommended when you need to abstract complex object creation. The diagnosis identifies the primary code smell and recommends a single appropriate pattern per session.

Why does my TypeORM service have hidden coupling and how do I decouple it?

Hidden coupling in a TypeORM service typically stems from mixed concerns and unclear responsibilities within god services. Decouple it by applying structural design patterns like Facade or Observer, which produce concrete before/after TypeScript snippets and specify new files to add.