react
React component discipline: pure components, minimal state, effects as escape hatches. Invoke whenever task involves any interaction with React code — writing, reviewing, refactoring, debugging, or understanding JSX, hooks, component architecture, state management, or performance optimization.
What this skill does
# React
**Components are pure functions. State is minimal. Effects are escape hatches. If you reach for useEffect, verify you
actually need it.**
React rewards thinking in components: break UI into pieces, find minimal state, identify where it lives, and wire data
flow from parent to child. References contain extended examples, rationale, and edge cases for each topic area.
## References
- **Components** — `${CLAUDE_SKILL_DIR}/references/components.md` Composition, refs, metadata, custom elements
- **Hooks** — `${CLAUDE_SKILL_DIR}/references/hooks.md` Hook rules, custom hooks, `useSyncExternalStore`
- **State** — `${CLAUDE_SKILL_DIR}/references/state.md` Placement, reducers, context, actions
- **Performance** — `${CLAUDE_SKILL_DIR}/references/performance.md` Compiler, memoization, server components, streaming
- **Testing** — `${CLAUDE_SKILL_DIR}/references/testing.md` Query priority/variants, userEvent catalog, async patterns
## Component Design
### Thinking in React
Build UI in five steps:
1. Break UI into a component hierarchy — each component does one thing.
2. Build a static version first — props only, no state, no interactivity.
3. Find minimal state — if it doesn't change, is passed from a parent, or can be computed, it is not state.
4. Identify where state lives — find every component that renders based on the state, find their closest common parent,
put state there.
5. Add inverse data flow — pass state-setter callbacks down so children update parent state through event handlers.
### Purity
React assumes every component is a pure function. Same props + same state = same JSX. Never mutate props, state, or
variables declared before rendering.
- **Local mutation is fine.** Creating and mutating objects/arrays within the same render is safe — the mutation is
invisible outside that render.
- **Event handlers don't need to be pure** — they run outside of rendering.
### Component Structure
- One component per file. Small helpers co-located in the same file are acceptable but extract when reused.
- Prefer function declarations for components.
- Do not use `React.FC` — it adds implicit `children` typing and complicates generics. Use
`function Component(props: Props)`.
### Component Body Organization
Separate logic from rendering. The component body handles computation, state, and handler definitions. JSX is
declarative — it references results, not processes.
- **Handler object** — group all event handlers in a single `handle` object. This creates a clear boundary between logic
and rendering:
```tsx
const handle = {
submit() { /* ... */ },
inputChange(e: ChangeEvent<HTMLInputElement>) { setName(e.target.value); },
keyDown(e: KeyboardEvent) { if (e.key === 'Enter') handle.submit(); },
};
```
Reference in JSX as `onChange={handle.inputChange}`. Never inline handler logic in JSX.
- **Pre-render computation** — move list rendering and derived JSX out of the return statement into component body
variables:
```tsx
const tabElements: ReactNode[] = [];
for (const tab of allTabs) {
tabElements.push(<Tab key={tab.id}>{tab.name}</Tab>);
}
return <TabList>{tabElements}</TabList>;
```
JSX `.map()` inside the return statement is discouraged — compute element arrays in the body, reference them in JSX.
- **Conditional rendering** — simple conditions (`{isVisible && <Component />}`) are acceptable inline in JSX. When the
condition is complex or involves multiple branches, compute the result in the component body and reference the
variable in JSX.
### Composition
- Props flow down, events flow up. One-way data flow. Children never mutate parent state directly — they call callbacks.
- Composition over configuration. Pass JSX as `children` or render props instead of building components with dozens of
boolean flags.
- When a wrapper component updates its own state, React knows its `children` props haven't changed, so children skip
re-rendering.
- Use compound components (shared context between related sub-components) for complex UI patterns like flyout menus,
tabs, accordions.
- Prefer controlled components when parent needs to coordinate state across siblings. Prefer uncontrolled for isolated,
self-contained UI.
### Refs
- `ref` is a prop. Pass `ref` directly as a prop to function components. Never use `forwardRef` — it is deprecated.
- Ref callbacks can return a cleanup function, called when the element unmounts.
- Avoid implicit returns in ref callbacks — use block body `{}` not parentheses to prevent TypeScript confusion.
### Document Metadata
Render `<title>`, `<meta>`, `<link>` directly in components. React hoists them to `<head>` automatically. Works with
client-only apps, streaming SSR, and Server Components.
### Custom Elements
React provides full custom element support. Server rendering: primitive props render as attributes, non-primitive props
are omitted. Client rendering: props matching element instance properties are assigned as properties, others as
attributes.
## JSX Conventions
- Self-closing tags for components without children: `<Input />`.
- Boolean attributes without value: `<Input disabled />` not `disabled={true}`.
- Fragments to avoid wrapper divs: `<>...</>` or `<Fragment key={id}>`.
- Avoid `&&` with numbers — `count && <List />` renders `0`. Use `count > 0 && <List />` or a ternary.
- Never inline handler logic in JSX. Group all handlers in a `handle` object in the component body (see Component Body
Organization).
- Spread props sparingly — `{...props}` makes it unclear what a component accepts. Prefer explicit props.
- `key` on every list item. Stable, unique identifiers. Never use array index as key when items can reorder.
- No side effects during render. Event handlers for user actions, Effects for synchronization, render for pure
computation.
## Hooks
### `use()` — Context and Promises
- Prefer `use(MyContext)` over `useContext(MyContext)`. `use()` can be called inside conditionals and loops —
`useContext()` cannot.
- `use()` always looks for the closest provider **above** the calling component.
- `use(promise)` integrates with Suspense and Error Boundaries to read promise values.
- Do not create promises inside Client Components during render — they recreate every render. Pass promises from Server
Components or use a Suspense-compatible library.
- In Server Components, prefer `async`/`await` over `use()`.
- `use()` cannot be called in a try-catch block. Use Error Boundaries or `promise.catch()` instead.
### Hook Rules
- Top level only. Never call hooks inside conditions, loops, or nested functions. React relies on call order. Exception:
`use()` can be called conditionally.
- React functions only. Call hooks from function components or custom hooks — never from regular JavaScript functions.
- Exhaustive deps. Include all reactive values used inside the Effect in the dependency array. The linter enforces this
— don't suppress it. If a dependency causes unwanted re-runs, restructure the code.
- One Effect per concern. Don't merge unrelated sync logic into a single Effect. Separate Effects for separate external
systems.
### Effects Are Escape Hatches
Use Effects **only** to synchronize with external systems (DOM APIs, network, browser events). Not for transforming
data, handling user events, or state derivation.
**You don't need an Effect for:**
- **Transform data for rendering** — Compute during render
- **Handle user events** — Call in event handler
- **Reset state on prop change** — Use `key={userId}` on the component
- **Adjust state on prop change** — Compute: `items.find(...)` during render
- **Notify parent of state change** — Call `onChange` in the event handler
- **Share logic between handlers** — Extract a function, call from both handlers
- **Chain state updates** — Calculate all state in one event handler
**You DO need an Effect for:**
- Subscribing to browser events (online/offline, resize, intersection)
- Connecting tRelated 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.