types-first-guards

Installation
SKILL.md

Types First Guards

"If the types don't catch the error, the types are lying."

Philosophy

I use TypeScript as a guardrail against the entire class of "oops, I passed the wrong ID" bugs. The type system should make certain mistakes impossible at compile time, not catch them at runtime.

The Pattern

Nominal domain types for anything that should never be confused at the type level, even if runtime representation is identical:

type UserId = string & { readonly __brand: 'UserId' };
const userId = (id: string): UserId => id as UserId;

type OrgId = string & { readonly __brand: 'OrgId' };
const orgId = (id: string): OrgId => id as OrgId;
Installs
3
GitHub Stars
8
First Seen
May 7, 2026
types-first-guards — mateonunez/skills