typescript-patterns
Installation
SKILL.md
TypeScript patterns
Follow the repo's tsconfig and lint config. Rules that matter most:
- External data (HTTP, JSON.parse, env, storage, LLM output) is
unknownuntil parsed by the repo's schema library. Infer the type from the schema. - No
any,@ts-ignore, orascasts to silence errors. A cast is allowed only after a runtime check, with a comment naming it. - Model states as discriminated unions with an exhaustive
nevercheck, not optional fields. - Throw
Errorsubclasses, never strings. No emptycatch. No floating promises. - Add a generic parameter only when it relates two positions.
- Use
import typefor type-only imports. Noenum, no barrel files outside a package entry point. - Share one schema between client and server instead of redeclaring types.