Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
pproenca avatar

Typescript Refactor

  • 649 installs
  • 186 repo stars
  • Updated July 24, 2026
  • pproenca/dot-skills

typescript-refactor is a Claude Code skill that applies 47 prioritized TypeScript 6.0 and React 19 TSX modernization rules—from type architecture through compiler performance—for developers who need to harden legacy or f

About

typescript-refactor is a version 1.2.0 agent skill from pproenca/dot-skills that encodes 47 prioritized rules across 9 categories for TypeScript 6.0 and React 19 TSX. Each rule includes an explanation, a production-realistic example, and an authoritative reference, ordered from critical type architecture and narrowing to incremental quirks. It covers modern features such as satisfies, using, const type parameters, inferred type predicates, isolatedDeclarations, erasable syntax, and import attributes. Developers reach for typescript-refactor when an AI agent is refactoring components, tightening types, or migrating patterns without guessing at compiler-level best practices. The skill is designed for AI agents and LLMs acting as a TypeScript principal specialist during code modernization sessions.

  • 47 rules across 9 categories prioritized from critical type architecture to incremental pitfalls
  • TypeScript 6.0 coverage: satisfies, using, const type parameters, inferred predicates, isolatedDeclarations
  • React 19 / TSX: ref-as-prop, ComponentProps, discriminated props, synthetic events
  • Compiler-performance guidance including interfaces-over-intersections (CRITICAL rule)
  • Production-realistic examples and authoritative references per rule

Typescript Refactor by the numbers

  • 649 all-time installs (skills.sh)
  • Ranked #205 of 1,356 Code Review & Quality skills by installs in the Skillselion catalog
  • Security screen: MEDIUM risk (skills.sh audit)
  • Data as of Jul 31, 2026 (Skillselion catalog sync)
npx skills add https://github.com/pproenca/dot-skills --skill typescript-refactor

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs649
repo stars186
Security audit3 / 3 scanners passed
Last updatedJuly 24, 2026
Repositorypproenca/dot-skills

How do you modernize TypeScript React code with prioritized refactor rules?

Modernize and harden TypeScript and React 19 TSX code using 47 prioritized rules from type architecture through compiler performance.

Who is it for?

Frontend and full-stack developers maintaining TypeScript 6.0 or React 19 codebases who want agent-driven refactors grounded in 47 ordered rules instead of ad hoc style fixes.

Skip if: Greenfield projects with no TypeScript debt, teams that only need ESLint formatting, or backends with no TSX or React surface area.

When should I use this skill?

A developer asks to modernize, harden, or refactor TypeScript or React 19 TSX and wants rule-backed changes across types, narrowing, or compiler performance.

What you get

Prioritized refactor guidance, typed TSX examples, and rule-by-rule references aligned to TypeScript 6.0 and React 19.

  • Rule-guided TSX refactors
  • Modernized type patterns
  • Referenced examples per rule

By the numbers

  • 47 prioritized rules across 9 categories
  • Targets TypeScript 6.0 and React 19 TSX
  • Skill version 1.2.0 (May 2026)

Files

SKILL.mdMarkdownGitHub ↗

TypeScript Refactor Best Practices

Comprehensive TypeScript and TSX refactoring and modernization guide designed for AI agents and LLMs. Contains 47 rules across 9 categories, prioritized by impact to guide automated refactoring, code review, and code generation. Current to TypeScript 6.0 and React 19.

When to Apply

Reference these guidelines when:

  • Refactoring TypeScript or React/TSX code for type safety and maintainability
  • Designing type architectures (discriminated unions, branded types, generics)
  • Narrowing types to eliminate unsafe as casts
  • Typing React components and hooks (props, refs, events, state) in .tsx files
  • Adopting modern TypeScript 5.x–6.0 features (satisfies, using, const type parameters, inferred type predicates, erasable syntax, with import attributes)
  • Optimizing compiler performance in large codebases (isolatedDeclarations, project references)
  • Implementing type-safe error handling patterns
  • Reviewing code for TypeScript quirks and pitfalls

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Type ArchitectureCRITICALarch-
2Type Narrowing & GuardsCRITICALnarrow-
3Modern TypeScriptHIGHmodern-
4React & TSXHIGHtsx-
5Generic PatternsHIGHgeneric-
6Compiler PerformanceMEDIUM-HIGHcompile-
7Error SafetyMEDIUMerror-
8Runtime PatternsMEDIUMperf-
9Quirks & PitfallsLOW-MEDIUMquirk-

Quick Reference

1. Type Architecture (CRITICAL)

  • `arch-discriminated-unions` — Use discriminated unions over string enums for exhaustive pattern matching
  • `arch-branded-types` — Use branded types for domain identifiers to prevent value mix-ups
  • `arch-satisfies-over-annotation` — Use satisfies for config objects to preserve literal types
  • `arch-interfaces-over-intersections` — Extend interfaces instead of intersecting types for better error messages
  • `arch-const-assertion` — Use as const for immutable literal inference
  • `arch-readonly-by-default` — Default to readonly types for function parameters and return values
  • `arch-avoid-partial-abuse` — Avoid Partial<T> abuse for builder patterns

2. Type Narrowing & Guards (CRITICAL)

  • `narrow-custom-type-guards` — Replace as with runtime-checked guards; TS 5.5+ infers the predicate
  • `narrow-assertion-functions` — Use assertion functions for precondition checks
  • `narrow-exhaustive-switch` — Enforce exhaustive switch with never
  • `narrow-in-operator` — Narrow with the in operator for interface unions
  • `narrow-eliminate-as-casts` — Eliminate as casts with proper narrowing chains

3. Modern TypeScript (HIGH)

  • `modern-using-keyword` — Use the using keyword for resource cleanup
  • `modern-const-type-parameters` — Use const type parameters for literal inference
  • `modern-template-literal-types` — Use template literal types for string patterns
  • `modern-noinfer-utility` — Use NoInfer to control type parameter inference
  • `modern-verbatim-module-syntax` — Enable verbatimModuleSyntax for explicit import types
  • `modern-erasable-syntax` — Prefer erasable syntax over enums and namespaces for type-stripping
  • `modern-import-attributes` — Use with import attributes instead of deprecated assert

4. React & TSX (HIGH)

  • `tsx-avoid-react-fc` — Type props directly instead of React.FC
  • `tsx-ref-as-prop` — Pass ref as a prop instead of forwardRef (React 19)
  • `tsx-extend-native-props` — Extend native element props with ComponentPropsWithRef instead of redeclaring them
  • `tsx-discriminated-props` — Model mutually-exclusive props as discriminated unions
  • `tsx-event-handler-types` — Type event handlers with React synthetic event types
  • `tsx-hook-typing` — Type useState/useRef for nullable and mutable state

5. Generic Patterns (HIGH)

  • `generic-constrain-dont-overconstrain` — Constrain generics minimally
  • `generic-avoid-distributive-surprises` — Control distributive conditional types
  • `generic-mapped-type-utilities` — Build custom mapped types for repeated transformations
  • `generic-return-type-inference` — Preserve return type inference in generic functions

6. Compiler Performance (MEDIUM-HIGH)

  • `compile-explicit-return-types` — Add explicit return types to exported functions
  • `compile-avoid-deep-recursion` — Avoid deeply recursive type definitions
  • `compile-project-references` — Use project references for monorepo builds
  • `compile-base-types-over-unions` — Use base types instead of large union types
  • `compile-isolated-declarations` — Enable isolatedDeclarations for parallel declaration emit

7. Error Safety (MEDIUM)

  • `error-result-type` — Use Result types instead of thrown exceptions
  • `error-exhaustive-error-handling` — Use exhaustive checks for typed error variants
  • `error-typed-catch` — Type catch clause variables as unknown
  • `error-discriminated-error-unions` — Model domain errors as discriminated unions

8. Runtime Patterns (MEDIUM)

  • `perf-union-literals-over-enums` — Use union literals instead of enums — enums are non-erasable
  • `perf-avoid-delete-operator` — Avoid the delete operator on objects
  • `perf-object-freeze-const` — Use Object.freeze with as const for true immutability
  • `perf-object-keys-narrowing` — Avoid Object.keys type widening
  • `perf-map-set-over-object` — Use Map and Set over plain objects for dynamic collections

9. Quirks & Pitfalls (LOW-MEDIUM)

  • `quirk-excess-property-checks` — Understand excess property checks on object literals
  • `quirk-empty-object-type` — Avoid the {} type — it means non-nullish
  • `quirk-structural-typing-escapes` — Guard against structural typing escape hatches
  • `quirk-variance-annotations` — Use variance annotations to document generic intent (not for speed)

How to Use

Read individual reference files for detailed explanations and code examples:

  • Section definitions — Category structure and impact levels
  • Rule template — Template for adding new rules

Reference Files

FileDescription
references/_sections.mdCategory definitions and ordering
assets/templates/_template.mdTemplate for new rules
metadata.jsonVersion and reference information

Related skills

How it compares

Choose typescript-refactor over generic lint skills when you need deep TypeScript 6.0 and React 19 typing guidance with ordered impact, not just formatting or ESLint autofixes.

FAQ

How many rules does typescript-refactor include?

typescript-refactor bundles 47 prioritized rules across 9 categories for TypeScript 6.0 and React 19 TSX. Rules span type architecture, narrowing, modern syntax, and compiler performance, each with examples and references in skill version 1.2.0.

Which TypeScript and React versions does typescript-refactor target?

typescript-refactor is current to TypeScript 6.0 and React 19. It documents satisfies, using, const type parameters, inferred type predicates, isolatedDeclarations, erasable syntax, and import attributes for agent-led refactors.

When should a developer invoke typescript-refactor?

typescript-refactor fits active refactors of production TS/TSX where types, narrowing, or React 19 patterns need hardening. Invoke it when an agent is modernizing components or modules and you want 47 ordered rules instead of one-off guesses.

Is Typescript Refactor safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Code Review & Qualityfrontendbackendtesting

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.