Agent skill
routing
Route file conventions for organising API and web routes. Covers file separation, naming, grouping, middleware, and route model binding.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/routing-codebar-ag-coding-guidelines
SKILL.md
Name: Routing Description: Route file conventions for organising API and web routes. Covers file separation, naming, grouping, middleware, and route model binding. Compatible Agents: general-purpose, backend Tags: routes/**/*.php, laravel, php, backend, routing, routes, api, web
Rules
- API routes in
routes/api.php; web routes inroutes/web.php - Group related routes with prefixes and middleware
- Use route model binding where possible
- Use resourceful route names:
invoices.index,invoices.store - Use kebab-case for URL segments:
/invoice-lines - Prefix API routes with
/api(handled by Laravel automatically viaapi.php) - Apply authentication middleware at the group level
- Apply throttle middleware on API endpoints
- Use custom middleware for webhook signature verification
Examples
// 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(VerifyStripeSignature::class)
->name('webhooks.stripe');
});
// Route model binding — automatic resolution
Route::get('invoices/{invoice}', ShowInvoiceController::class);
// Controller resolves the model automatically
public function __invoke(Invoice $invoice): JsonResponse { ... }
// Naming with resourceful convention
Route::apiResource('invoice-lines', InvoiceLineController::class);
// Generates: invoice-lines.index, invoice-lines.store, invoice-lines.show, etc.
Anti-Patterns
- Mixing API and web routes in the same file
- Not using route model binding when an ID is passed to look up a model
- Applying authentication middleware per route instead of at the group level
- Using camelCase or snake_case in URL segments instead of kebab-case
- Not naming routes (anonymous routes are harder to reference and refactor)
References
- Laravel Routing
- Related:
Controllers/SKILL.md— controllers that handle routes - Related:
Middleware/SKILL.md— middleware applied at the route group level
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?