hernandor/agent-skillset/pydantic-config-tree
Claude Code and agent skill by hernandor/agent-skillset
- community
Checking that the SKILL.md file is still in the repository.
Use when a project has hyperparameters or behavioural settings scattered across modules, environment variables, or ad-hoc config classes, and a single typed root model with domain-grouped sub-models, env-var binding, and YAML round-trip is wanted.
Install
npx vskill@latest install hernandor/agent-skillset/pydantic-config-treeSKILL.md
The same SKILL.md was published earlier as hernandor/agent-skillset/pydantic-config-tree.
Pydantic Config Tree
Overview
A typed, frozen root model with domain-grouped sub-models, env-var binding, and YAML persistence is the recurring shape for medium-to-large Python pipelines. This skill ships the template and the rules that keep the tree maintainable: classmethod-based singleton hooks, pydantic-settings defaults, flat-by-default with a hard nesting cap.
When To Use
- A project has > ~30 settings and they live as scattered constants, env vars,
or per-module config dataclasses.
- You're about to add another
MyComponentConfigand the project has three of
them already.
- Settings need YAML round-trip for human review or persistence.
Do not use for projects with < 10 settings — a single dataclass plus os.environ is fine.
Singleton Pattern
Singleton is recommended, not required, and never module-level. Module-level _instance = None patterns hide the construction moment. Use classmethod hooks on the root model:
Construction is grep-able: AppConfig.bind(AppConfig.from_env()) at app entry appears at one site.
Env-Var Loading
pydantic-settings is the default. Use BaseSettings on the root or sub-models with a project-wide env_prefix:
Hand-written from_env() is the documented fallback for projects with sparse env coverage (≤ 5 vars) or migrations off a legacy reader. See references/from-env-fallback.md.
YAML Round-Trip
YAML is the default. `yaml.safe_load` is mandatory; yaml.load is a remote-code-execution footgun.
Adopters who must use JSON or TOML do a one-line import swap; no shipped adapter.
Nesting Discipline
- Flat by default: root → 5-ish sub-models. Add a sub-model only when it
owns ≥ 3 fields.
- Hard cap: three layers (root → sub-model → sub-sub-model). Beyond three,
env-var paths get unreadable; the signal is to split into multiple config trees, not deepen one.
See references/root-template.md for the worked shape.
Common Mistakes
- Defining
_instance = Noneas a module-level variable instead of a
classmethod-managed slot.
- Using
yaml.loadinstead ofyaml.safe_load. - Adding a fourth nesting level "because the domain is hierarchical" — split
the project into multiple trees instead.
- Letting two sub-models own < 3 fields each just to mirror the directory
structure. Flatten.
- Calling
bind()from inside a library import (binds at import time, hides
the construction moment).
Related Skills
centralized-path-config— companion for path config; cross-link only.loguru-first-logging— config tree often binds the log level at app
entry.
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
- SKILL.md in the repositoryCheckingplugins/implement/skills/pydantic-config-tree/SKILL.md
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
[](https://verified-skill.com/skills/hernandor/agent-skillset/pydantic-config-tree)