react-ops
React development patterns, hooks, state management, Server Components, and performance optimization. Use for: react, hooks, useState, useEffect, jsx, tsx, next.js, nextjs, app router, server components, RSC, zustand, react query, component patterns, react testing library, error boundary, suspense, react 19.
What this skill does
# React Operations
Comprehensive React skill covering hooks, component architecture, state management, Server Components, and performance optimization.
## Hook Selection Decision Tree
```
What problem are you solving?
│
├─ Storing UI state that triggers re-renders
│ ├─ Simple value (string, number, boolean)
│ │ └─ useState
│ ├─ Complex state with multiple sub-values and logic
│ │ └─ useReducer (actions + reducer = predictable transitions)
│ └─ Derived from existing state
│ └─ Calculate inline or useMemo — not useState
│
├─ Referencing a value WITHOUT triggering re-render
│ ├─ DOM element reference
│ │ └─ useRef<HTMLElement>(null) + ref={ref}
│ └─ Mutable value (timer ID, previous value, counter)
│ └─ useRef (mutate ref.current directly)
│
├─ Running a side effect
│ ├─ After every render (or specific deps)
│ │ ├─ Needs cleanup (subscription, timer, abort)
│ │ │ └─ useEffect with return cleanup function
│ │ └─ No cleanup (logging, analytics)
│ │ └─ useEffect with empty or dep array
│ ├─ Before browser paint (DOM mutation, animation)
│ │ └─ useLayoutEffect
│ └─ Triggered by user action (not render)
│ └─ Call it directly in the event handler — not useEffect
│
├─ Caching an expensive computation
│ └─ useMemo(() => expensiveCalc(a, b), [a, b])
│
├─ Stable callback reference for child props / event handlers
│ └─ useCallback(() => doThing(dep), [dep])
│
├─ Reading shared context value
│ └─ useContext(MyContext)
│
├─ Generating stable unique ID (forms, aria)
│ └─ useId()
│
├─ Syncing external store (Redux, Zustand internals)
│ └─ useSyncExternalStore(subscribe, getSnapshot)
│
└─ React 19+
├─ Await a promise or read context
│ └─ use(promise | context)
├─ Form submit state (pending, data, action)
│ └─ useFormStatus / useActionState
└─ Optimistic UI before server response
└─ useOptimistic(state, updateFn)
```
## Component Pattern Decision Tree
```
What's your composition challenge?
│
├─ Group of related components sharing implicit state
│ (Tabs, Accordion, Select, Menu)
│ └─ Compound Components with Context
│ Parent provides state via Context
│ Children consume via useContext
│
├─ Consumer needs to control rendering output
│ └─ Render Props: children(props) or render={fn}
│ Good for: headless UI, flexible layouts
│
├─ Apply cross-cutting concerns (auth, logging, theming)
│ to multiple components
│ └─ Higher-Order Components (HOC)
│ Wrap with withAuth(Component) or withLogging(Component)
│ Prefer custom hooks for pure logic
│
├─ Encapsulate reusable stateful logic
│ └─ Custom Hook — always prefer over HOC when possible
│ Composable, testable, no wrapper hell
│
├─ Need imperative control from parent (focus, scroll, reset)
│ └─ forwardRef + useImperativeHandle
│
├─ Render content outside DOM hierarchy (modal, tooltip, toast)
│ └─ Portal: createPortal(content, document.body)
│
├─ Accept arbitrary children/slots without prop drilling
│ └─ Slot pattern via children, or named props (header, footer)
│
└─ Polymorphic rendering (button that renders as <a> or div)
└─ as prop pattern with TypeScript generics
```
## State Management Decision Tree
```
Where does this state live and who owns it?
│
├─ Only one component needs it
│ └─ useState or useReducer (local state)
│
├─ A few nearby components need it
│ └─ Lift state to nearest common ancestor + prop drilling
│ (2-3 levels is fine)
│
├─ Many components need it, rarely changes
│ (theme, locale, auth user)
│ └─ React Context API
│ Split contexts by update frequency
│ Avoid single giant context
│
├─ Global client state, changes often
│ (shopping cart, UI preferences, navigation)
│ ├─ Simple/small app → Zustand (minimal boilerplate)
│ ├─ Atomic updates, React Suspense integration → Jotai
│ └─ Large team, time-travel debugging, complex logic → Redux Toolkit
│
├─ Server state (remote data, cache, sync)
│ (API data, database queries)
│ └─ TanStack Query (React Query)
│ Handles: caching, background refetch, loading/error
│ Don't use useState + useEffect for server data
│
└─ Form state
└─ React Hook Form + Zod validation
(controlled inputs are fine for simple forms)
```
## React 19 Quick Reference
| Feature | API | Purpose |
|---------|-----|---------|
| `use()` hook | `use(promise)` / `use(context)` | Await promises in render, read context conditionally |
| Actions | `async function action(formData)` | Async transitions with built-in pending state |
| `useActionState` | `useActionState(action, initialState)` | Action result + pending state |
| `useFormStatus` | `useFormStatus()` | Pending/data/method inside form |
| `useOptimistic` | `useOptimistic(state, updateFn)` | Optimistic UI before server response |
| React Compiler | Automatic memoization | Replaces most `memo`, `useMemo`, `useCallback` |
| `ref` as prop | `<Input ref={ref}>` | No more forwardRef wrapper needed |
| `<Context>` as provider | `<MyContext value={val}>` | No more `<MyContext.Provider>` |
```tsx
// React 19: use() for data fetching in Server Components
import { use } from 'react';
function UserProfile({ userPromise }: { userPromise: Promise<User> }) {
const user = use(userPromise); // suspends until resolved
return <h1>{user.name}</h1>;
}
// React 19: useActionState
import { useActionState } from 'react';
function ContactForm() {
const [state, action, isPending] = useActionState(
async (prevState: State, formData: FormData) => {
const result = await submitContact(formData);
return result;
},
{ error: null }
);
return (
<form action={action}>
<input name="email" type="email" />
<button disabled={isPending}>
{isPending ? 'Sending...' : 'Send'}
</button>
{state.error && <p>{state.error}</p>}
</form>
);
}
```
## Server vs Client Components
```
Does this component need...?
│
├─ useState, useReducer, useContext
│ └─ Client Component ('use client')
│
├─ useEffect, useLayoutEffect
│ └─ Client Component ('use client')
│
├─ Browser APIs (window, document, localStorage)
│ └─ Client Component ('use client')
│
├─ Event handlers (onClick, onChange, onSubmit)
│ └─ Client Component ('use client')
│
├─ Third-party libraries that use hooks/browser APIs
│ └─ Client Component ('use client')
│
├─ Direct database/file system access
│ └─ Server Component (default, no directive)
│
├─ Access to env vars (server-only secrets)
│ └─ Server Component
│
├─ Large dependencies you want to keep off the client bundle
│ └─ Server Component
│
└─ async/await at the top level
└─ Server Component
```
**Client boundary rules:**
- `'use client'` marks a boundary — everything imported below it becomes client JS
- Server Components can import Client Components (they pass as props/children)
- Client Components CANNOT import Server Components directly
- Pass Server Component output as `children` prop to Client Components
- Server data → Client: pass as serializable props only (no functions, classes, DOM nodes)
## Performance Checklist
| Technique | When to Use | When NOT to Use |
|-----------|-------------|-----------------|
| `React.memo` | Component re-renders often with same props | Nearly everything — adds comparison overhead |
| `useMemo` | Expensive calculation (>1ms), stable dep array | Primitive values, simple expressions |
| `useCallback` | Callback passed to memoized child or in dep array | Inline handlers on DOM elements |
| `React.lazy` + `Suspense` | Large components not needed on initial load | Small components, SSR-critical content |
| `useTransition` | Non-urgent state updates (filtering, sorting) | Time-sensitive UI (typing, hover) |
| `useDeferredValue` | Derived expensive render from fast-changing value | Same as above |
| Virtualization | Lists >100 items | Small lists — overhead not worth it |
| React Compiler (v19) | Automatic — replaces most manual memoization | Opt-out with `"use no memo"` if needed |
## Common Gotchas
| Gotcha | WhRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.