code-refactoring

Refactor legacy code into clean architecture with incremental, test-gated changes.

Updated Apr 15, 2026
One-click install
npx skills add https://github.com/shoshoavi/agentic_worflows --skill code-refactoring-shoshoavi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: code-refactoring
Source: https://github.com/shoshoavi/agentic_worflows/tree/main/cursor/skills/code-refactoring
Command: npx skills add https://github.com/shoshoavi/agentic_worflows --skill code-refactoring-shoshoavi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Refactoring legacy or monolithic code often risks breaking existing behavior, and big-bang rewrites introduce regressions. This Skill provides a disciplined, incremental process that keeps behavior and public contracts stable while modernizing code structure. ## Core Features & Use Cases - Incremental Refactoring Loop: Extract constants, convert procedural code to classes with dependency injection, extract helpers, reorganize folders, and upgrade error handling—each step gated by lint and tests. - Clean Architecture Migration: Move modules into domain/application/infrastructure/presentation folders using compatibility shims so old import paths keep working. - Multi-Language Guidance: Concrete patterns for Python, TypeScript/JavaScript, Go, and Java, including constants extraction, typed exception hierarchies, and retry with exponential backoff. - Use Case: Given a legacy processor.py full of magic strings and procedural logic, produce a smallest-first migration plan, convert it to a service class with injected dependencies, and validate each step with focused tests. ## Quick Start Ask the AI to refactor src/legacy/processor.py to clean architecture with an incremental, test-gated migration plan.

Frequently Asked Questions about code-refactoring

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

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

Refactor incrementally: pick the smallest low-coupled module, extract constants, convert to classes, then run lint and focused tests after each step. Keep compatibility adapters for old import paths and never attempt big-bang rewrites.

How to convert procedural code to object-oriented design?▼

Group cohesive functions into a class with one responsibility, inject dependencies through the constructor, and depend on interfaces or protocols. Keep the old function as a thin adapter temporarily while call-sites migrate incrementally.

What is the best way to extract magic values from code?▼

Move inline literals into constants modules using UPPER_SNAKE naming, frozenset for membership checks, and constant message templates formatted at call-sites. Avoid extracting one-time literals or creating a giant unrelated constants file.

Does this refactoring approach work for TypeScript and Go projects?▼

Yes, the Skill includes language-specific guidance for Python, TypeScript/JavaScript, Go, and Java. Each covers constants extraction, dependency injection patterns, typed error hierarchies, and retry policies appropriate to the language.

When should I not use incremental refactoring?▼

Avoid it when the module has no test coverage to gate changes or when behavior contracts are undefined. Establish a baseline of lint and tests first, and define a rollback boundary for each slice before starting.