What problem does it solve?
Implementing dependency injection in Litestar applications often leads to usage of deprecated patterns, incorrect scope configuration, and messy provider wiring that breaks as the framework evolves. This Skill eliminates these pitfalls by providing clear, up-to-date guidance for all Litestar DI workflows.
Core Features & Use Cases
- Modern DI Pattern Guidance: Replaces deprecated implicit dependency injection and
Dependency() kwargs with current best practices like NamedDependency and NamedDependency[SkipValidation[T]] for Litestar ≥ 2.23.
- Stack Selection Support: Helps you choose between Litestar's built-in
Provide() dependency maps for small to mid-sized apps and Dishka integration for enterprise apps requiring explicit cross-scope resource management.
- Common Pitfall Prevention: Includes guardrails to avoid mistakes like mixing DI naming conventions, storing database sessions as global mutable state, or hiding business logic inside provider functions.
- Use Case: A developer building a multi-controller Litestar API can use this Skill to correctly set up request-scoped database sessions and shared service providers without running into deprecation warnings or scope leaks.
Quick Start
Use the litestar-di skill to configure a correct, non-deprecated dependency injection setup for your Litestar application following current best practices.