litestar-dto
Installation
SKILL.md
DTO
Use this skill when request and response payloads need explicit shape control, field-level policy, or DTO factory customization.
Execution Workflow
- Start with the handler contract: define inbound (
dto) and outbound (return_dto) behavior explicitly. - Choose DTO factory type for your model ecosystem (for example,
DataclassDTO,SQLAlchemyDTO, or plugin-provided DTOs). - Define policy with
DTOConfig(exclude, rename, nesting depth, unknown-field handling, PATCH behavior). - Apply DTOs at the correct layer (handler, controller, router, or app) and rely on closest-layer precedence.
- Use
DTOData[T]in write/update handlers when you need controlled instantiation and patching semantics. - Validate wrappers and envelopes (
Response[T], pagination, generic wrappers) to ensure DTO transformation is still applied. - Implement a custom
AbstractDTOonly when factory DTOs cannot express required behavior.