resources/boost/skills/routing/SKILL.md
Route file conventions for organising API and web routes. Covers file separation, naming, grouping, middleware, and route model binding.
npx skillsauth add codebar-ag/coding-guidelines routingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
routes/web.php and routes/api.php are present and loaded.getRouteKeyName() when needed).web.php vs api.php).web routes prioritize session/CSRF/auth flow; api routes prioritize auth/throttle/binding consistency./api/v1/...) and keep version groups isolated.// routes/api.php
Route::middleware('auth:sanctum')->group(function () {
Route::apiResource('invoices', InvoiceController::class);
Route::prefix('invoices')->group(function () {
Route::post('{invoice}/pay', PayInvoiceController::class)->name('invoices.pay');
});
});
Route::middleware(['throttle:webhook'])->group(function () {
Route::post('webhooks/stripe', ProcessStripeWebhookController::class)
// Middleware ordering matters: signature check before heavy work.
->middleware([VerifyStripeSignature::class])
->name('webhooks.stripe');
});
// Implicit route model binding
Route::get('invoices/{invoice}', ShowInvoiceController::class);
// Controller resolves the model automatically
public function __invoke(Invoice $invoice): JsonResponse { ... }
// Explicit binding for custom resolution/gotchas
// App\Providers\RouteServiceProvider::boot()
Route::bind('invoice', function (string $value) {
return Invoice::where('uuid', $value)->firstOrFail();
});
// Route uses the same placeholder name: {invoice}
Route::get('invoices/{invoice}', ShowInvoiceController::class);
// Naming with resourceful convention
Route::apiResource('invoice-lines', InvoiceLineController::class);
// Generates: invoice-lines.index, invoice-lines.store, invoice-lines.show, etc.
{invoice} binds to Invoice $invoice; {invoiceId} does not.getRouteKeyName() or explicit Route::bind.withTrashed() patterns) when expected.// Soft-deleted model binding when restore/history endpoints must resolve trashed records
// routes/api.php
Route::get('invoices/{invoice}/audit', ShowInvoiceAuditController::class);
// App\Providers\RouteServiceProvider::boot()
Route::bind('invoice', function (string $value) {
return Invoice::withTrashed()->where('uuid', $value)->firstOrFail();
});
web, keep session/cookies/CSRF stack intact before auth-gated routes.api, apply auth and throttle consistently at version/group boundaries to avoid route drift.route:cache; use controller classes for cache-safe production routing.php artisan route:cache in CI and deployment pipelines after route/provider changes.route:cache as part of normal local development loop; prefer uncached routes locally for faster iteration/debugging.php artisan route:clear.php artisan route:list to verify names, middleware, and URI shape.404 when model missing).// Middleware ordering test: reject unauthenticated request before controller side effects
public function test_pay_invoice_requires_auth_before_controller_runs(): void
{
Event::fake([InvoicePaid::class]);
$this->postJson('/api/invoices/uuid-123/pay')
->assertUnauthorized();
Event::assertNotDispatched(InvoicePaid::class);
}
// Explicit 404 binding-failure test
public function test_show_invoice_returns_404_for_missing_binding(): void
{
$this->getJson('/api/invoices/non-existing-uuid')
->assertNotFound();
}
Controllers/SKILL.md — controllers that handle routesMiddleware/SKILL.md — middleware applied at the route group leveltesting
Translation and localization conventions for Laravel. Use when adding user-facing strings, creating translation files, or working with lang/ directory.
tools
Reusable behaviour shared across multiple unrelated classes. Traits provide shared Eloquent scopes, accessors, lifecycle hooks, and small stateless helper methods.
development
Tailwind CSS v4 styling conventions. Use when working with CSS, Tailwind utilities, or customizing the theme in Laravel projects.
development
Orchestration classes that coordinate multiple Actions, external APIs, or domain operations into a cohesive workflow. Services own transaction boundaries and third-party API integrations.