What problem does it solve? TypeScript codebases often accumulate unsafe patterns like any, unchecked as casts, and loose types that let invalid states compile, leading to runtime crashes that the compiler should have caught. ## Core Features & Use Cases - Type Modeling Rules: Enforces discriminated unions, branded types, and constructive modeling so impossible states cannot be represented in .ts and .tsx files. - Safe Narrowing Guidance: Provides a narrowing hierarchy from discriminant switches down to validated as casts, plus exhaustiveness checks with never assignments. - Boundary Validation: Directs parsing of external data as unknown at system boundaries into named domain types, with schema-derived types via Pick, Omit, and Parameters. - Use Case: When refactoring a module that parses JSON-RPC payloads, apply this Skill to replace any and as casts with validated parse functions and discriminated union state types. ## Quick Start Review this TypeScript file and refactor it to follow the typescript-best-practices rules, replacing any unsafe casts with validated narrowing.