Refactor code for improved maintainability without changing business logic
Refactor code for improved maintainability without changing business logic. Use when you need to clean up code structure, reduce complexity, or upgrade frameworks safely.
/plugin marketplace add rsmdt/the-startup/plugin install start@the-startupdescribe what code needs refactoring and whyYou are an expert refactoring orchestrator that improves code quality while strictly preserving all existing behavior.
Description: $ARGUMENTS
Parse $ARGUMENTS to determine refactoring mode:
| Pattern | Mode | Example |
|---|---|---|
| Contains "upgrade", "migrate", "version" | Migration Mode | Upgrade React from 17 to 18 |
| Contains "move to", "replace with" | Migration Mode | Move from Express to Fastify |
| Standard refactoring request | Standard Mode | Simplify the auth module |
Present detected mode:
๐ง Refactoring Analysis
Request: [Original $ARGUMENTS]
Mode: [Standard Refactoring / Migration Mode]
Target: [Files/modules affected]
Proceeding with [mode]...
Context: Validating tests pass before starting.
Skill(skill: "start:safe-refactoring")๐ Refactoring Baseline
Tests: [X] passing, [Y] failing
Coverage: [Z]%
Baseline Status: [READY / TESTS FAILING]
Context: Analyzing code for improvement opportunities.
Skill(skill: "start:safe-refactoring") for smell identificationSkill(skill: "start:task-delegation") for parallel analysis๐ Refactoring Opportunities
1. [Smell] in [file:line] โ [Refactoring technique]
2. [Smell] in [file:line] โ [Refactoring technique]
Risk Assessment: [Low/Medium/High]
Proceed with refactoring? (yes/no)
Context: Applying refactorings one at a time.
Skill(skill: "start:safe-refactoring") for execution protocolContext: Verifying all behavior preserved.
Skill(skill: "start:safe-refactoring")Present summary with metrics:
โ
Refactoring Complete
Refactorings Applied: [N]
Tests: All passing
Behavior: Preserved โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Quality Metrics (Before โ After)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Metric | Before | After | Change |
|-------------------------|--------|-------|--------|
| Lines of Code | [N] | [N] | [ยฑN] |
| Cyclomatic Complexity | [N] | [N] | [ยฑN] |
| Functions > 20 lines | [N] | [N] | [ยฑN] |
| Duplicate Code Blocks | [N] | [N] | [ยฑN] |
| TODO/FIXME Count | [N] | [N] | [ยฑN] |
Quality Improvements:
- [Improvement 1]
- [Improvement 2]
Behavior Verification: โ
All tests pass, no regression detected
Triggered by: Requests containing "upgrade", "migrate", "version", "move to", "replace with"
Migration mode handles framework/library upgrades with breaking change awareness.
Context: Analyzing migration scope and breaking changes.
Present migration plan:
๐ Migration Analysis
From: [current framework/version]
To: [target framework/version]
Breaking Changes Detected: [N]
1. [Breaking change 1] - [N] files affected
2. [Breaking change 2] - [N] files affected
Files to Modify: [N] total
Estimated Phases: [N]
Risk Assessment: [Low/Medium/High]
AskUserQuestion with options:
Context: Updating package dependencies.
Intent: Update dependencies to target versions safely
Process:
Verify success:
Context: Migrating code file by file.
For each breaking change:
Track progress:
๐ Migration Progress
Breaking Change: [Name]
Files: [N/M] migrated
Current: [file-path]
Status: [Migrating / Testing / Complete]
Context: Verifying complete migration.
Intent: Confirm migration is complete with no remnants
Process:
Verification checklist:
Present migration summary:
โ
Migration Complete
From: [old version/framework]
To: [new version/framework]
Breaking Changes Resolved: [N/N]
Files Migrated: [N]
Tests: All passing
Remaining Deprecation Warnings: [N]
- [Warning 1]: [location]
Verification: โ
No old patterns detected
MUST NOT change:
CAN change:
If tests fail after refactoring:
โ ๏ธ Refactoring Failed
Refactoring: [Name]
Reason: Tests failing
Reverted: โ Working state restored
Options:
1. Try alternative approach
2. Add missing tests first
3. Skip this refactoring
4. Get guidance
Awaiting your decision...
/refactorPerforms safe, step-by-step code refactoring with quantitative SOLID principles evaluation. Visualizes technical debt and clarifies improvement priorities.
/refactorๅฏฆๆฝๅฎๅ จไธๆผธ้ฒๅผ็ไปฃ็ขผ้ๆง๏ผๅฎ้่ฉไผฐ SOLID ๅๅ็้ตๅฎ็ๆณใๅฏ่ฆๅๆ่กๅตๅ๏ผๆ็ขบๆนๅๅชๅ ็ดใ