litestar-routing

Designs Litestar Controllers, Routers, and domain-clustered route modules.

Updated Aug 17, 2026
One-click install
npx skills add https://github.com/renjianguo666/litecms --skill litestar-routing-renjianguo666
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: litestar-routing
Source: https://github.com/renjianguo666/litecms/tree/main/.agents/skills/litestar-routing
Command: npx skills add https://github.com/renjianguo666/litecms --skill litestar-routing-renjianguo666

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Structuring routes in a Litestar application becomes inconsistent as the codebase grows, leading to handlers grouped by HTTP method, fat controllers with business logic, and scattered authorization code. This Skill provides canonical patterns for organizing routes by business domain using Controllers, Routers, and DomainPlugin layout. ## Core Features & Use Cases - Controller Patterns: Group related routes under a Controller class with shared path, guards, dependencies, and tags, keeping handlers thin and async. - Domain-Clustered Layout: Organize code into domain folders where each domain owns its controllers, services, schemas, guards, and jobs, with shared infrastructure in lib/. - Router Composition: Wire Controllers into the app via Router composition or DomainPlugin auto-discovery, with a complete end-to-end vertical slice example. - Use Case: When adding a new tasks feature to a Litestar API, use this Skill to scaffold the Controller with typed path parameters, guard placement, filter dependencies, and app wiring following the canonical fullstack layout. ## Quick Start Ask the AI to design a Litestar Controller for a new domain with list, get, create, update, and delete endpoints following domain-clustered routing conventions.

Frequently Asked Questions about litestar-routing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I organize routes in a Litestar application?

Group related routes into a Controller class that shares path, dependencies, guards, and tags across handlers. Cluster Controllers by business domain in folders like domain/accounts/controllers.py rather than grouping by HTTP method.

When should I use a Litestar Controller versus standalone route handlers?

Use a Controller when routes share a path prefix, guards, dependencies, or tags, since the Controller centralizes that configuration. Standalone decorators like @get and @post suit isolated one-off endpoints.

How do I compose multiple Controllers into a Litestar app?

Create a Router with a path prefix and pass the Controller classes in route_handlers, then register the Router on the Litestar app. For larger apps, use DomainPlugin auto-discovery to walk domain folders and register handlers automatically.

Where should authorization logic go in Litestar routing?

Authorization belongs in Guards attached at the Controller level, not inside handlers. Handlers should stay thin: parse request data, call a service, and return a DTO or response object.

What folder structure does Litestar recommend for large applications?

Cluster code by business domain under src/app/domain/, where each domain owns its controllers, services, schemas, guards, and jobs. Shared cross-cutting infrastructure like exceptions, settings, and base schemas lives in a lib/ folder.