React Patterns

SkillAI & models

The react-patterns skill is a set of React principles your agent follows while working on your code. It covers component design, hook extraction rules, state management choices, React 19 patterns, performance profiling, error boundaries and TypeScript typing. The agent applies this guidance when reading, writing or editing React files.

Use React Patterns in Claude, ChatGPT or Ahel Desktop

Free. Sign in, add React Patterns and connect your AI. About a minute.

Also: Claude Code · Cursor · Codex

Then ask your AI: use the React Patterns skill

Details

Instructions available. Your AI can read the instructions. Execution depends on the setup they require.

Have a React project with TypeScript files the agent can read and edit.

React PatternsStart free

What your AI can do with it

  • Apply component design rules: one responsibility per component, props down, events up
  • Extract custom hooks such as useLocalStorage, useDebounce, useFetch and useForm
  • Choose state management based on complexity, from useState to Zustand or Redux Toolkit
  • Use React 19 hooks including useActionState, useOptimistic and use
  • Follow a performance order: check, profile with DevTools, find the bottleneck, fix it
  • Type component props with interfaces and unions

Getting started

  1. Have a React project with TypeScript files the agent can read and edit.
  2. Add the react-patterns skill to your agent so it loads the React principles.
  3. Confirm the agent has Read, Write, Edit, Glob and Grep access to your React files.
  4. Ask the agent to write or edit a component and it will apply the patterns.

What this skill tells your AI

The instructions your AI receives, as published by davila7/claude-code-templates in cli-tool/components/skills/development/react-patterns/SKILL.md and read by ahel’s review.

Principles for building production-ready React applications.


1. Component Design Principles

Component Types

TypeUseState
ServerData fetching, staticNone
ClientInteractivityuseState, effects
PresentationalUI displayProps only
ContainerLogic/stateHeavy state

Design Rules

  • One responsibility per component
  • Props down, events up
  • Composition over inheritance
  • Prefer small, focused components

2. Hook Patterns

When to Extract Hooks

PatternExtract When
useLocalStorageSame storage logic needed
useDebounceMultiple debounced values
useFetchRepeated fetch patterns
useFormComplex form state

Hook Rules

  • Hooks at top level only
  • Same order every render
  • Custom hooks start with "use"
  • Clean up effects on unmount

3. State Management Selection

ComplexitySolution
SimpleuseState, useReducer
Shared localContext
Server stateReact Query, SWR
Complex globalZustand, Redux Toolkit

State Placement

ScopeWhere
Single componentuseState
Parent-childLift state up
SubtreeContext
App-wideGlobal store

4. React 19 Patterns

New Hooks

HookPurpose
useActionStateForm submission state
useOptimisticOptimistic UI updates
useRead resources in render

Compiler Benefits

  • Automatic memoization
  • Less manual useMemo/useCallback
  • Focus on pure components

5. Composition Patterns

Compound Components

  • Parent provides context
  • Children consume context
  • Flexible slot-based composition
  • Example: Tabs, Accordion, Dropdown

Render Props vs Hooks

Use CasePrefer
Reusable logicCustom hook
Render flexibilityRender props
Cross-cuttingHigher-order component

6. Performance Principles

When to Optimize

SignalAction
Slow rendersProfile first
Large listsVirtualize
Expensive calcuseMemo
Stable callbacksuseCallback

Optimization Order

  1. Check if actually slow
  2. Profile with DevTools
  3. Identify bottleneck
  4. Apply targeted fix

7. Error Handling

Error Boundary Usage

ScopePlacement
App-wideRoot level
FeatureRoute/feature level
ComponentAround risky component

Error Recovery

  • Show fallback UI
  • Log error
  • Offer retry option
  • Preserve user data

8. TypeScript Patterns

Props Typing

PatternUse
InterfaceComponent props
TypeUnions, complex
GenericReusable components

Common Types

NeedType
ChildrenReactNode
Event handlerMouseEventHandler
RefRefObject

9. Testing Principles

LevelFocus
UnitPure functions, hooks
IntegrationComponent behavior
E2EUser flows

Test Priorities

  • User-visible behavior
  • Edge cases
  • Error states
  • Accessibility

10. Anti-Patterns

❌ Don't✅ Do
Prop drilling deepUse context
Giant componentsSplit smaller
useEffect for everythingServer components
Premature optimizationProfile first
Index as keyStable unique ID

Remember: React is about composition. Build small, combine thoughtfully.

Signals

GitHub stars
32k
Forks
4k
Last commit
Oct 2026

Others that do the same job

Questions

What is a react claude skill?
It is a skill that loads React principles for your agent to follow. The agent applies them when reading, writing or editing React files, covering hooks, state, performance and TypeScript.
Does it support React 19?
Yes. It includes React 19 patterns such as useActionState for form submission state, useOptimistic for optimistic UI updates and use for reading resources in render.
Advanced
Item type
skill
Key
react-patterns-davila7
Source
github.com/davila7/claude-code-templates