coding-python-enforce-data-architecture-strict

Refactors Python code to enforce Pydantic models at boundaries, Enums for categorical values, and minimal conversions.

1|Updated Jun 23, 2026
One-click install
npx skills add https://github.com/bitranox/bitranox-skills --skill coding-python-enforce-data-architecture-strict-bitranox
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: coding-python-enforce-data-architecture-strict
Source: https://github.com/bitranox/bitranox-skills/tree/main/plugins/bitranox/skills/coding-python-enforce-data-architecture-strict
Command: npx skills add https://github.com/bitranox/bitranox-skills --skill coding-python-enforce-data-architecture-strict-bitranox

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Python codebases accumulate stringly-typed values, raw dict parameters, and redundant Model-to-dict-to-Model conversion chains that defeat type checking and hide bugs. This Skill drives an iterative, verified refactoring loop that eliminates those violations until the data flow is type-safe end to end. ## Core Features & Use Cases - Strict architecture rules: Pydantic models parsed at every external boundary, typed models (never raw dicts) internally, StrEnum/Enum for all fixed categorical values, and no compatibility shims. - Iterative violation loop: Parallel subagent analysis and refactoring tracked in a .data_arch_violations.json state file, repeating until zero violations remain, then running the project's test and type-check gates. - Documented Pydantic and Enum traps: Covers the str, Enum formatting difference between Python 3.10 and 3.11+, bare BaseModel fields serializing as {}, discriminated unions tagged with Literal[Enum.MEMBER], and defining types instead of suppressing pyright/mypy diagnostics. - Use Case: Given a service where handlers accept dict parameters and compare status == "active", the Skill converts inputs to Pydantic models at the boundary, replaces literals with StrEnum members, removes conversion chains, and loops until tests and the type checker pass. ## Quick Start Ask the AI to refactor this Python module to enforce strict data architecture with Pydantic models at the boundaries and Enums for all status values.

Frequently Asked Questions about coding-python-enforce-data-architecture-strict

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

FAQPage Schema
How do I eliminate dict parameters from Python functions?▼

Parse external input into a Pydantic BaseModel at the system boundary, then pass that typed model through every function instead of a dict. The Skill's loop flags every `: dict` and `-> dict` signature and each `data["key"]` access as a violation to fix.

Should I use StrEnum or IntEnum for status values in Pydantic?▼

Use StrEnum (or `class X(str, Enum)` on Python 3.10) for values that cross a boundary as strings, and reserve IntEnum for values that are genuinely integers on the wire. Pydantic then parses and serializes the enum without changing the wire format.

Why does my Pydantic field serialize as an empty object?▼

A field annotated as the bare BaseModel class serializes by its declared type, which has no fields, so model_dump emits {} regardless of the runtime subclass instance. Fix it with SerializeAsAny[BaseModel] or by dumping the payload explicitly at the output boundary.

Does the str, Enum fallback behave the same on Python 3.10 and 3.11?▼

No. On 3.10, f-string interpolation of a `str, Enum` member yields the value, but on 3.11+ it yields the member name like `C.A`. Use `.value` for any string interpolation under the fallback, or use StrEnum which is consistent on every version.

How do I handle pyright strict errors from third-party stub gaps?▼

Define the missing types rather than suppressing the diagnostic: add the real annotation, or wrap the partially-typed library in a typed Protocol facade with a cast. Reserve a narrow, rule-specific `# pyright: ignore[rule]` with a documented reason as the last resort.

When should I use a dataclass instead of a Pydantic model?▼

Use @dataclass only for pure internal logic with no serialization or validation needs. If code converts Pydantic to dataclass and back, eliminate the dataclass and use Pydantic throughout to keep conversions to one parse at input and one dump at output.