typescript

Enforce TypeScript best practices for type safety and maintainability.

Updated Aug 8, 2025
One-click install
npx skills add https://github.com/Albarracin-sg/MIS-DOTFILES --skill typescript-albarracin-sg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/Albarracin-sg/MIS-DOTFILES/tree/main/tools/opencode/skill/typescript
Command: npx skills add https://github.com/Albarracin-sg/MIS-DOTFILES --skill typescript-albarracin-sg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TypeScript codebases often suffer from inconsistent type usage, inline and ad-hoc interfaces, heavy reliance on any, and fragmented utility types. This skill provides a structured set of patterns to standardize type declarations, enforce safer patterns, and improve long-term maintainability.

Core Features & Use Cases

  • Const Types Pattern: Create a single runtime object and derive exact types for robust, type-safe value maps.
  • Flat Interfaces: Use one-level deep interfaces to keep types maintainable and reusable.
  • Avoid Any: Prefer unknown and generics for robust type safety across modules.
  • Utility Types & Guards: Use Pick, Omit, Partial, Required, Readonly, and type guards for precise API design.
  • Use Case: Refactor a legacy TS project to replace unions with a single source of truth, enabling safer refactors and better autocomplete.

Quick Start

Refactor a TypeScript module to implement a const-based status pattern and flatten interfaces for safer typing.

Frequently Asked Questions about typescript

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

FAQPage Schema
How do I enforce TypeScript best practices for type safety in a legacy codebase?

To enforce TypeScript type safety, you can refactor legacy code using const-based types, flat interfaces, and utility types. This avoids `any` and ensures safer refactors, better autocomplete, and improved long-term maintainability across your modules.

How do I use const-based types and flat interfaces to improve TypeScript code quality?

You can improve TypeScript code quality by creating a single runtime const object to derive exact types, and structuring interfaces one level deep. This pattern provides a single source of truth, enabling safer refactors and precise API design.

When should I use utility types and type guards instead of custom TypeScript interfaces?

Use utility types like Pick, Omit, Partial, Required, and Readonly alongside type guards instead of custom interfaces to achieve precise API design. This approach standardizes type declarations and prevents fragmented, ad-hoc type definitions.

Can I apply these TypeScript patterns to both frontend and backend projects?

Yes, these TypeScript patterns are applicable to both frontend and backend projects. They standardize type declarations and enforce safer patterns across diverse environments, guiding refactors, code reviews, and onboarding processes.

Why does avoiding `any` and preferring `unknown` matter for TypeScript generics?

Avoiding `any` and preferring `unknown` with generics matters because it enforces robust type safety across modules. This practice eliminates ad-hoc type usage and ensures that all type declarations are explicitly validated.

What are the limitations of relying on ad-hoc TypeScript interfaces and fragmented utility types?

Relying on ad-hoc interfaces and fragmented utility types leads to inconsistent type usage and poor maintainability. Standardizing with flat interfaces and const-based patterns avoids these limitations by establishing a single source of truth.