Interfaces and di

From jpcaparas/superpowers-laravel · View interactive version

Interfaces and di is an AI agent skill from the GitHub repository jpcaparas/superpowers-laravel. Use interfaces and dependency injection to decouple code; bind implementations in the container

How to use this skill

Skill file

Interfaces and Dependency Injection

Define narrow interfaces and inject them where needed. Bind concrete implementations in a service provider.

interface Slugger { public function slug(string $s): string; }

final class AsciiSlugger implements Slugger {
  public function slug(string $s): string { /* ... */ }
}

$this->app->bind(Slugger::class, AsciiSlugger::class);

Benefits: easier testing (mock interfaces), clearer contracts, swap implementations without touching consumers.

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.