typescript-refactor

Identify and fix type-safety issues across a TypeScript codebase.

Updated Apr 27, 2026
One-click install
npx skills add https://github.com/Immanuel-Aristotle/agents --skill typescript-refactor-immanuel-aristotle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-refactor
Source: https://github.com/Immanuel-Aristotle/agents/tree/main/skills/typescript-refactor
Command: npx skills add https://github.com/Immanuel-Aristotle/agents --skill typescript-refactor-immanuel-aristotle

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) and references (resource) components.

What problem does it solve?

TypeScript refactor guidelines help teams systematically improve type safety, readability, and maintainability during code modernization, reducing runtime errors and compiler overhead.

Core Features & Use Cases

  • Guidelines for Type Architecture, Type Narrowing, and Generics to promote safer refactors.
  • Patterns for error handling, discriminated unions, and migrating to modern TS features (satisfies, as const, template literal types).
  • Real-world scenarios: migrating legacy TS modules to modern idioms, improving code reviews and automated refactoring tasks.

Quick Start

Provide a TypeScript file and ask the AI to apply the refactor guidelines to produce a modern, type-safe version.

Frequently Asked Questions about typescript-refactor

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

FAQPage Schema
How do I refactor TypeScript code to improve type safety and compiler performance?

TypeScript refactoring improves type safety by systematically tightening type architectures, narrowing, and generics while preserving runtime behavior and reducing compiler overhead. You modernize legacy modules by applying patterns for discriminated unions and idiomatic type usage.

What are the best patterns for migrating legacy TypeScript to modern type-safe idioms?

Modern TypeScript migration patterns utilize features like satisfies, as const, and template literal types to enforce strong type-safety guarantees. These patterns help restructure error handling and type architecture during codebase modernization without altering runtime behavior.

How does type narrowing work when restructuring TypeScript generics?

Type narrowing in TypeScript generics refactoring involves tightening type architectures to distinguish specific types within a broader scope. This process applies discriminated unions and narrowing guidelines to ensure safer refactors across medium to large codebases.

Can I apply TypeScript refactor guidelines to a large codebase without breaking runtime behavior?

Yes, TypeScript refactoring guidelines are designed for medium to large codebases and explicitly require preserving runtime behavior. The focus remains on improving compiler performance and idiomatic usage while maintaining strong type-safety guarantees.

When should I use the satisfies operator during a TypeScript type architecture refactor?

Use the satisfies operator during TypeScript refactoring to ensure an object matches a specific type without widening it, preserving literal types for stronger type-safety. It is a modern TypeScript feature ideal for migrating legacy modules to safer idioms.

Why does TypeScript compiler performance degrade in large codebases and how can refactoring help?

TypeScript compiler performance degrades when type architectures are overly complex or lack proper narrowing and generics. Refactoring tightens these type structures and applies modern idioms, reducing compiler overhead while maintaining strong type-safety guarantees.