type-definition

Official

Encode business rules, prevent invalid states.

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., EmailAddress instead of just string).
  • 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 string for a user's ID, use this skill to define a UserId branded type. Then, create a smart constructor makeUserId that 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 required

Components

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.
View Source Repository