← ClaudeAtlas

strict-property-accesslisted

Enforce strict, schema-verified property access in all generated or edited code. Use this skill whenever writing, modifying, or reviewing code that accesses object properties, dict keys, API response fields, or config values — in any language. Especially triggers when the exact property name or data shape is uncertain, when mapping external data (API responses, JSON, DB rows) to internal types, or when tempted to write fallback chains like `obj.x or obj.X`, `data.get('a') or data.get('A')`, or `obj?.userId ?? obj?.user_id`. Also use when reviewing existing code for these patterns.
xs2tariqrasheed/strict-property-access · ★ 1 · Code & Development · score 64
Install: claude install-skill xs2tariqrasheed/strict-property-access
# Strict Property Access This codebase uses a typing system. Data shapes are knowable. Code must be predictable: every property access uses exactly one, verified name. Fallback property access ("property resolver" chains) is forbidden because it hides schema uncertainty inside runtime behavior instead of surfacing it to a human. ## Forbidden patterns Never generate code that tries multiple names/casings for the same value: ```python # ALL FORBIDDEN x = obj.x or obj.X user_id = data.get("userId") or data.get("user_id") or data.get("id") name = getattr(o, "name", None) or getattr(o, "Name", None) ``` ```typescript // ALL FORBIDDEN const id = obj.userId ?? obj.user_id; const name = res.name || res.Name || ""; const v = (obj as any)["x"] ?? (obj as any)["X"]; ``` Also forbidden in the same spirit: - Casting to `any` / using `# type: ignore` to dodge a property-name error - Silent defaulting that masks a missing required field (`data.get("id", "")`) - Normalizing keys speculatively (`{k.lower(): v for k, v in data.items()}`) just to avoid learning the real casing ## Required behavior instead Follow these steps in order. Stop at the first one that resolves the name. ### 1. Verify the schema before writing the access Look up the authoritative source of truth and use the exact name it defines: - Type definitions: TypeScript interfaces/types, Pydantic models, dataclasses, protobufs, ORM models, OpenAPI/GraphQL schemas - The function or endpoint that produces the object -