plugins/litestar/skills/litestar-routing/SKILL.md
Design and implement Litestar routing with app/router/controller composition, handler decorators, path and parameter modeling, route indexing/reverse lookups, ASGI mounting, and layered route metadata. Use when creating or refactoring endpoint topology and URL contracts. Do not use for purely internal service logic unrelated to HTTP route structure.
npx skillsauth add alti3/litestar-skills litestar-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.
Use this skill when API path design, handler registration, route composition, and parameter behavior are core to the task.
name, opt) for discoverability and policy hooks.@get, @post, etc.) over @route() for clearer OpenAPI operations.Litestar(route_handlers=[...]) is the root registration point./.app.register(handler) when runtime registration is genuinely required.Request, WebSocket, ASGIConnection), so dynamic registration can be called from handlers/middleware/dependencies.Router can register controllers, handlers, and nested routers.Controller subclasses with a class-level path.path is omitted, it defaults to /.sync_to_thread=True runs in threadpool (safe for blocking code).sync_to_thread=False signals non-blocking sync behavior.@get("/x")) or keyword (@get(path="/x")).ImproperlyConfiguredException during app startup.Reserved names include:
cookies, headers, queryrequest (HTTP handlers)socket (WebSocket handlers)scope, state, body (body for HTTP handlers)If collisions occur, use alternative parameter naming patterns.
@route() maps to HTTPRouteHandler but is generally discouraged for normal CRUD-style APIs.@get, @post, @put, @patch, @delete, @head@websocket() supports low-level socket handling directly.@asgi() / ASGIRouteHandler supports custom ASGI apps.scope, receive, send.@asgi(..., is_mount=True) to mount sub-app behavior on a path prefix.copy_scope=True, forwarded scope["path"] is rewritten relative to mount root.name on handlers for stable lookup.ImproperlyConfiguredException.route_reverse(name, **params) can build a path.request.url_for(name, **params) builds absolute URLs.optopt={...} metadata.opt.opt is available to guards, request route handler context, and ASGI scope.opt is layered (app/router/controller/handler) and merged by precedence.TYPE_CHECKING, resolve them via:signature_types=[...] on app/router/controller/handler layer as needed.signature_namespace={...} when alias names differ from runtime type __name__.Default signature namespace includes:
Headers, ImmutableState, Receive, Request, Scope, Send, State, WebSocket, WebSocketScope{name:type}, for example {user_id:int}.date, datetime, decimal, float, int, path, str, time.Parameter() helperParameter(...) with Annotated[...] for extra validation and OpenAPI metadata.gt, lt, titles/descriptions/examples).str | None / Optional[str]) express nullable query params.Parameter(query="externalName").Parameter(...), for example numeric bounds.schema_component_key when same enum needs different parameter descriptions across endpoints.Parameter(header="...") or Parameter(cookie="...").route_handlers topology resolves to intended final paths.sync_to_thread decisions.route_reverse / url_for) is deterministic for indexed handlers.opt metadata merge behavior is correct across layers.litestar-requests and litestar-responses for transport contract depth.litestar-authentication and litestar-dependency-injection for route-scoped security/services.litestar-websockets for higher-level websocket session architecture.litestar-openapi to verify operation IDs, parameter schemas, and route docs fidelity.development
Build Litestar WebSocket endpoints with low-level websocket handlers, websocket listeners, websocket streams, dependency injection, custom websocket classes, transport-mode control, and graceful connection lifecycle handling. Use when implementing bidirectional real-time communication, reactive websocket message handling, or proactive server push over WebSockets. Do not use for server-side pub/sub fanout that is better expressed with channels alone.
tools
Test Litestar applications with TestClient, AsyncTestClient, create_test_client, websocket test helpers, dependency overrides, mocked dependencies, lifecycle-aware fixtures, and deterministic success and failure assertions. Use when adding or fixing Litestar test coverage, including exception contracts, override precedence, websocket behavior, event-bus side effects, or live-server-only response patterns. Do not use as a substitute for production observability or runtime debugging strategy.
development
Configure Litestar templating with `TemplateConfig`, Jinja/Mako/MiniJinja engines, file-or-string `Template` responses, request and CSRF-aware context, template callables, and custom engine integration. Use when implementing or fixing server-rendered HTML in Litestar. Do not use for static asset serving or pure JSON API endpoints.
development
Configure Litestar stores and the store registry for caching, server-side sessions, rate limiting, and other key-value state with explicit backend selection, bytes-safe data handling, TTL and renewal policy, namespacing, registry wiring, and lifecycle cleanup. Use when a Litestar app depends on `MemoryStore`, `FileStore`, `RedisStore`, `ValkeyStore`, or `StoreRegistry`. Do not use for relational persistence, domain repositories, or response-caching policy details that belong in database or caching-focused skills.