Refactoring Patterns

Identify code smells and apply refactoring patterns to improve software structure.

3|1|Updated Oct 23, 2025
One-click install
npx skills add https://github.com/vanman2024/dev-lifecycle-marketplace --skill refactoring-patterns-vanman2024
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Refactoring Patterns
Source: https://github.com/vanman2024/dev-lifecycle-marketplace/tree/main/.archive/old-numbered-plugins/04-iterate/skills/refactoring-patterns
Command: npx skills add https://github.com/vanman2024/dev-lifecycle-marketplace --skill refactoring-patterns-vanman2024

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Codebases naturally accumulate "code smells" like duplication, complex functions, and poor naming, leading to reduced maintainability and increased technical debt. This skill provides patterns and tools to systematically identify and address these issues.

Core Features & Use Cases

  • Code Smell Detection: Includes scripts (detect-duplicates.sh, complexity-check.sh) to automatically identify duplicate code, measure function complexity, and analyze naming quality.
  • Refactoring Pattern Guidance: Offers detailed instructions and examples for common refactoring patterns like Extract Method, Extract Class, Simplify Conditionals, and Remove Duplication.
  • Structural Improvement Techniques: Guides on improving module organization, dependency management, and separation of concerns, enhancing overall code architecture.
  • Refactoring Checklist: Provides a checklist to ensure refactorings preserve functionality, maintain backward compatibility, and are covered by tests.
  • Use Case: A developer is tasked with improving the maintainability of a legacy module. This skill can analyze the code to detect duplicate sections and highly complex functions, then provide guidance and examples for applying refactoring patterns like "Extract Method" to simplify the codebase.

Quick Start

Analyze the 'src/utils.js' file for code complexity and detect any duplicate code patterns within the 'src/' directory.

Frequently Asked Questions about Refactoring Patterns

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

FAQPage Schema
How do I detect duplicate code in my codebase?

Duplicate code detection identifies repeated code patterns across your files using automated scripts like detect-duplicates.sh. This reveals redundancy that inflates maintenance burden and introduces inconsistency risks, helping you pinpoint sections to consolidate through refactoring.

What are code smells and why should I fix them?

Code smells are structural patterns—long methods, complex conditionals, poor naming—that signal maintainability problems without being functional bugs. Fixing them reduces technical debt, improves readability, and makes future changes safer and faster.

How do I simplify complex functions using refactoring patterns?

Extract Method and Extract Class patterns break down overly complex functions into smaller, focused units. These patterns reduce cognitive load, improve testability, and make code behavior easier to understand and modify.

Can I measure function complexity automatically?

Yes, complexity-check.sh automatically measures function complexity across your codebase. This identifies candidates for simplification and lets you track improvements over time to prevent complexity from accumulating.

Does refactoring preserve existing functionality?

Refactoring patterns maintain behavior while improving structure. A refactoring checklist ensures changes preserve backward compatibility and remain covered by tests, so existing code relying on your module continues working.

How do I improve code organization and module structure?

Structural improvement techniques guide dependency management, separation of concerns, and interface clarity across modules. These changes reduce coupling, increase cohesion, and make architectural dependencies explicit and manageable.