TypeScript Best Practices
February 20, 2026 ยท View on GitHub
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.
Install
Cursor / Claude Code / Windsurf
npx skills add ofershap/typescript-best-practices
Or copy skills/ into your .cursor/skills/ or .claude/skills/ directory.
What's Included
| 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 Agents Get Wrong
| 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 |
Related Plugins
- 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.
Author
License
MIT