Individual skill
typescript-refactor
TypeScript and TSX refactoring and modernization guidelines from a principal specialist perspective, current to TypeScript 6.0 and React 19. This skill should be used when refactoring, reviewing, or modernizing TypeScript or React/TSX code for type safety, compiler performance, and idiomatic patterns. Triggers on tasks involving type architecture, narrowing, generics, discriminated unions, error handling, React component and hook typing, or migration to modern TypeScript features (satisfies, using, const type parameters, inferred type predicates, isolatedDeclarations, erasable syntax, import attributes).
skills/.experimental/typescript-refactor/SKILL.md
Source commit cf93c57cac89d6fc3e4194686000411567f5caf3
What was checked
- Matches the observed repository HEAD
- Yes
- Scanner rules are current
- No
- Repository scan complete
- No
- Skill scan complete
- Yes
- Observed behavior
- Not checked yet
- Last checked
- Nov 5, 2026
These are observations at the recorded commit, not a guarantee of safety. Review the source before running it.
Install this skill
Choose an agent in your Stack or copy a command below. Commands fetch the pinned commit and copy only this skill directory. Existing destinations are refused. Copying a command does not install anything.
An install command is unavailable: current rules, complete repository and skill scans, an eligible behavior level and a permitted license are required.
Repository context
- Repository stars (not skill ratings)
- 222
- Repository last updated
- Aug 15, 2026
- License
- MIT
Observed agent integration: codex
- engineering Derived category
- engineering-web Derived category
Files and excerpt
File metadata and permitted, redacted excerpts come from the recorded scan. Source links are pinned to that commit.
Browse files
AGENTS.mddoc · 11,071 bytesSKILL.mdcore · 9,266 bytesassets/templates/_template.mddoc · 786 bytesmetadata.jsonasset · 1,508 bytesreferences/_sections.mddoc · 2,384 bytesreferences/arch-avoid-partial-abuse.mddoc · 1,386 bytesreferences/arch-branded-types.mddoc · 1,425 bytesreferences/arch-const-assertion.mddoc · 1,295 bytesreferences/arch-discriminated-unions.mddoc · 1,922 bytesreferences/arch-interfaces-over-intersections.mddoc · 1,684 bytesreferences/arch-readonly-by-default.mddoc · 1,227 bytesreferences/arch-satisfies-over-annotation.mddoc · 1,315 bytesreferences/compile-avoid-deep-recursion.mddoc · 1,482 bytesreferences/compile-base-types-over-unions.mddoc · 1,597 bytesreferences/compile-explicit-return-types.mddoc · 2,026 bytesreferences/compile-isolated-declarations.mddoc · 1,566 bytesreferences/compile-project-references.mddoc · 1,631 bytesreferences/error-discriminated-error-unions.mddoc · 1,323 bytesreferences/error-exhaustive-error-handling.mddoc · 1,497 bytesreferences/error-result-type.mddoc · 1,540 bytesreferences/error-typed-catch.mddoc · 1,259 bytesreferences/generic-avoid-distributive-surprises.mddoc · 1,186 bytesreferences/generic-constrain-dont-overconstrain.mddoc · 1,127 bytesreferences/generic-mapped-type-utilities.mddoc · 1,468 bytesreferences/generic-return-type-inference.mddoc · 1,507 bytesreferences/modern-const-type-parameters.mddoc · 1,306 bytesreferences/modern-erasable-syntax.mddoc · 1,717 bytesreferences/modern-import-attributes.mddoc · 1,079 bytesreferences/modern-noinfer-utility.mddoc · 1,232 bytesreferences/modern-template-literal-types.mddoc · 1,421 bytesreferences/modern-using-keyword.mddoc · 1,572 bytesreferences/modern-verbatim-module-syntax.mddoc · 1,446 bytesreferences/narrow-assertion-functions.mddoc · 1,737 bytesreferences/narrow-custom-type-guards.mddoc · 1,868 bytesreferences/narrow-eliminate-as-casts.mddoc · 1,794 bytesreferences/narrow-exhaustive-switch.mddoc · 1,586 bytesreferences/narrow-in-operator.mddoc · 1,636 bytesreferences/perf-avoid-delete-operator.mddoc · 1,102 bytesreferences/perf-map-set-over-object.mddoc · 1,613 bytesreferences/perf-object-freeze-const.mddoc · 1,295 bytesreferences/perf-object-keys-narrowing.mddoc · 1,606 bytesreferences/perf-union-literals-over-enums.mddoc · 1,818 bytesreferences/quirk-empty-object-type.mddoc · 1,404 bytesreferences/quirk-excess-property-checks.mddoc · 1,670 bytesreferences/quirk-structural-typing-escapes.mddoc · 1,433 bytesreferences/quirk-variance-annotations.mddoc · 1,815 bytesreferences/tsx-avoid-react-fc.mddoc · 1,437 bytesreferences/tsx-discriminated-props.mddoc · 1,674 bytesreferences/tsx-event-handler-types.mddoc · 1,435 bytesreferences/tsx-extend-native-props.mddoc · 1,668 bytesreferences/tsx-hook-typing.mddoc · 1,332 bytesreferences/tsx-ref-as-prop.mddoc · 1,292 bytes
Read excerpt
# 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