3.6 KiB
3.6 KiB
name, description
| name | description |
|---|---|
| project-route-structure | Always apply in this project when creating, moving, or refactoring Laravel route definitions in routes/*.php; changing route prefixes, names, middleware, scoped bindings, or route files; or adding frontend-facing endpoints that Wayfinder generates. Documents the KanbanGit route-file layout and grouping conventions. |
Project Route Structure
When to Apply
Activate this skill whenever work in this project changes:
routes/*.php- Route names, URI prefixes, middleware groups, scoped bindings, or controller route registrations
- Frontend-facing endpoints that require regenerated Wayfinder output
Use this together with laravel-best-practices. Also activate wayfinder-development when route changes affect generated frontend route/action imports.
Route Files
routes/web.phpis the web entry point only. Keep public shell routes here, such ashomeanddashboard, then require domain route files.routes/projects.phpowns allprojects.*routes.routes/admin.phpowns alladmin.*routes.routes/teams.phpowns allteams.*routes.routes/settings.phpowns account settings routes, but keeps their existing route names such asprofile.edit,security.edit, andgit-connections.edit.
Add a new route file only when a domain gets large enough to stand alone. Otherwise, extend the existing domain file.
Grouping Pattern
- Put shared middleware, URI prefixes, route name prefixes, and controller declarations on groups instead of repeating them on each route.
- Prefer this nesting order when it reads naturally:
middleware(...),prefix(...),name(...),controller(...), thengroup(...). - Keep public route names stable unless the user explicitly asks for a public interface change.
- Keep route URIs stable when reorganizing route files; this kind of change should be structural.
- Use
function (): voidfor route group closures.
Project Routes
Project routes should follow this shape:
- Top-level group:
middleware(['auth', 'verified']),prefix('projects'),name('projects.'). - Project create/store routes live under
can:create-project. - Routes under
{project}use project gates by capability:- Read pages:
can:view-project,project - Mutations:
can:write-project,project - Project settings and access management:
can:admin-project,project - Project delete:
can:access-admin
- Read pages:
projects/{project}/permissions/...must not be insideRoute::scopeBindings(), becauseProjectdoes not defineusers()orteams()child relationships.- Use
Route::scopeBindings()only around nested project resources that should bind through project-owned relationships, such as tickets and project settings children. - Keep ticket subroutes grouped under
tickets.and settings subroutes grouped undersettings..
Settings Routes
- Keep the
settingsURI prefix grouped. - Keep profile edit/update behind
authonly. - Keep profile deletion, security, git connections, and appearance behind
authplusverified. - Do not rename settings routes to a
settings.*namespace unless the frontend/tests are intentionally updated.
Verification
After changing route files:
- Run
php artisan route:list --except-vendor. - Run
php artisan wayfinder:generate --with-form --no-interactionwhen any route signature, name, method, or controller action changed. - Run
vendor/bin/pint --dirty --format agentfor PHP route formatting. - Run the affected feature tests, usually
php artisan test --compact tests/Feature/Projects tests/Feature/Teams tests/Feature/Admin tests/Feature/Settings. - Run
git diff --checkbefore finalizing.