TypeScript Best Practices

February 20, 2026 ยท View on GitHub

License: MIT Skills

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, use as instead of satisfies, 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

TypeNameDescription
Skilltypescript-best-practices13 rules for strict mode, satisfies, discriminated unions, branded types, NoInfer, and more
Rulebest-practicesAlways-on behavioral rule that enforces current TypeScript patterns
Command/auditScan your codebase for TypeScript anti-patterns

What Agents Get Wrong

What the agent writesWhat you should use
any for uncertain typesunknown with type narrowing
as SomeType to silence errorssatisfies SomeType for validation without widening
{ success?: Data; error?: string }Discriminated union with type field
strict: false in tsconfigstrict: true with proper null handling
import { SomeType }import type { SomeType } for type-only imports
TypeVar + Generic[T] patternsNoInfer<T>, const assertions, branded types

If this helped your workflow, a star helps others find it.

Author

Made by ofershap

LinkedIn GitHub

License

MIT