typescript-best-practices
Installation
SKILL.md
TypeScript Best Practices
Guidelines for writing clean, type-safe, and maintainable TypeScript code.
Note: If the repository has established code style conventions, follow those first. These guidelines serve as defaults.
Core Principles
- Type-First Design - Define types before implementation; minimize reliance on inference
- Interface for Structure - Use
interfacefor objects,typefor unions/mapped/conditional - Namespace for Type Organization - Group related types with namespaces (types only, not runtime)
- Generic Const for Strictness - Use
<const TConfig>for strict literal inference - Extract, Don't Redefine - Get types from existing definitions instead of duplicating
- Strictest Config - Use strictest tsconfig base; install
ts-resetfor saner built-in types