typescript-best-practices

Apply TypeScript patterns and Zod runtime validation to data models and API integrations.

9|2|Updated Jan 29, 2026
One-click install
npx skills add https://github.com/stephanj/claude-code-collections --skill typescript-best-practices-stephanj
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-best-practices
Source: https://github.com/stephanj/claude-code-collections/tree/main/skills/typescript-best-practices
Command: npx skills add https://github.com/stephanj/claude-code-collections --skill typescript-best-practices-stephanj

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses the common pitfalls in TypeScript development, such as loose typing, unhandled runtime errors, and inconsistent module structures, which lead to fragile and hard-to-maintain codebases.

Core Features & Use Cases

  • Type-First Architecture: Provides patterns for discriminated unions, branded types, and exhaustive switch checks to make illegal states unrepresentable.
  • Runtime Validation: Integrates Zod schemas as a single source of truth for data validation at trust boundaries.
  • Use Case: Use this skill when refactoring a legacy module to ensure that all possible states are handled at compile time and that external API responses are strictly validated before entering your application logic.

Quick Start

Apply the typescript-best-practices skill to analyze the current file and suggest improvements for type safety and runtime validation.

Frequently Asked Questions about typescript-best-practices

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

FAQPage Schema
How do I enforce type safety and runtime validation in TypeScript?

TypeScript type safety and runtime validation are enforced by applying discriminated unions for exhaustive state handling and integrating Zod schemas as a single source of truth to validate data at trust boundaries.

What is the best way to validate external API responses in a full-stack TypeScript application?

The best way to validate external API responses in full-stack TypeScript is using Zod schemas as a single source of truth, strictly validating data before it enters your application logic to prevent unhandled runtime errors.

How do I make illegal states unrepresentable in TypeScript?

Make illegal states unrepresentable in TypeScript by using type-first architecture patterns such as discriminated unions, branded types, and exhaustive switch checks to eliminate loose typing and unhandled states.

Can I use Zod for runtime validation in legacy TypeScript codebases?

Yes, you can use Zod for runtime validation in legacy TypeScript codebases by refactoring modules to integrate Zod schemas at trust boundaries, ensuring all possible states are handled at compile time.

When do I need strict mode compliance and immutable functional programming in TypeScript?

You need strict mode compliance and immutable functional programming in TypeScript when designing data models and API integration layers in full-stack applications to prevent fragile and hard-to-maintain codebases.