refactor-file

Refactor TypeScript code while preserving behavior and updating tests.

Updated Oct 19, 2022
One-click install
npx skills add https://github.com/iradkot/shaniDms22 --skill refactor-file
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-file
Source: https://github.com/iradkot/shaniDms22/tree/main/.github/skills/refactor-file
Command: npx skills add https://github.com/iradkot/shaniDms22 --skill refactor-file

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides a structured, safe, and scalable approach to refactoring TypeScript codebases while preserving existing behavior, tests, and interfaces. It emphasizes SOLID principles, performance-oriented design, and feature-folder organization to improve maintainability without introducing regressions.

Core Features & Use Cases

  • Guided, behavior-preserving refactor process that preserves outputs, timing, and side effects.
  • Focused on TypeScript projects with large files, long functions, and complex nesting, offering guidelines to extract constants, helpers, rename APIs, and restructure into feature folders.
  • Supports updating tests, types, imports, and usages in a coordinated refactor workflow.

Quick Start

Identify the target file and run the structured refactor plan to extract helpers and constants while preserving behavior.

Frequently Asked Questions about refactor-file

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

FAQPage Schema
How do I refactor large TypeScript files without breaking existing behavior?

Behavior-preserving TypeScript refactoring involves extracting constants and helpers, renaming APIs, and reorganizing into feature folders while ensuring outputs, timing, and side effects remain identical. This structured approach improves maintainability without introducing regressions or altering existing functionality.

What is the best way to split long functions in TypeScript?

The best way to split long TypeScript functions is to extract reusable constants and helper functions, then reorganize them into feature folders. This process must preserve original outputs and side effects while updating tests, types, and imports to align with SOLID and performance-first principles.

How do I update tests and imports when restructuring TypeScript code into feature folders?

When restructuring TypeScript code into feature folders, update tests, types, imports, and usages in a coordinated refactor workflow. This ensures behavior is preserved by keeping outputs and side effects identical while maintaining alignment with SOLID and performance-oriented design principles.

Does this refactoring approach work for complex TypeScript codebases?

This refactoring approach works for complex TypeScript codebases by targeting scenarios with large files, long functions, and complex nesting. It guides users through extracting helpers and constants while enforcing behavior preservation, test updates, and alignment with SOLID and performance-first principles.

When should I not use a behavior-preserving refactor in TypeScript?

You should avoid behavior-preserving TypeScript refactors when your goal is to change application outputs, timing, or side effects. This approach is strictly designed to improve code quality, reorganize into feature folders, and align with SOLID principles without altering existing functionality.