What problem does it solve?
Codebases accumulate runtime failures that the compiler could have prevented: contradictory optional fields, interchangeable primitive IDs, unchecked casts, and non-exhaustive matches. This Skill provides a set of type design principles that shift those errors from runtime to compile time in any statically-typed language.
Core Features & Use Cases
- Illegal State Elimination: Model variants as sum types (discriminated unions, enums with payloads, sealed classes) instead of bags of optional fields.
- Semantic Primitive Branding: Distinguish types like UserId and OrderId using newtypes, opaque types, or branded intersections so they cannot be mixed up.
- Boundary Parsing and Exhaustiveness: Parse external data (JSON, RPC, env vars) into typed models at boundaries and enforce exhaustive matching so new variants break compilation.
- Use Case: When reviewing a function signature like
{ completed: boolean; completedAt?: Date }, apply the Skill to remodel it as { kind: 'open' } | { kind: 'done'; at: Date } so contradictory states cannot compile.
Quick Start
Ask the agent to review this type definition and function signature using the type system discipline principles and suggest how to make illegal states unrepresentable.