refactor-convention

Diagnose code smells and apply SOLID principles with GoF design patterns.

Updated Oct 21, 2022
One-click install
npx skills add https://github.com/Chengxufeng1994/dotfiles --skill refactor-convention
Or copy as Structured Prompt for Agentโ–ผ
Please help me install this Agent Skill.
Skill: refactor-convention
Source: https://github.com/Chengxufeng1994/dotfiles/tree/main/claude/skills/refactor-convention
Command: npx skills add https://github.com/Chengxufeng1994/dotfiles --skill refactor-convention

SYSTEM DOCUMENTATION & REQUIREMENTS

๐Ÿ’ก This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a standardized, principle-driven workflow for refactoring code, addressing common issues like code smells, poor design, and violation of software engineering principles.

Core Features & Use Cases

  • Universal Refactoring Workflow: Guides users through diagnosing, planning, and executing code refactoring.
  • Principle Enforcement: Emphasizes SOLID, KISS, YAGNI, DRY, and GoF patterns for cleaner, more maintainable code.
  • Use Case: When faced with a complex, hard-to-maintain function, use this Skill to systematically break it down, apply design patterns, and ensure testability and extensibility.

Quick Start

Use the refactor-convention skill to refactor the provided code snippet.

Frequently Asked Questions about refactor-convention

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

FAQPage Schema
How do I apply SOLID principles to refactor legacy code?โ–ผ

To refactor legacy code with SOLID principles, diagnose code smells, apply object-oriented analysis, and select appropriate GoF design patterns to ensure backward compatibility and testability.

What is the best way to structure a code refactoring workflow?โ–ผ

A robust code refactoring workflow involves diagnosing code smells, enforcing DRY, KISS, and YAGNI principles, applying SOLID design patterns, and verifying changes through tests and static analysis.

Can I use this refactoring approach with any programming language?โ–ผ

Yes, this refactoring approach provides a universal workflow applicable to any programming language by focusing on language-agnostic design patterns and software engineering principles.

When should I use GoF design patterns during code refactoring?โ–ผ

Use GoF design patterns during code refactoring when diagnosing complex, hard-to-maintain functions to systematically break them down and ensure structural extensibility.

How do you ensure backward compatibility when refactoring code?โ–ผ

Ensure backward compatibility during code refactoring by systematically applying design patterns and verifying structural changes with tests and static analysis before finalizing.

Why does my code violate KISS and DRY principles?โ–ผ

Code violates KISS and DRY principles due to accumulated complexity and duplicated logic, requiring systematic object-oriented analysis to diagnose smells and apply refactoring workflows.