From superpowers-laravel
Implements Strategy pattern in Laravel: shared interface, multiple implementations, factory for runtime selection by key/context, bound via service provider.
How this skill is triggered — by the user, by Claude, or both
Slash command
/superpowers-laravel:strategy-patternThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Create a common interface and multiple implementations. Choose a strategy by key or context.
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.
npx claudepluginhub jpcaparas/superpowers-laravel --plugin superpowers-laravelGenerates PHP 8.4 Strategy pattern with interface, concrete strategies, resolver, optional service, and unit tests for interchangeable algorithm families like pricing or sorting.
Implements Template Method and Strategy patterns in Laravel to stabilize core workflows, enabling extension via new classes instead of editing logic or switches.
Implements the Strategy pattern using Symfony tagged services for runtime algorithm selection and extensibility. Helps refactor conditional logic into decoupled strategies.