mcpField
L
laravel:strategy-pattern

laravel:strategy-pattern

github.com/jpcaparasDevelopment157108 installsUpdated 19w ago
Repository

About laravel:strategy-pattern

A Laravel skill for structuring interchangeable implementations behind a shared interface. It helps developers select behavior by a key or context and centralize construction in a factory.

Key features

  1. 01Shared interface for strategies
  2. 02Multiple interchangeable implementations
  3. 03Selection by key or context
  4. 04Factory registered in a service provider

Use cases

  1. 01Selecting country-specific tax calculations
  2. 02Choosing behavior based on runtime context

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/jpcaparas/superpowers-laravel --skill laravel:strategy-pattern

After installing, type/laravel:strategy-patternin Claude Code to confirm it loaded.

Details

From the project README

Strategy Pattern

Create a common interface and multiple implementations. Choose a strategy by key or context.

interface TaxCalculator { public function for(int $cents): int; }
final class NzTax implements TaxCalculator { /* ... */ }
final class AuTax implements TaxCalculator { /* ... */ }

final class TaxFactory {
  public function __construct(private array $drivers) {}
  public function forCountry(string $code): TaxCalculator { return $this->drivers[$code]; }
}

Register in a service provider and inject the factory where needed.

Comments

Markdown supported