Laravel prompting patterns

From jpcaparas/superpowers-laravel · View interactive version

Laravel prompting patterns is an AI agent skill from the GitHub repository jpcaparas/superpowers-laravel. Use Laravel-specific vocabulary—Eloquent patterns, Form Requests, API resources, jobs/queues—to get idiomatic framework code

How to use this skill

Skill file

Laravel Prompting Patterns

Use Laravel's vocabulary to get idiomatic code. Generic requests produce generic solutions that don't leverage the framework.

Database Operations

Generic

"Get all active users with their posts"

Laravel-Specific

"Query active users with eager-loaded posts using Eloquent:

User::where('active', true)
    ->with('posts')
    ->get();

Add a scope to User model: scopeActive($query)"

Relationships

"Set up a many-to-many relationship between Posts and Tags:

Query Optimization

"Avoid N+1 on the posts index:

Validation

Generic

"Validate the user input"

Laravel-Specific

"Create UserStoreRequest with validation rules:

public function rules(): array
{
    return [
        'email' => ['required', 'email', 'unique:users,email'],
        'password' => ['required', 'min:12', Password::defaults()],
        'name' => ['required', 'string', 'max:255'],
    ];
}

Add custom error messages in messages() method"

Complex Validation

"Validate order creation:

API Endpoints

Generic

"Create an API for products"

Laravel-Specific

"Create RESTful product API:

Pagination

"Paginate products API:

Filtering

"Add filtering to products API:

Background Processing

Generic

"Send email after user registers"

Laravel-Specific

"Dispatch SendWelcomeEmail job after registration:

SendWelcomeEmail::dispatch($user)
    ->onQueue('emails')
    ->delay(now()->addMinutes(5));

Queue Configuration

"Configure queue for payment processing:

Job Chaining

"Process order with job chain:

Bus::chain([
    new ValidateInventory($order),
    new ChargePayment($order),
    new SendConfirmation($order),
])->dispatch();

If any job fails, chain stops. Handle in catch() callback."

Referencing Documentation

Effective References

"Implement according to Laravel's Eloquent Relationships docs"

"Follow Laravel's Form Request Validation pattern"

"Use Laravel's API Resource pattern for response transformation"

"Configure queues per Laravel Queue docs"

Pattern Catalog

Models & Eloquent:

Validation:

API:

Jobs & Queues:

Use Laravel's vocabulary. Get Laravel solutions.

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.