Guided code refactoring with safety checks and incremental changes
Guided code refactoring with safety checks and incremental changes
/plugin marketplace add Benny9193/devflow/plugin install benny9193-devflow@Benny9193/devflowSystematically improve code quality while maintaining behavior.
What are we refactoring?
What's the goal?
Before any changes:
git stash # or commit current work
git checkout -b refactor/[description]
Look for:
List specific refactorings to apply:
| Smell | Location | Refactoring | Risk |
|---|---|---|---|
| Long method | api.ts:processOrder | Extract Method | Low |
| Duplication | utils.ts, helpers.ts | Extract & Share | Medium |
For each refactoring:
# After each change:
npm test # or equivalent
git add -p
git commit -m "refactor(scope): description"
// Before
function process() {
// 20 lines of validation
// 20 lines of transformation
// 20 lines of persistence
}
// After
function process() {
validate();
transform();
persist();
}
// Before
function getPrice(type) {
if (type === 'A') return priceA();
if (type === 'B') return priceB();
}
// After
const pricers = { A: priceA, B: priceB };
function getPrice(type) {
return pricers[type]();
}
// Before
function createUser(name, email, age, country, role) {}
// After
function createUser(userDetails: UserDetails) {}
After all refactorings:
Provide a refactoring summary: