From superpowers-laravel
Refines AI-generated Laravel code through specific feedback on errors, gaps, performance issues, and style violations. Use when iterating from rough drafts to production-ready code.
npx claudepluginhub jpcaparas/superpowers-laravel --plugin superpowers-laravelThis skill uses the workspace's default tool permissions.
AI-generated code rarely perfect on first try. Effective iteration gets you from "close" to "exactly right."
Guides crafting effective Laravel code review requests with focus areas, context, architectural feedback, and Laravel conventions. Ideal for actionable reviews.
Provides production-grade Laravel solutions with clean architecture, security best practices, performance optimizations, and idiomatic patterns for Laravel 10/11+. Use for features, refactoring, APIs, auth, services, DB interactions, and code reviews.
Optimizes prompts for code tasks like implementation, debugging, refactoring, review, and testing by adding investigation steps, verification, anti-hallucination rules, and clarity.
Share bugs, ideas, or general feedback.
AI-generated code rarely perfect on first try. Effective iteration gets you from "close" to "exactly right."
"This doesn't work"
"The validation is incorrect:
Current code:
'email' => 'required|email|unique:users'
Problem: This allows updating a user's email to another user's existing email. The unique rule needs to ignore the current user.
Fix:
'email' => [
'required',
'email',
Rule::unique('users')->ignore($this->user()->id)
]
This allows the user to keep their own email but prevents duplicates with other users."
Why it works: Identifies the specific problem, explains why it's wrong, shows the correct solution.
"Something's missing"
"The OrderService is missing error handling:
Current implementation:
public function createOrder(array $data): Order
{
$order = Order::create($data);
$this->processPayment($order);
return $order;
}
Missing:
Add:
DB::transaction(function () use ($data) {
$this->validateInventory($data['items']);
$order = Order::create($data);
$this->processPayment($order);
event(new OrderCreated($order));
return $order;
});
Plus add try/catch for payment failures."
Why it works: Lists specific missing pieces with context and shows how to add them.
"Make it better"
"Refine the query for better performance:
Current:
$products = Product::all()->filter(function ($product) {
return $product->isActive() && $product->inStock();
});
Issues:
Refined:
$products = Product::query()
->where('active', true)
->where('stock_quantity', '>', 0)
->get();
Move filtering to database, use indexed columns, avoid loading unnecessary data."
Why it works: Explains what needs refinement and why, shows the improved version.
"Follow our style guide"
"Update to match our coding standards:
Current:
public function get_user_orders($userId) {
return Order::where('user_id', $userId)->get();
}
Style issues:
getUserOrders$userId ✓ (already correct)Corrected:
/**
* Get all orders for a specific user.
*/
public function getUserOrders(int $userId): Collection
{
return Order::where('user_id', $userId)->get();
}
See our style guide: docs/coding-standards.md"
Why it works: Points to specific style violations, shows corrections, references the style guide.
"Change the validation, add error handling, refactor the service, update the tests, and add logging"
"Let's iterate step by step:
Step 1: Fix the validation issue first
'email' => Rule::unique('users')->ignore($this->user()->id)
Let's verify this works before moving on."
[After validation confirmed working]
"Step 2: Now add error handling for the payment processing
try {
$this->processPayment($order);
} catch (PaymentException $e) {
Log::error('Payment failed', ['order' => $order->id]);
throw new OrderProcessingException('Payment failed', previous: $e);
}
Test this before we continue."
Why it works: One change at a time, validate each step, build confidence incrementally.
"The relationship is incorrect:
**Current:** `return $this->hasMany(Post::class);`
**Problem:** A User has many Posts, but you're defining this in the Post model. This creates a circular relationship.
**Fix:** Move this to the User model, or if you meant Post belongs to User:
```php
// In Post model
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
```"
"Missing authorization check:
**Why it matters:** Any authenticated user can delete any order, not just their own.
**Add this to OrderController@destroy:**
```php
$this->authorize('delete', $order);
And create the policy method:
// In OrderPolicy
public function delete(User $user, Order $order): bool
{
return $user->id === $order->user_id;
}
```"
"Current implementation has issues:
**Current:**
```php
foreach ($orders as $order) {
$order->load('items', 'customer', 'shipping');
}
Issues:
Improved:
$orders = Order::with(['items', 'customer', 'shipping'])->get();
Single query with eager loading."
## Quick Reference
Iterate effectively:
- **Be specific** - Point to exact lines, explain exact problems
- **Show, don't just tell** - Provide corrected code
- **Explain why** - Help the AI understand the reasoning
- **One change at a time** - Validate incrementally
- **Reference standards** - Point to style guides, docs, examples
Specific feedback = better iterations = code that fits your needs.