typescript-patterns

Apply TypeScript 5.x patterns for type safety and Zod validation.

3|Updated Jan 29, 2026
One-click install
npx skills add https://github.com/peopleforrester/claude-dotfiles --skill typescript-patterns-peopleforrester
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-patterns
Source: https://github.com/peopleforrester/claude-dotfiles/tree/main/skills/patterns/typescript-patterns
Command: npx skills add https://github.com/peopleforrester/claude-dotfiles --skill typescript-patterns-peopleforrester

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill consolidates modern TypeScript 5.x patterns, best practices, and idioms to help developers write safer, more maintainable code and to spot common pattern anti-patterns in code reviews.

Core Features & Use Cases

  • Discriminated unions and branded types patterns to improve type safety across complex domains.
  • Utility types and type-level tricks to express constraints, improve ergonomics, and reduce boilerplate.
  • Runtime validation with Zod to enforce schemas at boundaries and during data ingestion.
  • Guidance for strict mode configuration to ensure robust compilation and predictable behavior.
  • Use case: Review a TS module to replace ad-hoc types with discriminated unions and branded IDs.

Quick Start

To begin using these patterns, review the examples and apply them to a small TS module, then run your TypeScript compiler with strict mode enabled to observe type-safety improvements.

Frequently Asked Questions about typescript-patterns

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

FAQPage Schema
How do I use discriminated unions and branded types to improve TypeScript type safety?

Discriminated unions and branded types improve TypeScript type safety by enforcing strict domain constraints and exhaustive checks. You apply these patterns to replace ad-hoc types, ensuring predictable behavior and preventing invalid state combinations across complex modules.

What is the best way to enforce runtime validation in a TypeScript codebase?

The best way to enforce runtime validation in TypeScript is using Zod schemas at boundaries and during data ingestion. This approach ensures parsed data matches expected types, bridging the gap between compile-time type safety and unpredictable external inputs.

How do I configure strict mode in TypeScript 5.x for robust compilation?

Configuring strict mode in TypeScript 5.x involves enabling strict flags in your compiler options to enforce robust compilation. This provides clear type-guidance references and predictable behavior by catching pattern anti-patterns during code reviews.

Does TypeScript support utility types for reducing boilerplate in complex modules?

TypeScript supports utility types and type-level tricks to express constraints and reduce boilerplate. By applying these built-in utilities, you can improve ergonomics across your codebase and easily spot common pattern anti-patterns during development.

When do I need Zod schema validation versus standard TypeScript types?

You need Zod schema validation when enforcing schemas at boundaries and during data ingestion, whereas standard TypeScript types only provide compile-time safety. Zod bridges runtime validation and type-guidance, ensuring robust compilation when external data enters your system.

Why should I replace ad-hoc types with discriminated unions during code reviews?

Replacing ad-hoc types with discriminated unions during code reviews improves type safety and maintainability across complex domains. This pattern-based design enforces strict mode predictability and eliminates common anti-patterns found in loosely structured TypeScript modules.