type-safety

Prevent mixing incompatible values with branded types and boundary parsing.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/aitchwhy/dotfiles --skill type-safety-aitchwhy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: type-safety
Source: https://github.com/aitchwhy/dotfiles/tree/main/config/quality/generated/skills/type-safety
Command: npx skills add https://github.com/aitchwhy/dotfiles --skill type-safety-aitchwhy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Prevents mixing incompatible values using branded types and boundary parsing.

Core Features & Use Cases

  • Branded IDs
  • Parse at boundary
  • Type-first development

Quick Start

Define branded types and parse at boundary.

Frequently Asked Questions about type-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent mixing incompatible values in TypeScript?

Branded types prevent mixing incompatible values by creating distinct type identities at compile time. Define a branded type with a unique symbol, then use boundary parsers to validate and transform inputs into branded domain objects, ensuring type safety across modules.

What's the best way to validate data at module boundaries in TypeScript?

Parse at boundary by decoding unknown inputs into fully typed domain objects using schema validation. This ensures all data crossing module edges matches your type contract, eliminating runtime type mismatches and mixing of incompatible identifiers.

Can I use branded types to create type-safe IDs in TypeScript?

Yes. Branded IDs use TypeScript's type system to distinguish between logically different identifiers—like UserID vs OrderID—even if both are strings. The compiler prevents accidental mixing while parsers at boundaries validate raw inputs into branded identifiers.

Do I need schema validation to adopt branded types?

Schema-driven workflows complement branded types by formalizing data contracts and validation rules. Combined with boundary parsing, schemas ensure inputs decode into properly typed domain objects, eliminating gaps between compile-time types and runtime guarantees.

When should I use branded types instead of structural typing?

Branded types create nominal identity, preventing accidental mixing of structurally identical but semantically distinct values. Use them when domain correctness depends on distinguishing between logically different types that share the same underlying representation.