refactoring-patterns

Identify and apply refactoring moves to JavaScript/TypeScript codebases.

Updated May 6, 2026
One-click install
npx skills add https://github.com/Abdullahmohammadaref/acar --skill refactoring-patterns-abdullahmohammadaref
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactoring-patterns
Source: https://github.com/Abdullahmohammadaref/acar/tree/main/.agents/skills/refactoring-patterns
Command: npx skills add https://github.com/Abdullahmohammadaref/acar --skill refactoring-patterns-abdullahmohammadaref

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill helps developers identify and apply proven refactoring moves to improve readability, reduce duplication, and simplify complex logic without changing observable behavior.

Core Features & Use Cases

  • Structured refactoring moves: extract method, replace conditional with polymorphism, introduce parameter object, and more—each move is repeatable and testable.
  • Guided decision-making: provides criteria from code smells to select the appropriate refactoring approach.
  • Use Case: when a function grows unwieldy, use this skill to identify a named refactor target and implement it safely.

Quick Start

Identify a long function and extract a named helper to reduce complexity while preserving behavior.

Frequently Asked Questions about refactoring-patterns

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

FAQPage Schema
How do I safely refactor a long function in JavaScript?

To refactor a long function in JavaScript safely, apply the Extract Method move by pulling out logical blocks into named helper functions. This reduces complexity while enforcing tests to preserve the original observable behavior.

When should I replace conditional logic with polymorphism in TypeScript?

Replace conditional logic with polymorphism in TypeScript when you encounter code smells like complex switch statements. This refactoring move simplifies logic by delegating behavior to subclasses, improving readability and reducing duplication.

How do I simplify functions with too many parameters in a TypeScript codebase?

To simplify functions with too many parameters in a TypeScript codebase, apply the Introduce Parameter Object refactoring move. This groups related parameters into a structured object, enhancing code readability and maintainability.

What is the best way to identify code smells for refactoring?

The best way to identify code smells for refactoring is to evaluate your codebase against structured criteria. This skill guides decision-making by mapping specific code smells like unwieldy functions to proven, repeatable refactoring moves.

Does refactoring JavaScript code change its observable behavior?

Refactoring JavaScript code does not change its observable behavior. The process strictly improves internal code quality, readability, and structure while preserving existing functionality and enforcing safety through tests.

Can I use these refactoring patterns for both JavaScript and TypeScript?

Yes, you can use these refactoring patterns for both JavaScript and TypeScript. The taxonomy-driven moves, including Extract Method and Introduce Parameter Object, are designed specifically for JavaScript and TypeScript codebases.