mcpField
R
react-refactor

react-refactor

github.com/shipshitdevDevelopment3988 installsUpdated 1d ago
Repository

About react-refactor

A React refactoring skill for developers restructuring codebases, reviewing changes, and improving component and state design. Its 40 rules span seven areas, from architecture and hooks to refactoring safety.

Key features

  1. 0140 rules across seven categories
  2. 02Prioritize component and state architecture
  3. 03Guidance for hooks and decomposition
  4. 04Address coupling and side effects
  5. 05Improve refactoring test safety

Use cases

  1. 01Plan a large React restructuring
  2. 02Review React pull requests
  3. 03Break oversized components into focused units
  4. 04Improve testability and reduce module coupling

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/shipshitdev/skills --skill react-refactor

After installing, type/react-refactorin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

AGENTS.md
plugin.json
README.md
assets/templates/
_template.md
references/
_sections.md
arch-composition-over-props.md
arch-compound-components.md
arch-container-presentational.md
arch-feature-colocation.md
arch-headless-pattern.md
arch-interface-segregation.md
arch-push-client-low.md
arch-render-props-to-hooks.md
couple-barrel-free-features.md
couple-break-circular-deps.md
couple-dependency-injection.md
couple-stable-imports.md
data-context-module-pattern.md
data-granular-error-boundaries.md
data-server-first-fetch.md
data-tanstack-query-client.md
decomp-complete-extraction.md
decomp-extract-by-change-reason.md
decomp-extract-pure-functions.md
decomp-inline-premature.md
decomp-scroll-test.md
decomp-separate-view-logic.md
hook-avoid-object-deps.md
hook-composition-over-nesting.md
hook-dependency-stability.md

Details

From the project README

React Refactor Best Practices

40 rules across 7 categories for React refactoring, 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 client-side form handling, see react-hook-form skill

Comments

Markdown supported