Agent skill
laravel-template-method-and-plugins
Stabilize workflows with Template Method or Strategy; extend by adding new classes instead of editing core logic
Install this agent skill to your Project
npx add-skill https://github.com/noartem/skills/tree/main/skills/laravel-template-method-and-plugins
SKILL.md
Template Method and Pluggable Strategies
Keep core flows stable; enable extension via small classes.
Template Method
Use a base class that defines the algorithm skeleton; subclasses override hooks.
abstract class Importer {
final public function handle(string $path): void {
$rows = $this->load($path);
$data = $this->normalize($rows);
$this->validate($data);
$this->save($data);
}
abstract protected function load(string $path): array;
protected function normalize(array $rows): array { return $rows; }
protected function validate(array $data): void {}
abstract protected function save(array $data): void;
}
Strategy/Plugin
Define an interface; register implementations; select by key/config.
interface PaymentGateway { public function charge(int $cents, string $currency): string; }
final class StripeGateway implements PaymentGateway { /* ... */ }
final class BraintreeGateway implements PaymentGateway { /* ... */ }
final class PaymentsRegistry {
/** @param array<string,PaymentGateway> $drivers */
public function __construct(private array $drivers) {}
public function for(string $key): PaymentGateway { return $this->drivers[$key]; }
}
Prefer adding a class over editing switch statements. Test implementations in isolation.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
laravel-transactions-and-consistency
Wrap multi-write operations in transactions; use dispatchAfterCommit and idempotency patterns to ensure consistency
laravel-filesystem-uploads
Store and serve files via Storage; set visibility, generate URLs, and handle streaming safely
laravel-task-scheduling
Schedule tasks with safety; use withoutOverlapping, onOneServer, and visibility settings for reliable cron execution
laravel-dependencies-trim-packages
Remove unneeded Composer packages and assets to improve boot time, memory, and security surface
laravel-controller-tests
Write focused controller tests using HTTP assertions; keep heavy logic in Actions/Services and unit test them
laravel-strategy-pattern
Use the Strategy pattern to select behavior at runtime; bind multiple implementations to a shared interface
Didn't find tool you were looking for?