mcpField
R
react-hooks-best-practices

react-hooks-best-practices

github.com/siberiacancodeDevelopment2356 installsUpdated 3w ago
Repository

About react-hooks-best-practices

react-hooks-best-practices provides practical rules for developers writing, refactoring, or reviewing React components and custom hooks. Its guidance is organized around DX, optimization, and logic, with current rules focused on extracting complex logic and using watch mode.

Key features

  1. 01Organizes rules by DX, optimization, and logic
  2. 02Extracts complex feature logic into custom hooks
  3. 03Guides when to use watch mode
  4. 04Includes rule explanations and contrasting code examples

Use cases

  1. 01Refactor React components with complex logic
  2. 02Design composable custom hook APIs
  3. 03Review reactive update patterns in hooks
  4. 04Avoid unnecessary renders from high-frequency updates

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/siberiacancode/agent-skills --skill react-hooks-best-practices

After installing, type/react-hooks-best-practicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

AGENTS.md
metadata.json
README.md
rules/
_sections.md
_template.md
dx-extract-complex-hook.md
optimization-watch-mode.md

Details

From the project README

React Hooks Best Practices

Practical rules for using hooks in React applications and designing custom hooks across three lenses: DX, optimization, and logic.

When to Apply

Reference these guidelines when:

  • Writing React components that use hooks
  • Creating or refactoring custom hooks
  • Designing hook APIs that are ergonomic and composable
  • Reviewing dependencies, effects, refs, state, callbacks, and memoization
  • Reviewing hook APIs for unnecessary re-renders
  • Reviewing hook internals for stale closures, cleanup, SSR, and lifecycle correctness
  • Designing custom hooks that subscribe to high-frequency updates
  • Consuming hooks that expose snapshot, callback, and watch() APIs
  • Refactoring hooks that update React state on every browser event
  • Moving DOM-adjacent work out of React render state

Rule Categories by Priority

PriorityCategoryImpactPrefix
1DXHIGHdx-
2OptimizationHIGHoptimization-
3LogicHIGHlogic-

Quick Reference

1. DX (HIGH)
  • dx-extract-complex-hook - Move complex feature logic into custom hooks with grouped return contracts like form, state, functions, refs, and features
2. Optimization (HIGH)
  • optimization-watch-mode - Use watch() only when the UI needs reactive render data; keep hot updates in snapshots and callbacks otherwise
3. Logic (HIGH)

Rules coming soon.

How to Use

Read individual rule files for detailed explanations and examples:

rules/dx-extract-complex-hook.md
rules/optimization-watch-mode.md

Each rule file contains:

  • The problem the pattern solves
  • Incorrect and correct code examples
  • Guidance for hook authors and hook consumers
  • References to source material where relevant

Full Compiled Document

For the compiled overview, see AGENTS.md.

Comments

Markdown supported