- Home
- Skills
- APIs & Backend
- Laravel Architecture
Works with the AI Agents you already use
Laravel Architecture
Build, refactor, and audit Laravel applications using idiomatic patterns and optimized Eloquent queries.
$5.99
Laravel Architecture
Example session with this skill installed
Refactor the StoreOrder logic in OrderController to use a dedicated Action class. Ensure it handles database transactions and dispatches the OrderCreated event.
- Read your context and instructions
- Compiled the laravel architecture
I have refactored the order creation logic. The process now uses a dedicated Action class to ensure a clear transaction boundary, moving logic out of the controller and into a reusable domain component.
Refactored Order Architecture
// app/Actions/StoreOrderAction.php
namespace App\Actions;
use App\Models\Order;
use App\Events\OrderCreated;
use Illuminate\Support\Facades\DB;
use App\Http\Requests\StoreOrderRequest;
class StoreOrderAction
{
public function execute(StoreOrderRequest $request): Order
{
return DB::transaction(function () use ($request) {
$order = Order::create($request->validated());
if ($request->has('items')) {
$order->items()->createMany($request->input('items'));
}
OrderCreated::dispatch($order);
return $order;
});
}
}
// app/Http/Controllers/OrderController.php
namespace App\Http\Controllers;
use App\Actions\StoreOrderAction;
use App\Http\Requests\StoreOrderRequest;
use App\Http\Resources\OrderResource;
class OrderController extends Controller
{
public function store(StoreOrderRequest $request, StoreOrderAction $storeOrder)
{
$order = $storeOrder->execute($request);
return new OrderResource($order);
}
}
Next steps
- Update
OrderActionTest.phpto verify the transaction rolls back on item creation failure. - Register the
OrderCreatedlistener in yourEventServiceProviderif not using discovery. - Verify that
StoreOrderRequestincludes all necessary validation rules for the nested items array.
Connects securely to your tools. The creator never sees your data.
About this skill
Laravel development moves fast, but architectural technical debt accumulates even faster. This skill handles everything from resolving N+1 query bottlenecks to designing complex event-driven systems while maintaining idiomatic Laravel patterns. It ensures your application stays maintainable by choosing the simplest design that works, rather than forcing unnecessary abstractions like repositories or DDD where a simple Controller and Eloquent model suffice.
What it does
- Architectural design suggests idiomatic patterns from simple CRUD to CQRS or event sourcing based on specific business needs.
- Query optimization identifies and fixes N+1 issues, implements caching, and optimizes Eloquent relationships and migrations.
- Reliable background processing configures queues, jobs, and events with atomic handoffs and idempotent processing logic.
- Security enforcement implements robust authorization via Policies, validates input with Form Requests, and secures trust boundaries.
- Modern frontend integration builds delivery layers using Blade, Livewire, Inertia.js, or dedicated API resources.
How it works
- Discovery scans
composer.jsonand project files to identify Laravel versions, installed packages, and existing architectural patterns. - Analysis traces affected entry points, data flows, and business rules to define success and failure states.
- Implementation writes the smallest coherent change, prioritizing native framework features and type safety.
- Verification runs focused tests using production-family drivers to prove guarantees for locking, isolation, and delivery.
Frameworks & tools
Specifically built for the Laravel ecosystem, including Eloquent ORM, Blade, Livewire, Inertia.js, Sanctum, Passport, Horizon, and Octane. It supports testing via Pest or PHPUnit and static analysis integration.
Why this beats prompting it yourself
Generic AI often hallucinates outdated APIs or forces generic PHP patterns onto Laravel. This skill verifies APIs against your specific version and understands the trade-offs between facades, dependency injection, and service providers in a real-world application.
Use cases
- Refactor a bloated Controller into dedicated Action classes and Form Requests.
- Troubleshoot a race condition in a high-concurrency job using atomic locks.
- Design a multi-tenant isolation strategy for a new SaaS feature.
- Audit an existing codebase for N+1 queries and missing database indexes.
Known limitations
Does not support standalone PHP libraries without a Laravel integration boundary. Destructive operations and live deployments require explicit manual authorization.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Not for standalone PHP libraries. Destructive operations or live deployments require manual authorization. Scope limited to Laravel-integrated codebases.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 2 days ago
- Software
Git