← ClaudeAtlas

coding-python-enforce-data-architecture-strictlisted

Use when refactoring or reviewing Python code to enforce a strict data architecture - Pydantic models at every external boundary, typed models (never raw dicts) inside the app, Enums for all fixed categorical values, and minimal input-to-output conversions. Use when asked to eliminate dict parameters, stringly-typed status/mode values, Model->dict->Model conversion chains, or compatibility shims, or to make a Python data flow type-safe end to end.
bitranox/bitranox-skills · ★ 1 · AI & Automation · score 57
Install: claude install-skill bitranox/bitranox-skills
# Data Architecture Enforcement Refactor Python code to follow strict data architecture rules using Pydantic models and Enums. > Pydantic-at-the-boundary is also the input-sanitization edge. For the full per-sink output escaping > (parametrized SQL, HTML autoescape, shell argv) and the boundary-vs-internal-libs scope, see > `bitranox:coding-input-sanitization`. --- ## Architecture Rules ### Core Principles 1. **Pydantic at Boundaries**: All external data (API requests, file reads, env vars, CLI args) must be parsed into Pydantic models immediately upon entry 2. **Pydantic for Export**: All outputs (API responses, file writes, serialization) must use Pydantic's `.model_dump()` or `.model_dump_json()` 3. **No Internal Dicts**: Inside the application, never use raw dicts for structured data - always typed models 4. **Enums for Constants**: All string literals representing categories, statuses, modes, or fixed values must be Enums. For values that cross an external boundary as strings, use `StrEnum` (Python 3.11+) or `class X(str, Enum)` so Pydantic parses and serializes them without changing the wire format; reserve `IntEnum` for values that are genuinely integers on the wire. **If your floor is 3.10 and you take the `class X(str, Enum)` fallback, its default string form is version-dependent** - read "The `str, Enum` fallback formats differently on 3.10 and 3.11+" below before you interpolate a member anywhere. 5. **Minimize Conversions**: Ideal flow is ONE parse at input,