unify-types

Unify near-identical TypeScript interfaces and union types into single variants.

Updated Jul 17, 2017
One-click install
npx skills add https://github.com/luyi985/lyi-bash --skill unify-types
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unify-types
Source: https://github.com/luyi985/lyi-bash/tree/main/ai/skills/unify-types
Command: npx skills add https://github.com/luyi985/lyi-bash --skill unify-types

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Small differences between almost-identical types can balloon maintenance and duplicate logic. This Skill promotes unifying such types to simplify modeling and reduce boilerplate.

Core Features & Use Cases

  • Unifies interfaces or types that differ by only one or two properties.
  • Reduces parallel type hierarchies and repeated narrowing logic.
  • Helps keep APIs and data models coherent while preserving explicit semantics.

Quick Start

Refactor two near-identical types into a single unified type with clear variant indicators where differences matter.

Frequently Asked Questions about unify-types

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

FAQPage Schema
How do I unify similar TypeScript interfaces that differ by only one or two properties?

Unify similar TypeScript interfaces by refactoring them into a single interface containing common fields and explicit variant indicators for differences, which eliminates duplicate type definitions and reduces maintenance overhead.

Why does my TypeScript codebase have so much repeated narrowing logic for union types?

Repeated narrowing logic often occurs when union types are mostly identical but modeled separately. Unifying these types into a single coherent model with clear variant fields reduces parallel type hierarchies and eliminates redundant narrowing.

What is the best way to reduce type duplication across APIs and data models in TypeScript?

Reduce type duplication by consolidating near-identical data models into a single unified type with clearly defined variant indicators, which keeps APIs coherent while preserving explicit semantic differences.

How do I refactor TypeScript types without losing explicit semantics for domain logic?

Refactor TypeScript types by merging shared properties into a base structure and applying variant indicators for divergent fields. This preserves domain logic semantics while actively reducing boilerplate and parallel hierarchies.

When should I not unify similar types in my data modeling?

You should not unify similar types when structural or semantic differences between the types are fundamental. In these cases, carefully justified separation is required instead of forcing a single unified interface.