$npx -y skills add Jeffallan/claude-skills --skill laravel-specialistBuild and configure Laravel 10+ applications, including creating Eloquent models and relationships, implementing Sanctum authentication, configuring Horizon queues, designing RESTful APIs with API resources, and building reactive interfaces with Livewire. Use when creating Larave
| 1 | # Laravel Specialist |
| 2 | |
| 3 | Senior Laravel specialist with deep expertise in Laravel 10+, Eloquent ORM, and modern PHP 8.2+ development. |
| 4 | |
| 5 | ## Core Workflow |
| 6 | |
| 7 | 1. **Analyse requirements** — Identify models, relationships, APIs, and queue needs |
| 8 | 2. **Design architecture** — Plan database schema, service layers, and job queues |
| 9 | 3. **Implement models** — Create Eloquent models with relationships, scopes, and casts; run `php artisan make:model` and verify with `php artisan migrate:status` |
| 10 | 4. **Build features** — Develop controllers, services, API resources, and jobs; run `php artisan route:list` to verify routing |
| 11 | 5. **Test thoroughly** — Write feature and unit tests; run `php artisan test` before considering any step complete (target >85% coverage) |
| 12 | |
| 13 | ## Reference Guide |
| 14 | |
| 15 | Load detailed guidance based on context: |
| 16 | |
| 17 | | Topic | Reference | Load When | |
| 18 | |-------|-----------|-----------| |
| 19 | | Eloquent ORM | `references/eloquent.md` | Models, relationships, scopes, query optimization | |
| 20 | | Routing & APIs | `references/routing.md` | Routes, controllers, middleware, API resources | |
| 21 | | Queue System | `references/queues.md` | Jobs, workers, Horizon, failed jobs, batching | |
| 22 | | Livewire | `references/livewire.md` | Components, wire:model, actions, real-time | |
| 23 | | Testing | `references/testing.md` | Feature tests, factories, mocking, Pest PHP | |
| 24 | |
| 25 | ## Constraints |
| 26 | |
| 27 | ### MUST DO |
| 28 | - Use PHP 8.2+ features (readonly, enums, typed properties) |
| 29 | - Type hint all method parameters and return types |
| 30 | - Use Eloquent relationships properly (avoid N+1 with eager loading) |
| 31 | - Implement API resources for transforming data |
| 32 | - Queue long-running tasks |
| 33 | - Write comprehensive tests (>85% coverage) |
| 34 | - Use service containers and dependency injection |
| 35 | - Follow PSR-12 coding standards |
| 36 | |
| 37 | ### MUST NOT DO |
| 38 | - Use raw queries without protection (SQL injection) |
| 39 | - Skip eager loading (causes N+1 problems) |
| 40 | - Store sensitive data unencrypted |
| 41 | - Mix business logic in controllers |
| 42 | - Hardcode configuration values |
| 43 | - Skip validation on user input |
| 44 | - Use deprecated Laravel features |
| 45 | - Ignore queue failures |
| 46 | |
| 47 | ## Code Templates |
| 48 | |
| 49 | Use these as starting points for every implementation. |
| 50 | |
| 51 | ### Eloquent Model |
| 52 | |
| 53 | ```php |
| 54 | <?php |
| 55 | |
| 56 | declare(strict_types=1); |
| 57 | |
| 58 | namespace App\Models; |
| 59 | |
| 60 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 61 | use Illuminate\Database\Eloquent\Model; |
| 62 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
| 63 | use Illuminate\Database\Eloquent\Relations\HasMany; |
| 64 | use Illuminate\Database\Eloquent\SoftDeletes; |
| 65 | |
| 66 | final class Post extends Model |
| 67 | { |
| 68 | use HasFactory, SoftDeletes; |
| 69 | |
| 70 | protected $fillable = ['title', 'body', 'status', 'user_id']; |
| 71 | |
| 72 | protected $casts = [ |
| 73 | 'status' => PostStatus::class, // backed enum |
| 74 | 'published_at' => 'immutable_datetime', |
| 75 | ]; |
| 76 | |
| 77 | // Relationships — always eager-load via ::with() at call site |
| 78 | public function author(): BelongsTo |
| 79 | { |
| 80 | return $this->belongsTo(User::class, 'user_id'); |
| 81 | } |
| 82 | |
| 83 | public function comments(): HasMany |
| 84 | { |
| 85 | return $this->hasMany(Comment::class); |
| 86 | } |
| 87 | |
| 88 | // Local scope |
| 89 | public function scopePublished(Builder $query): Builder |
| 90 | { |
| 91 | return $query->where('status', PostStatus::Published); |
| 92 | } |
| 93 | } |
| 94 | ``` |
| 95 | |
| 96 | ### Migration |
| 97 | |
| 98 | ```php |
| 99 | <?php |
| 100 | |
| 101 | use Illuminate\Database\Migrations\Migration; |
| 102 | use Illuminate\Database\Schema\Blueprint; |
| 103 | use Illuminate\Support\Facades\Schema; |
| 104 | |
| 105 | return new class extends Migration |
| 106 | { |
| 107 | public function up(): void |
| 108 | { |
| 109 | Schema::create('posts', function (Blueprint $table): void { |
| 110 | $table->id(); |
| 111 | $table->foreignId('user_id')->constrained()->cascadeOnDelete(); |
| 112 | $table->string('title'); |
| 113 | $table->text('body'); |
| 114 | $table->string('status')->default('draft'); |
| 115 | $table->timestamp('published_at')->nullable(); |
| 116 | $table->softDeletes(); |
| 117 | $table->timestamps(); |
| 118 | }); |
| 119 | } |
| 120 | |
| 121 | public function down(): void |
| 122 | { |
| 123 | Schema::dropIfExists('posts'); |
| 124 | } |
| 125 | }; |
| 126 | ``` |
| 127 | |
| 128 | ### API Resource |
| 129 | |
| 130 | ```php |
| 131 | <?php |
| 132 | |
| 133 | declare(strict_types=1); |
| 134 | |
| 135 | namespace App\Http\Resources; |
| 136 | |
| 137 | use Illuminate\Http\Request; |
| 138 | use Illuminate\Http\Resources\Json\JsonResource; |
| 139 | |
| 140 | final cla |