litestar-app-setup
Installation
SKILL.md
App Setup
Use this skill when defining or refactoring the application root object and its global behavior.
Execution Workflow
- Define an importable application entrypoint (
app.py,application.py,main.py, or factory) for runtime and CLI discovery. - Construct
Litestar(...)with explicitroute_handlers=[...](controllers, routers, or handlers); this list is required. - Configure app-level concerns intentionally (dependencies, middleware, exception handlers, DTO defaults, request/response classes).
- Choose lifecycle model:
- Use
on_startup/on_shutdownfor straightforward init/teardown hooks. - Use
lifespan=[...]async context managers for resource lifecycles that require context ownership. - Add application hooks (
after_exception,before_send,on_app_init) only for cross-cutting concerns. - Use application state sparingly, initialize it explicitly, and inject it intentionally where needed.
- Validate layered overrides to ensure the closest layer to the handler wins as expected.