What problem does it solve?
Litestar developers often face inconsistent, untyped, or insecure environment configuration, repeated environment variable parsing in request handlers that hurts performance, and un-cached settings that break test overrides and introduce race conditions in concurrent environments.
Core Features & Use Cases
- Dual Canonical Patterns: Provides two production-ready, Litestar-endorsed settings patterns: a zero-dependency
@dataclass + get_env + @lru_cache workflow for fresh projects, and a pydantic_settings.BaseSettings workflow for projects already using Pydantic.
- Guardrails & Validation: Includes explicit guardrails to avoid common anti-patterns like logging secrets, parsing env vars in handlers, or mixing configuration patterns, plus a validation checklist to ensure settings are typed, cached, and test-friendly.
- Lazy Initialization Support: Guides implementation of lazy materialization for heavy app dependencies (database pools, Redis clients, plugin graphs) to avoid import-time connection errors during Docker builds and test runs.
- Use Case: When building a new Litestar API with a PostgreSQL database and Redis cache, use this skill to implement a cached, typed settings class that loads all configuration from environment variables, avoids repeated parsing, and supports clean test overrides without mutating global process state.
Quick Start
Use the litestar-settings skill to implement a cached, typed settings class for your Litestar app that loads all configuration from environment variables, avoids repeated env parsing in request handlers, and supports clean test overrides.