Modernize and improve legacy codebases while maintaining functionality. Use when you need to refactor old code, reduce technical debt, modernize deprecated patterns, or improve code maintainability without breaking existing behavior.
This skill helps you systematically refactor legacy code to improve maintainability, readability, and performance while preserving existing functionality. It follows industry best practices for safe refactoring with comprehensive testing.
First, analyze the legacy code to understand:
# Review the codebase structure
tree -L 3 -I 'node_modules|dist|build'
# Check for outdated dependencies
npm outdated # or pip list --outdated, composer outdated, etc.
# Identify code complexity hotspots
# Use tools like:
# - SonarQube for code smells
# - eslint for JavaScript
# - pylint for Python
# - RuboCop for Ruby
Detailed implementations in the references/ directory:
| Guide | Contents | |---|---| | Code Assessment | Code Assessment | | Establish Safety Net | Establish Safety Net | | Incremental Refactoring | Incremental Refactoring | | Modernize Patterns | Modernize Patterns | | Reduce Dependencies | Reduce Dependencies, Documentation | | Complete Refactoring Example | Complete Refactoring Example | | Benefits Achieved | Benefits Achieved |
Copy a source-pinned command for your client. You run it yourself.
Destination: .claude/skills/refactor-legacy-code · pinned to the source commit
git clone https://github.com/aj-geddes/useful-ai-prompts.git
cd useful-ai-prompts
git checkout 3f5182cfd739fc113f4af5244a1cf342ad7f7911
mkdir -p ".claude/skills/refactor-legacy-code"
cp -r "skills/refactor-legacy-code" ".claude/skills/refactor-legacy-code"Review the source before running. This copies files into your project; it is not a one-click install and does not verify runtime safety.
Scanner static-checks@0.1.0 · commit 3f5182cfd739. Static checks cannot prove runtime safety – review the source and the exact diff before installing. How checks work.
No static rules matched. This is not a safety guarantee.