frontend-refactor-planner
Creates safe refactor plans for messy UI code including component splitting strategies, state simplification, performance optimizations, and accessibility improvements. Provides phased approach, risk assessment, and "done" criteria. Use when refactoring "legacy code", "messy components", "performance issues", or "large files".
When & Why to Use This Skill
The Frontend Refactor Planner is a specialized Claude skill designed to transform complex, 'spaghetti' UI code into maintainable, high-performance applications. It provides structured, phased refactoring strategies—including component decoupling, state management optimization, and accessibility audits—to reduce technical debt while minimizing regression risks through detailed impact assessments and 'done' criteria. By focusing on modularity and performance, it helps developers modernize legacy codebases with a clear, low-risk roadmap.
Use Cases
- Case 1: Decomposing monolithic React or Vue components (300+ lines) into smaller, reusable sub-components to improve readability and maintainability.
- Case 2: Migrating legacy frontend state management to modern patterns like Context API or Zustand to eliminate prop drilling and simplify data flow.
- Case 3: Implementing performance optimization plans for slow-loading pages by identifying memoization needs (useMemo/useCallback) and code-splitting opportunities.
- Case 4: Auditing and upgrading UI accessibility (a11y) by planning the integration of ARIA labels, semantic HTML, and keyboard navigation into existing workflows.
- Case 5: Creating a low-risk migration strategy for high-traffic legacy pages using feature flags and phased rollouts to ensure zero downtime during refactoring.
| name | frontend-refactor-planner |
|---|---|
| description | Creates safe refactor plans for messy UI code including component splitting strategies, state simplification, performance optimizations, and accessibility improvements. Provides phased approach, risk assessment, and "done" criteria. Use when refactoring "legacy code", "messy components", "performance issues", or "large files". |
Frontend Refactor Planner
Create safe, phased refactor plans for complex frontend code.
Refactor Assessment
Identify Issues: Large components (>300 lines), prop drilling, duplicate logic, poor performance, accessibility gaps, tight coupling, untested code Prioritize: By risk (high-traffic pages first) and impact (user-facing bugs prioritized) Plan Phases: Break into small, testable increments
Common Refactor Patterns
Component Splitting: Extract sub-components, create compound components, separate logic from presentation State Management: Lift state up, move to Context/Zustand, remove unnecessary state Performance: Memoization (useMemo/useCallback), code splitting, lazy loading, virtualization Accessibility: Add ARIA labels, keyboard navigation, focus management, semantic HTML Testing: Add tests before refactoring, test after each change
Phased Approach
Phase 1 - Stabilize: Add tests, fix critical bugs, document current behavior Phase 2 - Extract: Pull out utilities, create smaller components, reduce complexity Phase 3 - Simplify: Remove dead code, consolidate duplicates, optimize state Phase 4 - Polish: Performance optimization, accessibility audit, documentation
Risk Mitigation
Feature flags for gradual rollout, A/B testing refactored vs original, monitor error rates, have rollback plan, peer review all changes, incremental deployment.
Done Criteria
Code coverage >80%, performance metrics improved, accessibility score 95+, no regressions in tests, code review approved, documentation updated.