From superpowers-laravel
Guides using concrete examples—code patterns, naming conventions, input/output pairs—in prompts to align AI outputs with Laravel project styles and standards.
npx claudepluginhub jpcaparas/superpowers-laravel --plugin superpowers-laravelThis skill uses the workspace's default tool permissions.
Examples clarify intent better than descriptions. Show the AI what you want, don't just tell it.
Generates minimal, complete, and progressive PHP code examples for documentation with expected output, error handling, and patterns like before/after refactoring.
Prompts with Laravel-specific patterns like Eloquent queries, Form Requests, API Resources, Jobs/Queues to generate idiomatic framework code for DB ops, validation, APIs, background tasks.
Provides Laravel patterns and best practices for Eloquent ORM, model relationships, authentication, API resources, testing, caching, and queues.
Share bugs, ideas, or general feedback.
Examples clarify intent better than descriptions. Show the AI what you want, don't just tell it.
"Create a service similar to the payment service"
"Create OrderService following the pattern in app/Services/PaymentService.php:
class PaymentService
{
public function __construct(
private PaymentGateway $gateway,
private PaymentRepository $repository
) {}
public function charge(Order $order): Payment
{
// Implementation
}
}
Use constructor injection, return domain objects, keep methods focused."
Why it works: Shows structure, naming, and patterns to follow.
"Use consistent naming"
"Follow our naming conventions from app/Models/Product.php:
// Relationships: camelCase, descriptive
public function orderItems(): HasMany
public function primaryCategory(): BelongsTo
// Scopes: scope prefix, descriptive
public function scopeActive(Builder $query): void
public function scopePublishedAfter(Builder $query, Carbon $date): void
// Accessors: get prefix, Attribute suffix
public function getFormattedPriceAttribute(): string
Apply same patterns to the new Subscription model."
Why it works: Concrete examples of the conventions in action.
"Transform the product data"
"Transform product data for the API:
Input (from database):
[
'id' => 1,
'name' => 'Widget',
'price_cents' => 2999,
'created_at' => '2024-01-15 10:30:00',
'category' => ['id' => 5, 'name' => 'Tools']
]
Expected output:
{
"id": 1,
"name": "Widget",
"price": "29.99",
"category": "Tools",
"created_at": "2024-01-15T10:30:00Z"
}
Use ProductResource to handle this transformation."
Why it works: Shows exact input and expected output format.
"Handle errors properly"
"Handle errors like we do in app/Services/PaymentService.php:
try {
$charge = $this->gateway->charge($amount);
} catch (PaymentGatewayException $e) {
Log::error('Payment failed', [
'order_id' => $order->id,
'amount' => $amount,
'error' => $e->getMessage(),
]);
throw new PaymentFailedException(
'Unable to process payment: ' . $e->getMessage(),
previous: $e
);
}
Use specific exceptions, log context, preserve original exception."
Why it works: Shows the exact error handling pattern to replicate.
"Add tests"
"Add tests following our pattern in tests/Feature/ProductTest.php:
test('user can create product with valid data', function () {
$user = User::factory()->create();
$category = Category::factory()->create();
$response = $this->actingAs($user)
->postJson('/api/products', [
'name' => 'New Product',
'price' => 29.99,
'category_id' => $category->id,
]);
$response->assertCreated()
->assertJsonStructure(['data' => ['id', 'name', 'price']]);
$this->assertDatabaseHas('products', [
'name' => 'New Product',
]);
});
Use factories, test happy path and validation failures, check database state."
Why it works: Shows test structure, assertions, and patterns to follow.
When establishing new patterns, document them:
"Create a new service pattern for external API integrations. Here's the template:
// app/Services/External/BaseApiClient.php
abstract class BaseApiClient
{
protected string $baseUrl;
protected int $timeout = 30;
protected int $retries = 3;
abstract protected function authenticate(): array;
protected function request(string $method, string $endpoint, array $data = []): array
{
// Retry logic, error handling, logging
}
}
// app/Services/External/StripeClient.php
class StripeClient extends BaseApiClient
{
protected string $baseUrl = 'https://api.stripe.com/v1';
protected function authenticate(): array
{
return ['Authorization' => 'Bearer ' . config('services.stripe.secret')];
}
public function createCharge(int $amount): array
{
return $this->request('POST', '/charges', ['amount' => $amount]);
}
}
Use this pattern for all external API clients. Document in docs/patterns/external-apis.md."
Why it works: Creates a reusable pattern with documentation for future reference.
Make examples work for you:
Examples > explanations. Show, don't just tell.