Refactor Legacy Code
Skill files10 files

references/

scripts/

templates/

SKILL.md87 lines
1
---
2
name: refactor-legacy-code
3
description: >
4
Modernize and improve legacy codebases while maintaining functionality. Use
5
when you need to refactor old code, reduce technical debt, modernize
6
deprecated patterns, or improve code maintainability without breaking existing
7
behavior.
8
---
9
10
# Refactor Legacy Code
11
12
## Table of Contents
13
14
- [Overview](#overview)
15
- [When to Use](#when-to-use)
16
- [Quick Start](#quick-start)
17
- [Reference Guides](#reference-guides)
18
- [Best Practices](#best-practices)
19
20
## Overview
21
22
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.
23
24
## When to Use
25
26
- Modernizing outdated code patterns or deprecated APIs
27
- Reducing technical debt in existing codebases
28
- Improving code readability and maintainability
29
- Extracting reusable components from monolithic code
30
- Upgrading to newer language features or frameworks
31
- Preparing code for new feature development
32
33
## Quick Start
34
35
First, analyze the legacy code to understand:
36
37
```bash
38
# Review the codebase structure
39
tree -L 3 -I 'node_modules|dist|build'
40
41
# Check for outdated dependencies
42
npm outdated # or pip list --outdated, composer outdated, etc.
43
44
# Identify code complexity hotspots
45
# Use tools like:
46
# - SonarQube for code smells
47
# - eslint for JavaScript
48
# - pylint for Python
49
# - RuboCop for Ruby
50
```
51
52
## Reference Guides
53
54
Detailed implementations in the `references/` directory:
55
56
| Guide | Contents |
57
|---|---|
58
| [Code Assessment](references/code-assessment.md) | Code Assessment |
59
| [Establish Safety Net](references/establish-safety-net.md) | Establish Safety Net |
60
| [Incremental Refactoring](references/incremental-refactoring.md) | Incremental Refactoring |
61
| [Modernize Patterns](references/modernize-patterns.md) | Modernize Patterns |
62
| [Reduce Dependencies](references/reduce-dependencies.md) | Reduce Dependencies, Documentation |
63
| [Complete Refactoring Example](references/complete-refactoring-example.md) | Complete Refactoring Example |
64
| [Benefits Achieved](references/benefits-achieved.md) | Benefits Achieved |
65
66
## Best Practices
67
68
### ✅ DO
69
70
- **Refactor incrementally**: Small, testable changes
71
- **Run tests frequently**: After each refactoring step
72
- **Commit often**: Create logical, atomic commits
73
- **Keep existing tests passing**: Don't break functionality
74
- **Use IDE refactoring tools**: Safer than manual edits
75
- **Review code coverage**: Ensure tests cover refactored code
76
- **Document decisions**: Why, not just what
77
- **Seek peer review**: Fresh eyes catch issues
78
79
### ❌ DON'T
80
81
- **Mix refactoring with new features**: Separate concerns
82
- **Refactor without tests**: Recipe for breaking changes
83
- **Change behavior**: Refactoring should preserve functionality
84
- **Refactor large chunks**: Increases risk and review difficulty
85
- **Ignore code smells**: Address them systematically
86
- **Skip documentation**: Future maintainers need context
87

© AJ Geddes · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…