hafizfasih/agentic-crisis-orchestrator/pydantic-settings-management

Claude Code and agent skill by hafizfasih/agentic-crisis-orchestrator

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Guides the professional implementation of application configuration using pydantic-settings and .env files. Use when the user needs to manage environment variables, validate config schemas, or structure settings for agents and web apps (FastAPI, etc.).

Install

npx vskill@latest install hafizfasih/agentic-crisis-orchestrator/pydantic-settings-management

SKILL.md

The same SKILL.md was published earlier as hafizfasih/agentic-crisis-orchestrator/pydantic-settings-management.

Pydantic Settings & Env Management

This skill provides a standardized, type-safe workflow for managing application configuration in 2025.

Workflow Summary

  1. Isolation: Use .env for local secrets; never commit it to git.
  2. Validation: Use BaseSettings to enforce types (e.g., ensure PORT is an int).
  3. Singleton Pattern: Instantiate settings once in a config.py and import the instance.

Implementation Guide

1. Environment File (.env)

Store your keys in a standard .env format at the project root.

env
# .env
DEBUG=true
PORT=8000
API_KEY=sk-your-key-here
2. Configuration Schema

Define your settings in a dedicated config.py file.

python
from pydantic_settings import BaseSettings, SettingsConfigDict
class AppSettings(BaseSettings):
# Fields with types (automatic validation)
api_key: str
port: int = 8000
debug: bool = False
# Metadata & behavior
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
case_sensitive=False
)
# Global instance for app-wide use
settings = AppSettings()
3. Usage in Application

Always import the settings instance, not the class.

python
from config import settings
def start_server():
if settings.debug:
print(f"Starting in DEBUG mode on port {settings.port}")

Advanced Patterns

For complex integrations (Prefixes, Nested Models, or Secrets Directories), refer to the bundled documentation: references/advanced_config.md

Common Troubleshooting

ErrorCauseSolution
ValidationErrorMissing or wrong type in .envCheck that PORT is a number and required keys exist.
ModuleNotFoundErrorpydantic-settings missingRun uv add pydantic-settings.
.env not loadingWrong file pathSet env_file=".env" in SettingsConfigDict.
Third-party SDK can't find env varpydantic-settings reads .env into object, not os.environExport to os.environ in __init__ (see pitfall below)
Pitfall: Third-Party SDKs That Read os.environ

pydantic-settings reads .env into Settings object properties but does NOT export them to os.environ. SDKs like OpenAI, Stripe, and others that read directly from os.environ will fail with "API key not set" errors even though the key is in .env.

Fix: Bridge the gap in __init__:

python
class Settings(BaseSettings):
openai_api_key: str = ""
stripe_secret_key: str = ""
def __init__(self, **kwargs):
import os
super().__init__(**kwargs)
# Bridge pydantic-settings → os.environ for third-party SDKs
if self.openai_api_key and not os.environ.get("OPENAI_API_KEY"):
os.environ["OPENAI_API_KEY"] = self.openai_api_key
if self.stripe_secret_key and not os.environ.get("STRIPE_SECRET_KEY"):
os.environ["STRIPE_SECRET_KEY"] = self.stripe_secret_key

The not os.environ.get(...) guard avoids overwriting explicitly set env vars (e.g., from Docker/CI).

Resources

references/advanced_config.md

Documentation for advanced configuration patterns including environment prefixes, nested settings, and secret masking.

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/hafizfasih/agentic-crisis-orchestrator/pydantic-settings-management/badge)](https://verified-skill.com/skills/hafizfasih/agentic-crisis-orchestrator/pydantic-settings-management)

Something wrong with this skill or its page? Tell us.