From pysmith
Generate Pydantic Settings configuration with YAML support. Creates config/settings.py and example.env.yaml for type-safe configuration management. Use when setting up application configuration, adding environment-specific settings, or migrating from os.getenv() to Pydantic Settings.
npx claudepluginhub jugrajsingh/skillgarden --plugin pysmithThis skill is limited to using the following tools:
Create type-safe configuration management with Pydantic Settings and YAML support.
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Generates original PNG/PDF visual art via design philosophy manifestos for posters, graphics, and static designs on user request.
Create type-safe configuration management with Pydantic Settings and YAML support.
os.getenv() in app code - Use Pydantic Settingsexample.env.yaml, gitignore *.env.yamlGlob: config/settings.py, *settings*.py, example.env.yaml, *.env.yaml
If settings exist, ask via AskUserQuestion:
Present multi-select via AskUserQuestion:
Which config sections do you need?
☐ postgres (PostgresSettings) - Database connection
☐ redis (RedisSettings) - Cache/queue connection
☐ aws (AWSSettings) - AWS region, endpoint URL
☐ elasticsearch (ElasticsearchSettings) - Search cluster
☐ sentry (SentrySettings) - Error monitoring
☐ logging (LoggingSettings) - Log level, format
☐ api (APISettings) - Host, port, CORS
Read references/settings-template.py as the base template. Customize:
get_settings() cached singleton and convenience exportRead references/example-env.yaml as the base template. Customize:
Append if not present:
# Local configuration (secrets)
*.env.yaml
!example.env.yaml
local.*.yaml
If not already present in pyproject.toml:
uv add "pydantic-settings[yaml]>=2.0"
Created Pydantic Settings configuration:
config/settings.py
- Settings class with selected sections
- Type-safe configuration with validation
- Cached singleton via get_settings()
example.env.yaml
- Template with all settings documented
- Copy to local.env.yaml for local development
.gitignore updated
- *.env.yaml ignored (except example)
Dependency added:
- pydantic-settings[yaml]>=2.0
Usage:
from config.settings import settings
db_host = settings.postgres.host
aws_region = settings.aws.aws_region
Next steps:
1. cp example.env.yaml local.env.yaml
2. Edit local.env.yaml with your values
3. Import settings in your code
| YAML Path | Environment Variable |
|---|---|
postgres.host | POSTGRES__HOST |
postgres.password | POSTGRES__PASSWORD |
aws.aws_region | AWS__AWS_REGION |
elasticsearch.hosts | ELASTICSEARCH__HOSTS='["http://es:9200"]' |
logging.level | LOGGING__LEVEL |
The template uses discoverable YAML files with YamlConfigSettingsSource:
YAML_CONFIG_FILES = ["env.yaml", "local.env.yaml"]
env.yaml = base config (deployed via ConfigMap/secret in k8s)local.env.yaml = local dev overrides (gitignored, highest priority)Runtime override for scripts that need a different environment:
# In a script (e.g., reset_job.py, reindex_job.py):
settings = Settings(yaml_file="production.env.yaml")
The yaml_file init kwarg replaces the entire discovery list with a single file.
The underscore prefix avoids collision with the model_config.yaml_file key.
This is implemented via settings_customise_sources() which pops yaml_file
from init_kwargs before Pydantic processes them.
example.env.yaml goes in gityaml_file for scripts - Don't hardcode production configs