python-values-failure

Detects thirteen anti-patterns in Pydantic domain value modeling for Python.

Updated Jul 15, 2026
One-click install
npx skills add https://github.com/kyzobuild/kyzo-python --skill python-values-failure-kyzobuild
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python-values-failure
Source: https://github.com/kyzobuild/kyzo-python/tree/main/cursor/skills/python-values-failure
Command: npx skills add https://github.com/kyzobuild/kyzo-python --skill python-values-failure-kyzobuild

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Domain data in Python often gets shaped as bare primitives, mutable containers, or nullable fields, scattering constraints into runtime checks instead of encoding them in types. This Skill identifies thirteen specific failure patterns in Pydantic value modeling and shows the correct construct for each. ## Core Features & Use Cases - Failure Pattern Catalog: Covers thirteen anti-patterns including bare primitives, unproven scalars, free-floating vocabulary, mutable bags, nullable absence, open models, misbuilt unions, and after-validators. - Corrective Guidance: Each pattern pairs a violating code example with the correct construct, such as frozen RootModel scalars, discriminated unions, and reparameterized field relations. - Use Case: When reviewing a Pydantic model with email: str or settled_at: datetime | None, use this Skill to recognize the anti-pattern and refactor to a constrained RootModel scalar or a Settled/Unsettled union. ## Quick Start Review my Pydantic domain models for value-modeling anti-patterns and show me the correct construct for each violation.

Frequently Asked Questions about python-values-failure

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

FAQPage Schema
How do I model domain values correctly in Pydantic?▼

Model atomic domain values as frozen RootModel classes over one allowed primitive, carrying constraints on the root Field. Type fields as that scalar rather than the raw primitive so invalid values cannot be constructed at all.

How to replace Optional fields in Pydantic models?▼

Replace T | None fields with union variants named for what absence means, such as separate Settled and Unsettled variants. Absence is a state, not a slot modifier, so each state gets its own model shape.

Should I use model_validator after mode in Pydantic?▼

No, after-validators indicate something was left unmodeled. Move cross-field relations into reparameterized fields, single-field bounds onto the scalar's Field, and exactly-one-of constraints into discriminated unions.

When is it safe to access .root on a Pydantic RootModel?▼

Accessing .root is safe only when consumed immediately by a construction or at a wire edge like a route reply or client binding. Binding it to a name, operating on it arithmetically, or passing it to non-constructing calls drops the proof the scalar carried.

Why should Pydantic models use frozen and extra forbid?▼

ConfigDict(frozen=True, extra="forbid") makes a model a fixed, fully-described fact that cannot mutate after construction or silently absorb unmodeled fields. The only exception is the consistency model, which is the live state node.