typescript-best-practices

Enforce type-safe TypeScript code with interfaces, discriminated unions, and strict null checks.

54|1|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/rbarcante/claude-conductor --skill typescript-best-practices-rbarcante
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-best-practices
Source: https://github.com/rbarcante/claude-conductor/tree/main/skills/typescript-best-practices
Command: npx skills add https://github.com/rbarcante/claude-conductor --skill typescript-best-practices-rbarcante

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TypeScript projects often suffer from inconsistent type usage, unclear API contracts, and fragile codebases. This Skill provides a curated set of best practices to improve type safety, maintainability, and robustness across TypeScript code.

Core Features & Use Cases

  • Enforces strict type discipline: interfaces for object shapes, discriminated unions for variant states, and use of unknown instead of any.
  • Promotes robust async patterns: consistent error handling, explicit return types, and parallelization where appropriate.
  • Improves null safety and guards: strict null checks, optional chaining, nullish coalescing, and explicit guards.
  • Practical guidance for configuration and patterns: recommended tsconfig settings, type guards, utility types, and pattern examples.
  • Use Case: A large React frontend or Node backend can adopt these rules to reduce runtime errors and improve collaboration.

Quick Start

Audit a module for strict types, replace any with unknown, and add explicit return types to public APIs to begin applying the TypeScript Best Practices.

Frequently Asked Questions about typescript-best-practices

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

FAQPage Schema
What's the best way to enforce type safety in a TypeScript project?

Strict null checks in TypeScript prevent runtime errors by forcing explicit handling of nullable values. You can implement them using optional chaining and nullish coalescing operators, ensuring robust null safety and explicit guards across your codebase.

How do I handle async patterns and error handling in TypeScript?

To handle async patterns in TypeScript, apply consistent error handling, define explicit return types for async functions, and parallelize operations where appropriate. This ensures robust API contracts and maintainable internal utilities across frontend and backend code.

When do I need discriminated unions and type guards in TypeScript?

You need discriminated unions in TypeScript when modeling variant states, such as loading, success, and error responses. Combine these with explicit type guards to safely narrow types at runtime and enforce strict type discipline across your application.

What TypeScript configuration settings are recommended for strict type checking?

Recommended TypeScript configuration settings for strict type checking include enabling strict null checks and configuring the tsconfig to enforce explicit public APIs and explicit return types. These settings provide practical patterns to improve overall type safety and maintainability.

How do I audit an existing TypeScript module for type safety best practices?

To audit a TypeScript module for type safety, review its data structures and API contracts, replace 'any' with 'unknown', and add explicit return types to public APIs. This quick start approach immediately improves codebase robustness and maintainability.