typescript-refactor

TypeScript refactoring and modernization guidelines from a principal specialist perspective. This skill should be used when refactoring, reviewing, or…

INSTALLATION
npx skills add https://github.com/pproenca/dot-skills --skill typescript-refactor
Run in your project or agent environment. Adjust flags if your CLI version differs.

SKILL.md

TypeScript Refactor Best Practices

Comprehensive TypeScript refactoring and modernization guide designed for AI agents and LLMs. Contains 43 rules across 8 categories, prioritized by impact to guide automated refactoring, code review, and code generation.

When to Apply

Reference these guidelines when:

  • Refactoring TypeScript code for type safety and maintainability
  • Designing type architectures (discriminated unions, branded types, generics)
  • Narrowing types to eliminate unsafe as casts
  • Adopting modern TypeScript 4.x-5.x features (satisfies, using, const type parameters)
  • Optimizing compiler performance in large codebases
  • Implementing type-safe error handling patterns
  • Reviewing code for TypeScript quirks and pitfalls

Rule Categories by Priority

Priority

Category

Impact

Prefix

1

Type Architecture

CRITICAL

arch-

2

Type Narrowing & Guards

CRITICAL

narrow-

3

Modern TypeScript

HIGH

modern-

4

Generic Patterns

HIGH

generic-

5

Compiler Performance

MEDIUM-HIGH

compile-

6

Error Safety

MEDIUM

error-

7

Runtime Patterns

MEDIUM

perf-

8

Quirks & Pitfalls

LOW-MEDIUM

quirk-

Quick Reference

1. Type Architecture (CRITICAL)

  • arch-branded-types — Use branded types for domain identifiers to prevent value mix-ups

2. Type Narrowing & Guards (CRITICAL)

3. Modern TypeScript (HIGH)

4. Generic Patterns (HIGH)

5. Compiler Performance (MEDIUM-HIGH)

6. Error Safety (MEDIUM)

7. Runtime Patterns (MEDIUM)

8. Quirks & Pitfalls (LOW-MEDIUM)

How to Use

Read individual reference files for detailed explanations and code examples:

Reference Files

File

Description

references/_sections.md

Category definitions and ordering

assets/templates/_template.md

Template for new rules

metadata.json

Version and reference information

BrowserAct

Let your agent run on any real-world website

Bypass CAPTCHA & anti-bot for free. Start local, scale to cloud.

Explore BrowserAct Skills →

Stop writing automation&scrapers

Install the CLI. Run your first Skill in 30 seconds. Scale when you're ready.

Start free
free · no credit card