Dev Code Refactoring Plan Writer ================================ Create a code refactoring plan for [codebase/module/feature]. Refactoring details: - Target: [specific file/module/service] - Current problems: [describe technical debt] - Goal: [maintainability/performance/testability/readability] - Risk level: [high/medium/low] - Test coverage: [%] - Team size: [number] REFACTORING PLAN 1. ASSESSMENT CODE SMELLS IDENTIFIED - Long methods: [files/functions over X lines] - Large classes: [God objects] - Duplicate code: [DRY violations] - Deep nesting: [over 3 levels] - Magic numbers/strings: [hardcoded values] - Poor naming: [unclear variable/function names] - Dead code: [unused functions/variables] - Tight coupling: [dependencies that should be injected] - Missing tests: [coverage gaps] 2. PRIORITIZATION HIGH PRIORITY (do first) - [Issue 1]: [why high priority] - [Issue 2]: [impact] MEDIUM PRIORITY - [Issue 3]: [description] LOW PRIORITY (if time) - [Issue 4]: [nice to have] 3. REFACTORING STRATEGY BEFORE ANY REFACTORING - Ensure tests exist: [write if missing] - Understand current behavior fully - Refactor in small steps - Commit after each working step EXTRACT METHOD - Long methods broken into smaller focused functions - Rule: function does one thing - Max length: [20-30 lines guideline] EXTRACT CLASS - Large classes split by responsibility - Single responsibility principle REPLACE MAGIC NUMBERS - Named constants for all hardcoded values - Config files for environment-specific values DEPENDENCY INJECTION - Remove hardcoded dependencies - Inject via constructor/function params - Improves testability 4. TESTING APPROACH - Write characterization tests first: [capture current behavior] - Refactor: [make changes] - Verify tests still pass: [behavior preserved] - Add new unit tests: [for refactored code] 5. ROLLOUT PLAN - Branch strategy: [feature branch per refactor] - Review: [PR for each logical change] - Deployment: [behind feature flag if risky] - Monitoring: [watch for regressions after deploy] 6. DEFINITION OF DONE - All existing tests pass - New tests added: [coverage target %] - No new linting errors - Code reviewed and approved - Documentation updated Source: https://promptzyo.com/prompt/dev-code-refactoring-plan-writer