Skip to content
OpenSmartRoute
Skillv1.0.0

react-refactor

Architectural refactoring guide for React applications covering component architecture, state architecture, hook patterns, component decomposition, coupling and cohesion, data flow, and refactoring sa

by shipshitdev(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from shipshitdev/skills (skills/react-refactor/SKILL.md). Install upstream with npx skills add shipshitdev/skills --skill react-refactor. Copyright stays with the author.

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

Category Impact Rules Key Topics
Component Architecture CRITICAL 8 Compound components, headless pattern, composition over props, client boundaries
State Architecture CRITICAL 7 Colocation, state machines, URL state, derived values
Hook Patterns HIGH 6 Single responsibility, naming, dependency stability, composition
Component Decomposition HIGH 6 Scroll test, extraction by change reason, view/logic separation
Coupling & Cohesion MEDIUM 4 Dependency injection, circular deps, stable imports, barrel-free
Data & Side Effects MEDIUM 4 Server-first fetch, TanStack Query, error boundaries
Refactoring Safety LOW-MEDIUM 5 Characterization 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 ArchitectureCRITICAL
  2. State ArchitectureCRITICAL
  3. Hook PatternsHIGH
  4. Component DecompositionHIGH
  5. Coupling & CohesionMEDIUM
  6. Data & Side EffectsMEDIUM
  7. Refactoring SafetyLOW-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

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/shipshitdev-skills-react-refactor/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

shipshitdev-skills-react-refactor.ocm.jsonjson
{
  "ocm": "1",
  "id": "shipshitdev-skills-react-refactor",
  "kind": "skill",
  "name": "react-refactor",
  "description": "Architectural refactoring guide for React applications covering component architecture, state architecture, hook patterns, component decomposition, coupling and cohesion, data flow, and refactoring safety. Triggers when refactoring React codebases, reviewing PRs for architectural issues, decomposing oversized components, or improving module boundaries.",
  "publisher": "shipshitdev",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "react",
      "refactoring",
      "architecture",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Architectural refactoring guide for React applications covering component architecture, state architecture, hook patterns, component decomposition, coupling and cohesion, data flow, and refactoring safety. Triggers when refactoring React codebases, reviewing PRs for architectural issues, decomposing oversized components, or improving module boundaries."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/shipshitdev/skills",
      "path": "skills/react-refactor/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/shipshitdev/skills/blob/HEAD/skills/react-refactor/SKILL.md",
      "key": "shipshitdev/skills/skills/react-refactor/SKILL.md"
    }
  },
  "instructions": "# React Refactor Best Practices\n\n40 rules across 7 categories for React refactoring, prioritized by impact from critical (component and state architecture) to incremental (refactoring safety).\n\n## When to Apply\n\n- Refactoring existing React codebases or planning large-scale restructuring\n- Reviewing PRs for architectural issues and code smells\n- Decomposing oversized components into focused units\n- Extracting reusable hooks from component logic\n- Improving testability of React code\n- Reducing coupling between feature modules\n\n## Rule Categories\n\n| Category | Impact | Rules | Key Topics |\n|----",
  "cost": {
    "context_tokens": 2162
  }
}

Fetch it by URL: GET /api/v1/registry/shipshitdev-skills-react-refactor/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.