agent-skills / react-hooks-best-practices
AGENTS.md23 starsChanged 2 months agoMITView on GitHub
Version 1.0.0 siberiacancode August 2026 Note: This document is optimized for agents and LLMs writing React application code with hooks, creating custom hooks, and reviewing hook behavior. It groups guidance by DX, optimization, and logic. React hooks best practices for using hooks in React applications and designing custom hooks across DX, optimization, and logic. Use it for component hook usage, custom hook design, hook API review, feature-logic extraction, and hook correctness/performance checks. When a component owns complex feature logic, move…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/juniors-best-practice/AGENTS.mdAGENTS.md
- skills/react-best-practices/AGENTS.mdAGENTS.md
- skills/reactuse/AGENTS.mdAGENTS.md
- skills/testing-best-practices/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- integration-test-grillSkill
- juniors-best-practiceSkill
- vercel-react-best-practicesSkill
- react-hooks-best-practicesSkill
- reactuseSkill
- testcase-grillSkill
- testing-best-practicesSkill
- unit-test-grillSkill
- web-design-guidelinesSkill
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
When a component owns complex feature logic, move that logic into a custom hook.
- Distinctive: line 34
Do not extract just to make a file shorter.
- Very specific: line 36
Prefer grouped returns such as form, state, functions, refs, and features.
- Very specific: line 46
Use the callback path for imperative side effects such as CSS variables, canvas drawing, analytics, or DOM measurements.
- Very specific: line 48
Only call watch() at the usage site when JSX needs the live value.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
React Hooks Best Practices
Version 1.0.0
siberiacancode
August 2026
Note:
This document is optimized for agents and LLMs writing React application code with hooks, creating custom hooks, and reviewing hook behavior. It groups guidance by DX, optimization, and logic.
Abstract
React hooks best practices for using hooks in React applications and designing custom hooks across DX, optimization, and logic. Use it for component hook usage, custom hook design, hook API review, feature-logic extraction, and hook correctness/performance checks.
Table of Contents
- DX
- 1.1 Extract complex feature logic into hooks
- Optimization
- 2.1 Watch mode for hot updates
- Logic
1. DX
1.1 Extract complex feature logic into hooks
When a component owns complex feature logic, move that logic into a custom hook. This applies to forms, modals, mutations, routing, persistence, selected entities, derived values, and action handlers, even when there are no browser subscriptions.
Do not extract just to make a file shorter. Extract a cohesive feature scenario and expose a clear contract. Name the hook use + component/feature name, and name params types Use + component/feature name + Params, for example useCreateRoomForm and UseCreateRoomFormParams.
Prefer grouped returns such as form, state, functions, refs, and features; add domain-specific groups only when they make the component easier to read.
The component should read like UI composition. The hook should read like the feature controller.
2. Optimization
2.1 Watch mode for hot updates
For hooks that listen to hot external sources like mouse movement, scroll, observers, timers, or device sensors, do not force every update through React state. Keep the default path as callback + snapshot, and expose watch() as an explicit opt-in for components that actually render the value.
Use the callback path for imperative side effects such as CSS variables, canvas drawing, analytics, or DOM measurements. Throttling, debouncing, and requestAnimationFrame are consumer-side composition, not options baked into the primitive hook.
Only call watch() at the usage site when JSX needs the live value. One hook should support both modes: zero-render imperative usage by default, reactive rendering only when the consumer asks for it.
3. Logic
Rules coming soon.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

