code-refactoring-refactor-clean

Refactor code using clean code principles, SOLID patterns, and incremental improvement plans.

Updated May 8, 2026
One-click install
npx skills add https://github.com/kiprotichgidii/agent-skills --skill code-refactoring-refactor-clean-kiprotichgidii
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: code-refactoring-refactor-clean
Source: https://github.com/kiprotichgidii/agent-skills/tree/main/skills/code-refactoring-refactor-clean
Command: npx skills add https://github.com/kiprotichgidii/agent-skills --skill code-refactoring-refactor-clean-kiprotichgidii

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Legacy and tangled codebases accumulate code smells, duplication, and SOLID violations that slow development and increase bug risk. This Skill provides a structured refactoring workflow that analyzes code quality issues and produces prioritized, incremental improvement plans with concrete code examples. ## Core Features & Use Cases - Code Smell Detection: Identifies long methods, large classes, duplication, dead code, magic numbers, and tight coupling using defined quality metrics. - SOLID Pattern Application: Provides before/after examples for all five SOLID principles in Python, TypeScript, Java, and Go. - Prioritized Refactoring Plans: Uses ROI analysis and technical debt decision trees to order changes by impact, effort, and risk. - Use Case: Given a 500-line monolithic order processing class, the Skill decomposes it into validators, repositories, and services with dependency injection, plus tests and a migration guide. ## Quick Start Ask the AI to analyze and refactor the attached module using clean code principles and SOLID patterns, then provide a prioritized refactoring plan with tests.

Frequently Asked Questions about code-refactoring-refactor-clean

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

FAQPage Schema
How do I refactor legacy code without breaking existing behavior?▼

Apply changes in small incremental slices while keeping external behavior stable, and verify each step with tests. Start with low-risk fixes like extracting magic numbers and renaming variables before attempting class decomposition or architecture changes.

How to identify code smells in a large codebase?▼

Look for methods over 20 lines, classes over 200 lines, duplicate code blocks, complex nested conditionals, and magic numbers. Use static analysis tools like Ruff, ESLint with SonarJS, or SonarQube to automate detection with complexity thresholds.

What are SOLID principles with code examples?▼

SOLID covers Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion. The playbook includes before/after examples in Python, TypeScript, Java, and Go showing violations and their corrected implementations.

When should I not refactor code?▼

Avoid refactoring during change freezes, when only a small one-line fix is needed, or when the request is documentation-only. Also deprioritize code that is rarely modified, has adequate test coverage, and causes no production issues.

How do I prioritize technical debt for refactoring?▼

Use the ROI formula: (Business Value × Technical Debt) / (Effort × Risk). Fix code causing production bugs immediately, schedule items blocking new features this sprint, and backlog rarely-modified code with adequate coverage.