What problem does it solve? Codebases accumulate runtime failures that the compiler could have prevented: contradictory field combinations, interchangeable primitive identifiers, unchecked casts, and non-exhaustive matches. This Skill provides a set of type system design patterns that shift those failures from runtime to compile time in any statically-typed language. ## Core Features & Use Cases - Illegal State Elimination: Model variants as sum types (sealed classes in Kotlin, discriminated unions in TypeScript, enums with payloads in Rust) instead of bags of optional fields. - Semantic Primitive Branding: Distinguish types like UserId and OrderId using value classes, newtypes, opaque types, or branded intersections so they cannot be swapped. - Boundary Parsing and Exhaustiveness: Parse untyped external data (JSON, RPC payloads, CLI args) at boundaries and enforce compiler-checked exhaustive matching on sum types. - Use Case: When reviewing a Kotlin data class with isComplete: Boolean and completedAt: Instant?, apply this Skill to refactor it into a sealed interface with Open and Done variants so contradictory states no longer compile. ## Quick Start Apply the type system discipline principle to review this function signature and refactor any types that admit illegal states.