React

From pproenca/dot-skills · View interactive version

React is an AI agent skill from the GitHub repository pproenca/dot-skills. React 19/19.2 modern patterns for concurrent rendering, Server Components, actions, ref-as-prop, document metadata, resource hints, hooks, and memoization — plus a category-major review/refactor algorithm with codebase-level (remove/dedup/reuse) findings. This skill should be used when writing React

How to use this skill

Skill file

React 19 Best Practices

Comprehensive React 19/19.2 best-practices guide for AI agents. Contains 49 rules across 9 categories, prioritized by impact from critical (concurrent rendering, server components) through to cross-cutting codebase hygiene (dedup, dead code, boundary coherence). Reflects React 19 headline changes: ref as a regular prop (forwardRef deprecated), native document metadata, resource preload APIs, useActionState, useOptimistic, use() hook, and <Context> as provider.

Rule files describe pattern shapes (not API names) and open with a "Shapes to recognize" section listing 2–4 syntactic disguises the same break can wear. Selected high-value rules (those whose disguises are most common in real codebases — form actions, ref-as-prop, derived state, context, the use() hook, useCallback/memo pairing) include an extra concrete "In disguise" incorrect/correct example pair to teach pattern detection beyond the grep-friendly cases.

When to Apply

How to Review or Refactor a Codebase

When the user asks to review, refactor, modernize, or audit React code — single file or whole repo — follow CODE0. Do not improvise.

Four non-negotiables from that doc:

  1. Two modes — never refuse a whole-repo audit. Pick Mode A (scoped, ≤~20 files) or Mode B (whole-tree: inventory pass + targeted sweeps + full Category 9). The algorithm tells you how to handle "audit my codebase" without dumping 800 files into context.
  2. Judgment over grep. Each rule names a pattern shape, not a syntactic marker. Read each rule's Shapes to recognize section before sweeping — grep finds the easy violations and misses the high-value ones (a manually-drilled callback ref because the author dodged forwardRef; an onSubmit doing the work of useActionState; a useState+useEffect shaped like derived state; a custom hook hiding the fetch dance). Grep is a trigger, never a verdict.
  3. Category-major, not file-major — with forcing functions. Sweep one category at a time across all in-scope files in priority order (CRITICAL → … → CROSS-CUTTING). The algorithm requires a scope declaration, per-category progress lines, and a final coverage table (category × file, cells ∈ {clean, N findings, n/a}). A missing category in the output is immediately visible.
  4. Codebase-level findings come from Category 9. Single-file rules can't tell you "these two components should be one" or "this hook is dead." Category 9 (Codebase Hygiene) sweeps the full inventory at the end and produces remove / dedup / reuse / consolidate findings.

Single-file ad-hoc questions ("is this hook OK?") can go straight to the relevant rule. The algorithm exists for the multi-file and whole-repo cases.

Rule Categories

| # | Category | Impact | Rules | Key Topics |

|---|----------|--------|-------|------------|

| 1 | Concurrent Rendering | CRITICAL | 6 | useTransition, useDeferredValue, Activity, batching, render purity |

| 2 | Server Components | CRITICAL | 6 | RSC boundaries, data fetching, streaming, serializable props |

| 3 | Actions & Forms | HIGH | 5 | Form actions, declarative form state, useOptimistic, server validation |

| 4 | Data Fetching | HIGH | 7 | use() hook, cache(), Suspense, document metadata, resource hints |

| 5 | State Management | MEDIUM-HIGH | 5 | Derived values, context split, functional updates, reducer |

| 6 | Memoization & Performance | MEDIUM | 5 | React Compiler, useMemo, useCallback, React.memo |

| 7 | Effects & Events | MEDIUM | 5 | useEffectEvent, cleanup, external stores, derived-state anti-pattern |

| 8 | Component Patterns | LOW-MEDIUM | 5 | ref-as-prop, composition, controlled vs uncontrolled, key reset |

| 9 | Codebase Hygiene | CROSS-CUTTING | 5 | Dedup, consolidation, dead code, boundary coherence, prop-shape drift |

Quick Reference

Critical patterns — get these right first:

React 19 modern idioms (do NOT generate React 18 patterns):

Common single-file mistakes — avoid these anti-patterns:

Codebase-level patterns — surface these in Category 9 sweeps:

Table of Contents

  1. Concurrent Rendering — CRITICAL
  1. Server Components — CRITICAL
  1. Actions & Forms — HIGH
  1. Data Fetching — HIGH
  1. State Management — MEDIUM-HIGH
  1. Memoization & Performance — MEDIUM
  1. Effects & Events — MEDIUM
  1. Component Patterns — LOW-MEDIUM
  1. Codebase Hygiene — CROSS-CUTTING (multi-file findings; required for whole-repo audits)

References

  1. https://react.dev
  2. https://react.dev/blog/2024/04/25/react-19-upgrade-guide
  3. https://react.dev/blog/2024/12/05/react-19
  4. https://react.dev/blog/2025/10/01/react-19-2
  5. https://react.dev/blog/2025/10/07/react-compiler-1
  6. https://react.dev/learn/you-might-not-need-an-effect
  7. https://github.com/facebook/react

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.