Loading...
Loading...
TypeScript best practices. Use when reading or editing any .ts or .tsx file.
npx skill4agent add cursor/plugins typescript-best-practices| Rule | Summary |
|---|---|
| Discriminated unions | Model variants with a |
| Branded types | Brand primitives with |
| External data is |
No | Every |
| Narrowing hierarchy | Discriminant switch > |
| Type guards | Must verify the claim. A lying guard is worse than |
| Exhaustiveness | Inline |
| Validates the value without widening literal types. |
| Boundary validation | Validate where data crosses in; trust types inside. See the boundary-discipline principle skill. |
| Schema-derived types | Reach for |
| Object args | Pass objects, not positional, so argument order is self-documenting. Skip on hot paths (per-frame render, tokenizers, parsers). |
references/patterns.md