Modern TypeScript 5.x patterns your AI agent should use. Strict mode, discriminated unions,
satisfies operator, const assertions, branded types, NoInfer, using, and type-safe patterns.
AI coding assistants default to
any, skip strict mode, useasinstead ofsatisfies, and model states with optional fields instead of discriminated unions. This plugin enforces the patterns that make TypeScript worth using.
npx skills add ofershap/typescript-best-practicesOr copy skills/ into your .cursor/skills/ or .claude/skills/ directory.
| Type | Name | Description |
|---|---|---|
| Skill | typescript-best-practices |
13 rules for strict mode, satisfies, discriminated unions, branded types, NoInfer, and more |
| Rule | best-practices |
Always-on behavioral rule that enforces current TypeScript patterns |
| Command | /audit |
Scan your codebase for TypeScript anti-patterns |
| What the agent writes | What you should use |
|---|---|
any for uncertain types |
unknown with type narrowing |
as SomeType to silence errors |
satisfies SomeType for validation without widening |
{ success?: Data; error?: string } |
Discriminated union with type field |
strict: false in tsconfig |
strict: true with proper null handling |
import { SomeType } |
import type { SomeType } for type-only imports |
TypeVar + Generic[T] patterns |
NoInfer<T>, const assertions, branded types |
- tailwind-best-practices - Tailwind CSS v4 patterns
- drizzle-best-practices - Type-safe Drizzle ORM patterns
- python-best-practices - Modern Python 3.12+ type hints and patterns
If this helped your workflow, a star helps others find it.
MIT