skills/typescript-refactor/SKILL.md
TypeScript refactoring and modernization guidelines from a principal specialist perspective. This skill should be used when refactoring, reviewing, or modernizing TypeScript code to ensure type safety, compiler performance, and idiomatic patterns. Triggers on tasks involving TypeScript type architecture, narrowing, generics, error handling, or migration to modern TypeScript features.
npx skillsauth add shipshitdev/library typescript-refactorInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
43 rules across 8 categories for TypeScript refactoring and modernization, prioritized by impact to guide automated refactoring, code review, and code generation.
as castssatisfies, using, const type parameters)| 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- |
arch-discriminated-unions — Use discriminated unions over string enums for exhaustive pattern matchingarch-branded-types — Use branded types for domain identifiers to prevent value mix-upsarch-satisfies-over-annotation — Use satisfies for config objects to preserve literal typesarch-interfaces-over-intersections — Extend interfaces instead of intersecting types for better error messagesarch-const-assertion — Use as const for immutable literal inferencearch-readonly-by-default — Default to readonly types for function parameters and return valuesarch-avoid-partial-abuse — Avoid Partial<T> abuse for builder patternsnarrow-custom-type-guards — Write custom type guards instead of type assertionsnarrow-assertion-functions — Use assertion functions for precondition checksnarrow-exhaustive-switch — Enforce exhaustive switch with nevernarrow-in-operator — Narrow with the in operator for interface unionsnarrow-eliminate-as-casts — Eliminate as casts with proper narrowing chainsnarrow-typeof-chains — Use typeof narrowing before property accessmodern-using-keyword — Use the using keyword for resource cleanupmodern-const-type-parameters — Use const type parameters for literal inferencemodern-template-literal-types — Use template literal types for string patternsmodern-noinfer-utility — Use NoInfer to control type parameter inferencemodern-accessor-keyword — Use accessor for auto-generated getters and settersmodern-verbatim-module-syntax — Enable verbatimModuleSyntax for explicit import typesgeneric-infer-over-annotate — Let TypeScript infer instead of explicit annotationgeneric-constrain-dont-overconstrain — Constrain generics minimallygeneric-avoid-distributive-surprises — Control distributive conditional typesgeneric-mapped-type-utilities — Build custom mapped types for repeated transformationsgeneric-return-type-inference — Preserve return type inference in generic functionscompile-explicit-return-types — Add explicit return types to exported functionscompile-avoid-deep-recursion — Avoid deeply recursive type definitionscompile-project-references — Use project references for monorepo buildscompile-base-types-over-unions — Use base types instead of large union typeserror-result-type — Use Result types instead of thrown exceptionserror-exhaustive-error-handling — Use exhaustive checks for typed error variantserror-typed-catch — Type catch clause variables as unknownerror-never-for-unreachable — Use never to mark unreachable code pathserror-discriminated-error-unions — Model domain errors as discriminated unionsperf-union-literals-over-enums — Use union literals instead of enumsperf-avoid-delete-operator — Avoid the delete operator on objectsperf-object-freeze-const — Use Object.freeze with as const for true immutabilityperf-object-keys-narrowing — Avoid Object.keys type wideningperf-map-set-over-object — Use Map and Set over plain objects for dynamic collectionsquirk-excess-property-checks — Understand excess property checks on object literalsquirk-empty-object-type — Avoid the {} type — it means non-nullishquirk-type-widening-let — Prevent type widening with let declarationsquirk-variance-annotations — Use variance annotations for generic interfacesquirk-structural-typing-escapes — Guard against structural typing escape hatchesRead individual reference files for detailed explanations and code examples:
| File | Description | |------|-------------| | references/_sections.md | Category definitions and ordering | | assets/templates/_template.md | Template for new rules | | metadata.json | Version and reference information |
development
Coordinates a weekly engineering review of board accuracy, recent code changes, operational health, and scoped cleanup. Use for a recurring repository health review or a review of the last several days.
testing
Audits project board configuration and prepares explicitly requested setup, copy, or normalization changes while preserving the existing workflow and provider boundaries. Use when inspecting a board's fields, columns, scope, or configuration.
testing
Reconciles a project board with current work and delivery evidence, reports incomplete coverage and metadata gaps, and applies only approved provider-supported field changes. Use when auditing board drift, reviewing blocked work, or assessing upcoming delivery.
development
Walk through how a subsystem works. Use for "how does X work", code walkthroughs before changing something, and placement or ownership questions. Explains architecture, runtime flow, and onboarding mental models. Can critique architecture. Use why for motivation.