typescript-best-practices

Apply TypeScript patterns with Zod for type-first development and runtime validation.

Updated Jan 26, 2026
One-click install
npx skills add https://github.com/shelbeely/ADHD-Closet --skill typescript-best-practices-shelbeely
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-best-practices
Source: https://github.com/shelbeely/ADHD-Closet/tree/main/.agents/skills/typescript-best-practices
Command: npx skills add https://github.com/shelbeely/ADHD-Closet --skill typescript-best-practices-shelbeely

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill enforces rigorous TypeScript patterns to prevent bugs at compile time, ensuring code is maintainable, predictable, and less prone to runtime errors.

Core Features & Use Cases

  • Type-First Development: Emphasizes defining types and interfaces before implementation.
  • Error Prevention: Utilizes discriminated unions, branded types, and const assertions to make illegal states unrepresentable.
  • Runtime Validation: Integrates Zod for robust schema definition and data validation at API boundaries.
  • Use Case: When refactoring a complex JavaScript module to TypeScript, use this Skill to guide the process, ensuring all new types are correctly defined and validated, and that the code adheres to best practices for functional programming and error handling.

Quick Start

Apply the typescript-best-practices skill to refactor the provided JavaScript code into a type-safe TypeScript module.

Frequently Asked Questions about typescript-best-practices

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

FAQPage Schema
How do I make illegal states unrepresentable in TypeScript?

To make illegal states unrepresentable in TypeScript, use discriminated unions, branded types, and const assertions to enforce rigorous compile-time type safety and prevent invalid state combinations.

What is the best way to refactor JavaScript to type-safe TypeScript?

Refactoring JavaScript to type-safe TypeScript requires a type-first development approach, defining interfaces before implementation, and integrating Zod for robust runtime validation at API boundaries.

How does Zod validation work with TypeScript for API boundaries?

Zod validation integrates with TypeScript by defining robust schemas that validate runtime data at API boundaries, ensuring incoming data matches expected types and preventing unpredictable runtime errors.

When do I need runtime validation in a TypeScript codebase?

You need runtime validation in a TypeScript codebase when handling external API data, utilizing Zod schema definitions to ensure unpredictable runtime inputs match your compile-time type definitions.

What TypeScript patterns ensure exhaustive handling of states?

Exhaustive handling of states in TypeScript is ensured by applying discriminated unions and type-first development patterns, which guide the creation of robust, maintainable, and error-resistant codebases.

Does TypeScript type safety prevent all runtime errors?

TypeScript type safety prevents many compile-time bugs by making illegal states unrepresentable, but runtime validation with Zod is still required for external data to eliminate unpredictable runtime errors completely.