Skip to main content
rulesSource-backedReview first Safety · Privacy

React Expert - CLAUDE.md Rules for Claude Code

Transform Claude into a framework-agnostic React core specialist focused on the built-in Hooks, the Rules of Hooks, and component fundamentals from the official React docs

by JSONbored·added 2025-09-15·
HarnessClaude Code
Review first review before installing

Open the source and read safety notes before installing.

Citation facts

Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.

Source URLs
https://react.dev/learn, https://github.com/JSONbored/awesome-claude/blob/main/content/rules/react-expert.mdx
Privacy notes
Guidance covers React state and effects; keep API keys, tokens, and secrets out of client-side React code and bundles, since anything in the client is exposed to users.
Author
JSONbored
Claim status
unclaimed
Last verified
2025-09-15

Decision playbook

Review trust signals before you adopt

Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.

Required checks are still incomplete. Finish source and safety verification before adopting this resource.

Compare context
Selected

0

Current score

68

Baseline

Delta

No baseline selected

No major trust-signal divergence detected in the current selection.

Source and provenance checks

Complete

Confirm ownership and provenance before trusting install instructions.

  • Source link availableRequired

    Open the canonical repository and verify ownership.

    Done
  • Source provenance statusRequired

    Marked as source-backed.

    Done
  • Metadata reviewed

    Registry metadata indicates a reviewed listing.

    Done

Safety and privacy checks

Required checks missing

Validate risk disclosures before installation or API wiring.

  • Safety notes presentRequired

    No safety notes listed.

    Pending
  • Privacy notes presentRequired

    Review data handling notes before connecting accounts or secrets.

    Done
  • Trust level risk gateRequired

    Trust level does not block evaluation.

    Done

Package and install checks

Needs review

Check package metadata and artifact integrity signals.

  • Install payload available

    Install or copy payload is available for review.

    Done
  • Package verification flag

    No package verification flag provided.

    Pending
  • Checksum metadata

    No checksum provided for downloaded artifact.

    Pending

Compare-driven decision checks

Needs review

Use compare context to validate trade-offs before adoption.

  • Compare tray has multiple entries

    Add at least one more entry to compare trust differences.

    Pending
  • Baseline comparison available

    No baseline peer selected yet.

    Pending
  • Diverging trust signals identified

    No major trust-signal divergence found.

    Pending

Setup at a glance

Copy & paste

Copy-ready — paste the snippet to get started.

Install command

Not provided

Config snippet

Not provided

Copy snippet

Provided

Prerequisites

None

Platforms

1 listed

Difficulty

20/100

Adoption plan

Balanced adoption plan

Current risk score 30/100. Use staged verification before broader rollout.

Risk 30
Adoption blockers
  • Safety notes are missing.

Pre-adoption checks

Validate source and review signals before any execution.

  • Confirm source provenanceRequired

    Source URL/provenance metadata is present.

    Done
  • Confirm metadata review state

    Listing has review metadata.

    Done
  • Verify install payload

    Install/config payload exists and can be inspected.

    Done

Security checks

Confirm safety, privacy, and package integrity signals.

  • Review safety notesRequired

    Safety notes missing; review source code paths before execution.

    Pending
  • Review privacy notesRequired

    Privacy notes are present.

    Done
  • Verify package integrity metadata

    No package verification/checksum metadata.

    Pending

Rollout

Adopt in controlled steps based on the selected plan.

  • Run in isolated sandbox firstRequired

    Use a constrained sandbox and observe behavior across multiple tasks.

    Pending
  • Roll out graduallyRequired

    Roll out to a small cohort before wider usage.

    Pending
  • Set monitoring and fallback

    Define rollback path and monitor errors after adoption.

    Pending

Evidence readiness

Evidence readiness matrix · balanced

Missing required evidence: Safety notes. Risk score 31.

Risk 31

Source provenance

Present

Source repository/provenance is listed.

Required in this preset

Metadata review

Present

Review metadata is present.

Required in this preset

Safety notes

Missing

Safety notes are missing.

Required in this preset

Privacy notes

Present

Privacy notes are present.

Optional in this preset

Package integrity

Missing

Package integrity metadata is missing.

Optional in this preset

Install payload

Present

Install payload is available.

Required in this preset

Required gaps: Safety notes

Decision timeline

Decision timeline · balanced

Blocking gaps: Review safety notes. Risk 28.

Risk 28

triage

Confirm source provenanceRequired

Source/provenance metadata is available.

Done

triage

Check metadata review statusRequired

Review metadata is available.

Done

verify

Review safety notesRequired

Safety notes are missing.

Pending

verify

Review privacy notes

Privacy notes are available.

Done

verify

Validate package integrity metadata

Package integrity metadata is missing.

Pending

rollout

Verify install payload and commandsRequired

Install payload is available.

Done

Blockers: Review safety notes

Safety & privacy surface

Safety & privacy surface

1 privacy note across 1 risk area. Review closely: credentials & tokens.

1 area
  • PrivacyCredentials & tokensGuidance covers React state and effects; keep API keys, tokens, and secrets out of client-side React code and bundles, since anything in the client is exposed to users.

Privacy notes

  • Guidance covers React state and effects; keep API keys, tokens, and secrets out of client-side React code and bundles, since anything in the client is exposed to users.

Schema details

Install type
copy
Reading time
2 min
Difficulty score
20
Troubleshooting
Yes
Breaking changes
No
Skill and platform metadata
Retrieval sources
https://react.dev/learnhttps://react.dev/reference/react/hookshttps://react.dev/reference/rules/rules-of-hookshttps://react.dev/learn/synchronizing-with-effects
Full copyable content
You are a framework-agnostic React core specialist. Ground every answer in React itself — components, props, state, and the built-in Hooks — not in any meta-framework. Follow these principles:

## Core Model

- A component is a JavaScript function that returns JSX; pass data in with props and treat props as read-only.
- Keep components pure during render: given the same props and state, return the same JSX and do not mutate inputs or perform side effects while rendering.
- State is a snapshot. Calling a setter schedules a re-render with the next value; it does not change the current variable. Read the new value on the next render, not on the line after the setter.
- Update state immutably — create new objects/arrays instead of mutating existing ones, so React can detect the change.

## The Built-in Hooks
- `useState` — declare a piece of local component state; the setter triggers a re-render.
- `useEffect` — synchronize a component with an external system (subscriptions, the DOM, network). It runs after commit; if it does not talk to an external system, you probably do not need it.
- `useRef` — hold a mutable value that persists across renders without triggering a re-render; commonly used to reference DOM nodes.
- `useMemo` — cache an expensive calculation between renders so it only recomputes when its dependencies change.
- `useCallback` — cache a function definition between renders, typically to keep referential identity stable for memoized children.
- `useContext` — read a value from the nearest matching Context provider above in the tree.
- `useReducer` — manage more complex state transitions with a reducer function.

## Rules of Hooks (non-negotiable)
- Only call Hooks at the top level of a component or a custom Hook — never inside loops, conditions, nested functions, or `try`/`catch`.
- Only call Hooks from React functions: function components or custom Hooks (names starting with `use`), not from plain JavaScript functions.
- These rules let React preserve Hook state by call order across renders; breaking them corrupts that state.

## Effects: use sparingly
- Reach for an Effect only to synchronize with an external system. To transform data for rendering, compute it during render; to handle a user event, do the work in the event handler.
- Always specify a complete dependency array; if an Effect subscribes or opens a connection, return a cleanup function that reverses it.

## Code Standards
- Prefer function components and the built-in Hooks over class components.
- Lift shared state to the closest common ancestor; pass it down via props.
- Give list items stable, meaningful `key` props (not array indexes when the list can reorder).
- Follow accessibility guidelines (WCAG 2.2) and use semantic HTML elements.

About this resource

You are a framework-agnostic React core specialist. Ground every answer in React itself — components, props, state, and the built-in Hooks — not in any meta-framework. Follow these principles:

Core Model

  • A component is a JavaScript function that returns JSX; pass data in with props and treat props as read-only.
  • Keep components pure during render: given the same props and state, return the same JSX and do not mutate inputs or perform side effects while rendering.
  • State is a snapshot. Calling a setter schedules a re-render with the next value; it does not change the current variable. Read the new value on the next render, not on the line after the setter.
  • Update state immutably — create new objects/arrays instead of mutating existing ones, so React can detect the change.

The Built-in Hooks

The core Hooks shipped in react itself. Each is callable only from a component or custom Hook (see Rules of Hooks below).

Hook What it does Reach for it when
useState Adds a local state variable and a setter that triggers a re-render. A component needs to remember a value between renders and update the UI when it changes.
useEffect Synchronizes a component with an external system after commit. You must subscribe, connect, or otherwise touch something outside React (not for rendering logic).
useRef Holds a mutable value across renders without causing a re-render. You need a DOM node reference or a value that should not trigger rendering.
useMemo Caches an expensive calculation between renders. A heavy computation reruns on every render with the same inputs.
useCallback Caches a function definition between renders. You pass a callback to a memoized child and need a stable reference.
useContext Reads the value of the nearest matching Context provider. Deeply nested components need shared data without prop drilling.
useReducer Manages state via a reducer function. State updates are complex or the next state depends on the previous one.

Grounded example: useState + useEffect with cleanup

import { useState, useEffect } from 'react';

function ChatRoom({ roomId }) {
  const [messages, setMessages] = useState([]);

  useEffect(() => {
    const connection = createConnection(roomId);
    connection.on('message', (msg) =>
      // update immutably — new array, not push
      setMessages((prev) => [...prev, msg])
    );
    connection.connect();
    // cleanup reverses the effect when roomId changes or on unmount
    return () => connection.disconnect();
  }, [roomId]); // complete dependency array

  return <MessageList items={messages} />;
}

The Effect synchronizes with an external system (the connection), declares a complete dependency array, and returns a cleanup function. State is updated immutably via the updater form so React sees a new value.

Rules of Hooks (non-negotiable)

  • Only call Hooks at the top level of a component or a custom Hook — never inside loops, conditions, nested functions, or try/catch.
  • Only call Hooks from React functions: function components or custom Hooks (names starting with use), not from plain JavaScript functions.
  • These rules let React preserve Hook state by call order across renders; breaking them corrupts that state.

Effects: use sparingly

  • Reach for an Effect only to synchronize with an external system. To transform data for rendering, compute it during render; to handle a user event, do the work in the event handler.
  • Always specify a complete dependency array; if an Effect subscribes or opens a connection, return a cleanup function that reverses it.

Code Standards

  • Prefer function components and the built-in Hooks over class components.
  • Lift shared state to the closest common ancestor; pass it down via props.
  • Give list items stable, meaningful key props (not array indexes when the list can reorder).
  • Follow accessibility guidelines (WCAG 2.2) and use semantic HTML elements.

Source citations

Add this badge to your README

Show that React Expert - CLAUDE.md Rules for Claude Code is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.

Listed on HeyClaude
[![Listed on HeyClaude](https://heyclau.de/badge/rules/react-expert.svg)](https://heyclau.de/entry/rules/react-expert)

How it compares

React Expert - CLAUDE.md Rules for Claude Code side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.

Field

Transform Claude into a framework-agnostic React core specialist focused on the built-in Hooks, the Rules of Hooks, and component fundamentals from the official React docs

Open dossier

Security-first React component architect with XSS prevention, CSP integration, input sanitization, and OWASP Top 10 mitigation patterns

Open dossier

A coding rule that makes Claude fluent in React Server Components — the React 19 component type that renders ahead of bundling, on a server or at build time. It guides async server components, the use client boundary, Suspense streaming, and Server Functions through the Next.js 15 App Router.

Open dossier

A coding rule that turns Claude into a React 19 concurrent-rendering specialist. It applies the documented React hooks — useTransition, useDeferredValue, useOptimistic, and Suspense — to keep interfaces responsive during heavy updates, stream server-rendered UI, and hydrate it selectively.

Open dossier
Next steps
Trust
Review statusReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewedReviewedMaintainer reviewed
Package trustPackage not verifiedPackage not verifiedPackage not verifiedPackage not verified
Source provenanceSource-backedSource-backedSource-backedSource-backed
Submitter
Install riskReview firstReview firstReview firstReview first
Notes Safety · Privacy Safety Privacy Safety Privacy Safety Privacy
Brand
Categoryrulesrulesrulesrules
Sourcesource-backedsource-backedsource-backedsource-backed
AuthorJSONboredJSONboredJSONboredJSONbored
Added2025-09-152025-10-162025-10-162025-10-16
Platforms
Claude Code
Claude Code
Claude Code
Claude Code
Source repo
Safety notes— missingRecommendations may include shell commands, package installs, or file edits; review and run any suggested changes yourself instead of applying them unverified.This rule is prompt guidance, not executable code, but it directs Claude to generate React Server Functions and Server Actions that perform server-side writes such as database mutations and cache revalidation; review and authorize generated mutations before running them. Server Actions execute on the server with full backend access, so validate every action input (for example with Zod) and add CSRF protection before exposing a mutation, as the rule itself recommends.This rule is prompt guidance, not executable code, but its examples use Server Actions with useActionState and useFormStatus to perform server-side writes such as form submissions and optimistic mutations; review and authorize generated mutations before running them. The optimistic-update examples call crypto.randomUUID() only to generate temporary client-side keys — it is the standard Web Crypto UUID API and involves no payments, wallets, or identity data.
Privacy notesGuidance covers React state and effects; keep API keys, tokens, and secrets out of client-side React code and bundles, since anything in the client is exposed to users.Guides Claude to read your repository files plus any code, logs, configuration, or credentials you share in the session; nothing is transmitted beyond the model, but review what you expose before sharing.The recommended patterns fetch user data directly on the server through database queries and session or auth lookups and read server environment variables; keep secrets server-only and never pass sensitive data as props to Client Components. Treat NEXT_PUBLIC_ environment variables as client-exposed and keep credentials, tokens, and personal records on the server, matching the rule's security guidance.The patterns render user-submitted form data and fetch user-specific records on the server through Suspense data sources; validate inputs and keep server-only data off the client, never exposing sensitive fields as props to Client Components.
Prerequisites— none listed— none listed— none listed— none listed
Install
Config
Citations
ClaimUnclaimedUnclaimedUnclaimedUnclaimed
Open 4 picks in the interactive comparison tool

Related guides

Signals

Loading live community signals…

More like this, weekly

A short, calm digest of reviewed Claude resources. Unsubscribe any time.