pydantic-settings

Defines and validates typed environment-variable configuration through a pydantic-settings Settings class.

Updated Sep 13, 2026
One-click install
npx skills add https://github.com/abdulazeezoj/monovella-poc --skill pydantic-settings-abdulazeezoj
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pydantic-settings
Source: https://github.com/abdulazeezoj/monovella-poc/tree/main/.agents/skills/pydantic-settings
Command: npx skills add https://github.com/abdulazeezoj/monovella-poc --skill pydantic-settings-abdulazeezoj

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pydantic-settings, and includes references (resource) components.

What problem does it solve? This Skill standardizes how a FastAPI project defines, loads, and consumes environment-variable configuration, preventing inconsistent config patterns and confusing runtime failures from missing or mistyped settings. ## Core Features & Use Cases - Typed Settings Pattern: Documents the single Settings(BaseSettings) class in core/config.py, loaded once at import time from environment variables and .env with extra="ignore". - Add-a-Setting Workflow: Provides a step-by-step guide for adding a new setting end-to-end — the field, the matching env.jinja line, and the consumer import. - Startup Validation Guidance: Explains why validation at import time surfaces a clear ValidationError naming the offending field instead of a None failing later in a request handler. - Use Case: When wiring a new integration that needs an API key or connection string, follow the guide to add the field, the env var, and the consumer import so the app fails fast at startup if the value is missing. ## Quick Start Ask the AI to add a new SMTP_HOST setting to the project's Settings class following the pydantic-settings skill.

Frequently Asked Questions about pydantic-settings

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

FAQPage Schema
How do I add a new environment variable setting with pydantic-settings?

Add a typed field with a sensible default to the Settings class in core/config.py, add the matching UPPER_SNAKE_CASE line to env.jinja, then import the settings singleton wherever the value is needed. BaseSettings maps the field to its env var automatically.

How does pydantic-settings map fields to environment variables?

A snake_case field on a BaseSettings subclass maps to its UPPER_SNAKE_CASE environment variable by default, so database_url reads DATABASE_URL with no explicit alias. Real environment variables take priority, then the .env file, then the field's Python default.

Why does my app raise a ValidationError at startup with pydantic-settings?

A field declared without a default has no corresponding environment variable or .env entry, so pydantic validation fails when Settings() is constructed at import time. The error names the offending field; add the env var or give the field a default.

Should I instantiate Settings per request or use a singleton?

Use a single module-level settings = Settings() instance imported everywhere. Building it is pure and side-effect-free, so eager construction at import time is safe, unlike database engines or broker connections that must be deferred to a lifespan hook.

How do I keep .env and .env.example in sync?

In this project the generator mirrors whatever env.jinja renders into both .env and the checked-in .env.example at generation time. After generation nothing syncs them automatically, so add new variables to env.jinja rather than hand-editing one file.