type-definition
OfficialEncode business rules, prevent invalid states.
Software Engineering#type safety#typescript#domain modeling#discriminated unions#branded types#smart constructors#type-level programming
Authorsite-bender
Version1.0.0
Installs0
System Documentation
What problem does it solve?
This Skill elevates type definitions from mere data descriptions to powerful design tools that enforce business rules and prevent invalid states at compile time. It reduces runtime errors and improves code reliability by making constraints explicit in the type system, ensuring your data is always valid.
Core Features & Use Cases
- Branded Types (Newtypes): Guides the creation of types that carry semantic meaning and enforce specific constraints (e.g.,
EmailAddressinstead of juststring). - Discriminated Unions: Provides patterns for modeling complex states and ensuring exhaustive checking, ideal for state machines and error types.
- Smart Constructors & Type Predicates: Ensures that branded types are created safely and can be reliably narrowed at runtime.
- Use Case: Instead of using a plain
stringfor a user's ID, use this skill to define aUserIdbranded type. Then, create a smart constructormakeUserIdthat validates the string format. This ensures that only valid user IDs can exist in your system, preventing bugs related to malformed identifiers.
Quick Start
Generate a new branded type named 'PositiveNumber' based on 'number'.
Dependency Matrix
Required Modules
None requiredComponents
scripts
💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: type-definition Download link: https://github.com/site-bender/sitebender/archive/main.zip#type-definition Please download this .zip file, extract it, and install it in the .claude/skills/ directory.