agentsclimarketplace

React refactor

Skill ComeOnOliver/skillshub/skills/pproenca/dot-skills/react-refactor

🧠 The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.

Install
npx -y skills add ComeOnOliver/skillshub --skill react-refactor

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

8.7 KB, as published. Nobody here has run it

React Refactor Best Practices

Architectural refactoring guide for React applications. Contains 40 rules across 7 categories, prioritized by impact from critical (component and state architecture) to incremental (refactoring safety).

When to Apply

  • Refactoring existing React codebases or planning large-scale restructuring
  • Reviewing PRs for architectural issues and code smells
  • Decomposing oversized components into focused units
  • Extracting reusable hooks from component logic
  • Improving testability of React code
  • Reducing coupling between feature modules

Rule Categories

CategoryImpactRulesKey Topics
Component ArchitectureCRITICAL8Compound components, headless pattern, composition over props, client boundaries
State ArchitectureCRITICAL7Colocation, state machines, URL state, derived values
Hook PatternsHIGH6Single responsibility, naming, dependency stability, composition
Component DecompositionHIGH6Scroll test, extraction by change reason, view/logic separation
Coupling & CohesionMEDIUM4Dependency injection, circular deps, stable imports, barrel-free
Data & Side EffectsMEDIUM4Server-first fetch, TanStack Query, error boundaries
Refactoring SafetyLOW-MEDIUM5Characterization tests, behavior testing, integration tests

Quick Reference

Critical patterns β€” get these right first:

  • Use compound components instead of props explosion
  • Colocate state with the components that use it
  • Use state machines for complex UI workflows
  • Separate container logic from presentational components

Common mistakes β€” avoid these anti-patterns:

  • Lifting state to App when only one component reads it
  • Using context for rapidly-changing values
  • Monolithic hooks that fetch + transform + cache
  • Testing implementation details instead of behavior

Table of Contents

  1. Component Architecture β€” CRITICAL
  2. State Architecture β€” CRITICAL
  3. Hook Patterns β€” HIGH
  4. Component Decomposition β€” HIGH
  5. Coupling & Cohesion β€” MEDIUM
  6. Data & Side Effects β€” MEDIUM
  7. Refactoring Safety β€” LOW-MEDIUM

References

  1. https://react.dev
  2. https://react.dev/learn/thinking-in-react
  3. https://kentcdodds.com/blog/application-state-management-with-react
  4. https://testing-library.com/docs/guiding-principles
  5. https://patterns.dev

Related Skills

  • For React 19 API best practices, see react skill
  • For application performance optimization, see react-optimise skill
  • For client-side form handling, see react-hook-form skill

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.