TypeScript Senior Patterns

Enforce production-grade TypeScript patterns for type safety and maintainability.

Updated Jan 26, 2026
One-click install
npx skills add https://github.com/theofernandezz/ai-library --skill typescript-senior-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: TypeScript Senior Patterns
Source: https://github.com/theofernandezz/ai-library/tree/main/.opencode/skills/generic/typescript
Command: npx skills add https://github.com/theofernandezz/ai-library --skill typescript-senior-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TypeScript projects often drift into unsafe patterns that undermine maintainability. This skill enforces production-grade TypeScript patterns to bolster type safety, readability, and long-term reliability.

Core Features & Use Cases

  • Prohibits dangerous patterns such as using any, defaulting to enums inappropriately, or relying on namespaces.
  • Encourages robust type design through flat interfaces, const assertions, discriminated unions, utility types, and generics with constraints.
  • Use cases include auditing codebases, guiding new projects, and maintaining consistent typing across API layers, data models, and business logic.

Quick Start

Apply this skill to enforce production-grade TypeScript patterns across your TypeScript projects.

Frequently Asked Questions about TypeScript Senior Patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce type safety and avoid using any in a TypeScript codebase?

Enforcing type safety and avoiding any in TypeScript requires prohibiting unsafe patterns and adopting robust alternatives like flat interfaces, const assertions, and discriminated unions. This approach ensures long-term maintainability and prevents type drift across your project.

What is the best way to use TypeScript generics with constraints for API layers?

Using TypeScript generics with constraints for API layers involves pairing them with utility types to enforce strict type inference. This combination guarantees that data models remain type-safe, predictable, and maintainable across your application boundaries.

Does this approach to TypeScript patterns work for existing backend and UI projects?

Yes, these production-grade TypeScript patterns are applicable to both new and existing projects, including backend and UI environments. You can audit existing codebases to replace forbidden patterns like namespaces and enums with discriminated unions and const assertions effectively.

Why should I avoid enums and namespaces in TypeScript data models?

You should avoid enums and namespaces in TypeScript data models because they undermine type safety and readability. Replacing them with const assertions and discriminated unions promotes proper type inference and ensures more maintainable, production-grade code.

How do I implement proper null safety and discriminated unions in TypeScript?

Implementing proper null safety and discriminated unions in TypeScript requires enforcing flat interfaces and utilizing utility types. These patterns guide type inference correctly, ensuring that null values are handled safely across business logic and utility libraries.