typescript-best-practices
Installation
SKILL.md
TypeScript best practices
Use when authoring .ts / .tsx, configuring tsconfig, or integrating Zod and generated API types.
Strictness
- Enable
strict(and related flags) project-wide; don’t carve outanysilos without a plan to remove them. - Prefer
unknownoveranyat boundaries; narrow with type guards or schemas.
Types vs runtime
- Zod (or similar) at IO boundaries (API, env, search params); infer TS types with
z.inferto avoid drift. - Don’t assume generated OpenAPI types are perfect; wrap or refine where the contract is loose.
Modules and imports
- Use
import typefor type-only imports when it helps bundlers and clarity. - Avoid circular imports; extract shared types or small modules to break cycles.