Best for
- Creating custom middleware for authentication, logging, headers, etc.
- Configuring middleware groups and priority
- Terminable middleware (post-response processing)
event4u-app/agent-config/src/skills/laravel-middleware/SKILL.md
Use when creating or modifying Laravel middleware — request/response filtering, groups, priority, terminable middleware, or route-level assignment.
Decision brief
Use when creating or modifying Laravel middleware — request/response filtering, groups, priority, terminable middleware, or route-level assignment.
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/event4u-app/agent-config --skill "src/skills/laravel-middleware"Inspect the Agent Skill "laravel-middleware" from https://github.com/event4u-app/agent-config/blob/0adf49a8ae84b0ff6e2de8759eea43257e020eff/src/skills/laravel-middleware/SKILL.md at commit 0adf49a8ae84b0ff6e2de8759eea43257e020eff. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
1. Inspect existing middleware — Read app/Http/Middleware/ and bootstrap/app.php (or app/Http/Kernel.php) to identify naming conventions, aliases, and current group/global registration. 2. Generate class — php artisan make:middleware EnsureCustomerIsActive. 3. Implement logic —…
Use this skill when working with HTTP middleware: - Creating custom middleware for authentication, logging, headers, etc. - Configuring middleware groups and priority - Terminable middleware (post-response processing) - Route-level and global middleware assignment
Review the “Example” section in the pinned source before continuing.
Review the “Before vs. After middleware” section in the pinned source before continuing.
Runs after the response has been sent to the browser:
Permission review
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 92/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 7 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Use this skill when working with HTTP middleware:
app/Http/Middleware/ and bootstrap/app.php (or app/Http/Kernel.php) to identify naming conventions, aliases, and current group/global registration.php artisan make:middleware EnsureCustomerIsActive.handle(), return response or pass to next.php artisan make:middleware EnsureCustomerIsActive
declare(strict_types=1);
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
class EnsureCustomerIsActive
{
public function handle(Request $request, Closure $next): Response
{
if (!$request->user()?->getCustomer()?->isActive()) {
abort(403, 'Customer account is inactive.');
}
return $next($request);
}
}
// Before middleware — runs BEFORE the request hits the controller
public function handle(Request $request, Closure $next): Response
{
// Check something before the request
return $next($request);
}
// After middleware — runs AFTER the controller returns a response
public function handle(Request $request, Closure $next): Response
{
$response = $next($request);
// Modify the response
$response->headers->set('X-Custom-Header', 'value');
return $response;
}
Runs after the response has been sent to the browser:
class LogRequestDuration
{
private float $startTime;
public function handle(Request $request, Closure $next): Response
{
$this->startTime = microtime(true);
return $next($request);
}
public function terminate(Request $request, Response $response): void
{
$duration = microtime(true) - $this->startTime;
Log::info('Request duration', [
'url' => $request->fullUrl(),
'duration_ms' => round($duration * 1000, 2),
]);
}
}
class CheckRole
{
public function handle(Request $request, Closure $next, string $role): Response
{
if (!$request->user()?->hasRole($role)) {
abort(403);
}
return $next($request);
}
}
// Usage in routes
Route::get('/admin', AdminController::class)->middleware('role:admin');
// Route-level
Route::get('/dashboard', DashboardController::class)
->middleware([EnsureCustomerIsActive::class]);
// Group-level
Route::middleware(['auth', EnsureCustomerIsActive::class])->group(function () {
// ...
});
// Global middleware (bootstrap/app.php)
->withMiddleware(function (Middleware $middleware) {
$middleware->append(LogRequestDuration::class);
$middleware->prepend(SetLocale::class);
})
// bootstrap/app.php — control execution order
->withMiddleware(function (Middleware $middleware) {
$middleware->priority([
AuthenticateMiddleware::class,
EnsureCustomerIsActive::class,
CheckRole::class,
]);
})
handle() if the next middleware might also modify it — use terminate() for cleanup.