refactoring

Applies safe code refactoring patterns and legacy modernization strategies while preserving existing behavior.

111|73|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/autopus-ai/autopus-adk --skill refactoring-autopus-ai
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: refactoring
Source: https://github.com/autopus-ai/autopus-adk/tree/main/.omp/skills/refactoring
Command: npx skills add https://github.com/autopus-ai/autopus-adk --skill refactoring-autopus-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Restructuring legacy or tangled code without breaking existing behavior is risky and slow. This Skill provides proven refactoring patterns and safety checklists so code structure improves while external behavior stays identical. ## Core Features & Use Cases - Safe Refactoring Patterns: Apply Extract Function, Extract Interface, Replace Conditional with Polymorphism, and project-wide renames with caller verification. - Legacy Modernization Strategies: Migrate systems incrementally using the Strangler Fig pattern and Branch by Abstraction. - Dead Code Removal: Detect unused functions with go vet and caller searches, then remove them cleanly. - Use Case: When modernizing a Go monolith, use this Skill to wrap legacy implementations behind interfaces, shift traffic gradually to new implementations, and verify each step with tests before removing old code. ## Quick Start Refactor this long Go function by extracting its validation, calculation, and persistence logic into separate functions while keeping all existing tests passing.

Frequently Asked Questions about 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?▼

Protect existing behavior with tests first, then apply one transformation at a time such as Extract Function or Extract Interface. Run tests after each step and keep refactoring commits separate from feature change commits.

What is the Strangler Fig pattern for legacy modernization?▼

The Strangler Fig pattern places a new implementation alongside the existing system, gradually shifts traffic to the new implementation, and removes the old one after full migration. It avoids risky big-bang rewrites.

How do I safely remove dead code in a Go project?▼

Detect unused functions with go vet and confirm zero callers by searching the codebase excluding test files. Delete the code completely rather than commenting it out, since git history preserves it.

When should I replace conditionals with polymorphism?▼

Replace switch or if-else chains with an interface and multiple implementations when the same conditional logic appears repeatedly or new variants are added often. Each type then encapsulates its own behavior.

What are the limitations of manual refactoring without IDE tools?▼

Manual renames risk missing callers across a large project, so verify with grep searches or use tools like gopls rename. Always run the full test suite after each transformation step.