typescript-advanced-patterns

Encode advanced TypeScript type-system patterns to prevent runtime type errors.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/selrai-company/claude-workshop-kit --skill typescript-advanced-patterns-selrai-company
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: typescript-advanced-patterns
Source: https://github.com/selrai-company/claude-workshop-kit/tree/main/skills/typescript-advanced-patterns
Command: npx skills add https://github.com/selrai-company/claude-workshop-kit --skill typescript-advanced-patterns-selrai-company

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill eliminates classes of runtime errors by encoding domain constraints and invariants into the TypeScript type system so that incorrect usage is caught at compile time instead of in production.

Core Features & Use Cases

  • Branded nominal types to prevent mixing primitive values like IDs, currencies, and paths.
  • Discriminated unions and exhaustive-checking patterns for robust state machines and API results.
  • Advanced utilities: template literal types, conditional types with infer, the satisfies operator, const assertions, mapped types, and Zod schema inference for runtime validation.
  • Real-world use case: design a type-safe orders API with branded IDs, Zod-validated inputs, exhaustive handlers, and a typed event emitter to avoid integration bugs.

Quick Start

Create branded ID types, Zod schemas, and exhaustive discriminated unions for an orders API from the following field descriptions.

Frequently Asked Questions about typescript-advanced-patterns

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

FAQPage Schema
How do I use TypeScript types to catch runtime errors before production?▼

TypeScript exhaustive switch checking uses discriminated unions to guarantee all possible cases are handled. By leveraging this pattern, the compiler enforces that every state or API result variant is explicitly processed, preventing unhandled cases at runtime.

How do I create branded nominal types in TypeScript to prevent mixing primitive IDs?▼

Branded nominal types in TypeScript prevent mixing primitive values by tagging base types with unique identifiers. This pattern ensures that distinct domain values like IDs, currencies, and paths are structurally incompatible, catching misuse during compilation.

Can I use Zod schema inference to validate runtime inputs in a type-safe API?▼

Yes, Zod schema inference validates runtime inputs while automatically generating matching TypeScript types. This integrates runtime parsing with compile-time checks, ensuring that API inputs conform to domain models without manual type duplication.

What is the best way to build type-safe state machines using TypeScript conditional types?▼

The best way to build type-safe state machines is using discriminated unions alongside conditional types with infer. This approach models robust state transitions and API results, ensuring that invalid state changes fail at compile time.

Does TypeScript support template literal types and the satisfies operator for domain modeling?▼

TypeScript supports template literal types and the satisfies operator for domain modeling. These features allow you to enforce string format constraints and validate object shapes against expected types without widening the inferred type.