typescript-best-practices

Installation
Summary

TypeScript patterns for type-first development, making illegal states unrepresentable, and exhaustive handling.

  • Use discriminated unions, branded types, and const assertions to encode business rules in the type system and prevent invalid states at compile time
  • Validate at system boundaries with Zod schemas as single source of truth; infer TypeScript types automatically to keep types and validation in sync
  • Enforce exhaustive handling with never checks in switch statements and default cases; unhandled code paths become compile errors
  • Wrap external calls and async operations with contextual error messages; propagate failures rather than silently catching them
  • Load and validate configuration at startup with Zod; access typed config object throughout the codebase instead of process.env directly
SKILL.md

TypeScript Best Practices

Follows type-first, functional, and error handling patterns from CLAUDE.md. This skill covers language-specific idioms only.

Pair with React Best Practices

When working with React components (.tsx, .jsx files or @react imports), always load react-best-practices alongside this skill. This skill covers TypeScript fundamentals; React-specific patterns (effects, hooks, refs, component design) are in the dedicated React skill.

Make Illegal States Unrepresentable

Use the type system to prevent invalid states at compile time.

Related skills
Installs
2.1K
GitHub Stars
47
First Seen
Jan 20, 2026