react-patterns

react-patterns is a skill for Claude Code, Codex from tmj-90/gaffer. It costs 116 tokens per session (1,602 once invoked), scanned A, original, Apache-2.0.

A set of conventions for building user interfaces with React, a JavaScript library for component-based web interfaces. It explains how to handle state, effects, component composition, keys, and server or client components.

In plain words
What is it for?
It helps add or change React components, hooks, context, effects, suspense boundaries, and server components. It covers computing derived values, reacting to user events, cleanup, stable keys, and composing small components.
Why use it?
Misused state and effects can cause stale data, unnecessary rendering, broken subscriptions, or confusing component behaviour. These rules keep the interface model aligned with how React updates the screen.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It helps add or change React components, hooks, context, effects, suspense boundaries, and server components. It covers computing derived values, reacting to user events, cleanup, stable keys, and composing small components.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tmj-90/gaffer/react-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add tmj-90/gaffer --skill react-patterns
Clone the repo
git clone --depth 1 https://github.com/tmj-90/gaffer

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for react-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/tmj-90/gaffer/react-patterns/github.svg)](https://agentmods.dev/skills/tmj-90/gaffer/react-patterns)
Your own site
<a href="https://agentmods.dev/skills/tmj-90/gaffer/react-patterns"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/react-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for react-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/tmj-90/gaffer/react-patterns"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/react-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 116 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,602 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00116 $0.01602
Opus 5.5 $0.00046 $0.00641
Sonnet 5.5 $0.00023 $0.00320
Haiku 4.5 $0.00012 $0.00160

Measured 16d ago against content hash 481e76d0ca84, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

react-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 16d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

runner/skills/react-patterns/SKILL.md · 101 lines

How it starts

The opening of the file, as written. The whole thing — 101 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Write React the way React wants to be written

Most React bugs break the Rules of React: components and hooks must be pure (same inputs → same output, no side effects during render), props and state are immutable snapshots, and hooks are called unconditionally at the top level of a component or custom hook. Model UI as a function of state, keep effects for synchronising with systems outside React, and compose small components. This pack sits on top of the typescript-conventions skill; the design bar is frontend-foundations.

Steps

  1. Read the repo's React set-up. React version (19.x adds Actions, use, ref-as-prop; 19.2 adds useEffectEvent and <Activity>), whether the React Compiler is enabled (babel/SWC plugin in the build config), eslint-plugin-react-hooks config, framework (Next.js App Router, Remix/React Router, Vite SPA), and the state/data libraries (the frontend-state-management and frontend-data-fetching skills). Call search_lore and copy a sibling component's shape.
  2. Keep render pure. No fetches, subscriptions, Math.random()/Date.now() for output, or mutation of props, state or module variables during render. Never mutate state in place (items.push); create a new value. Strict Mode double-invokes render and effects in development precisely to expose impurity — "the effect runs twice" means the effect lacks a correct cleanup, not that Strict Mode should be removed.
  3. You probably don't need that effect. Before writing useEffect, check:
    • Derived from props/state? Compute it during render (useMemo only if measured as expensive and the Compiler is off).
    • Caused by a user action? Put it in the event handler.
    • Reset when an id changes? Key the component by the id.
    • Fetching? Use the data layer, a loader, or a Server Component. Effects remain for synchronisation: subscriptions, timers, imperative widgets, DOM measurement (useLayoutEffect only when you must measure before paint). Every effect that starts something returns a cleanup that stops it.
  4. Honest dependencies. The array lists every reactive value the effect reads; never disable react-hooks/exhaustive-deps. Logic that must read the latest value without re-running the effect (logging, analytics, a callback prop) goes in useEffectEvent (React 19.2+) or a ref updated in an effect on older versions. Move pure helpers outside the component instead of wrapping them in useCallback.
  5. Memoisation policy. With the React Compiler on, do not add memo/useMemo/ useCallback by hand unless profiling shows the Compiler bailed out; fix the lint diagnostics that cause bail-outs instead. With it off, memoise only what the profiler shows is costly (the frontend-performance skill).
  6. Keys are identities. Use stable ids from the data; never array indexes for lists that reorder, filter or delete, and never generated keys (Math.random()) — both lose input state and focus.
  7. Compose instead of configuring. children and slot props over boolean variant props; custom hooks (named useX, calling hooks) for reusable stateful logic; context for rarely changing shared values, split by change frequency. In React 19 ref is a prop (no forwardRef) and <Context value> is the provider.
  8. Forms and mutations with Actions where the repo uses them: useActionState for submit-with-result, useFormStatus for a pending button in a child, useOptimistic for an optimistic value that reverts when the action settles. Otherwise follow the repo's form library (the frontend-forms-and-validation skill).
  9. Async boundaries. <Suspense> with a real fallback around the part that waits and an error boundary at route or section level; startTransition/useDeferredValue for non-urgent updates so typing stays responsive. No async function passed directly to useEffect; an inner async function checks a cancelled flag or AbortSignal.
  10. Server Components (Next.js App Router, RSC). Server by default. "use client" marks a module boundary — push it to the interactive leaves; everything passed across it must be serialisable. Import server-only code through modules guarded with import 'server-only'. "use server" functions (Server Functions/Actions) are public HTTP endpoints: authenticate, authorise and validate their arguments inside the function every time (the security-authz and security-input-validation skills). Render nothing that differs between server and client (time, locale, window) without a client-only boundary, or hydration fails.
  11. Test and evidence. Per AC, a component test through the rendered UI (the frontend-testing skill); run type-check, lint (hooks rules included) and tests. Record per-AC evidence with the record-evidence skill, then stop.

Read the full file on GitHub · 101 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 16d ago Changed · +23 lines · +13 tokens per session 481e76d0ca84
  2. 19d ago First seen · 78 lines · 103 tokens per session scan A 277ae82bc448

Subscribe to this mod's changes

react-patterns is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 17d ago), licensed Apache-2.0. It adds 116 tokens to every session and 1,602 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-28.

Related

Other skills, from other repositories

bulwark-brainstorm

Role-based brainstorming with dual modes: --scoped (sequential Task tool, 5 roles) and --exploratory (Agent Teams peer debate, 4 roles). Use for feasibility assessment and idea validation.

QBall-Inc/the-bulwark · 50 tokens

plan-creation

Create structured implementation plans via a 4-role scrum team (Product Owner, Architect, Eng/Delivery Lead, QA/Critic) with optional Agent Teams peer debate mode.

QBall-Inc/the-bulwark · 38 tokens

anthropic-validator

Validates Claude Code assets (skills, hooks, agents, commands, MCP servers, plugins) against official Anthropic standards. Fetches latest docs dynamically and produces structured validation reports.

QBall-Inc/the-bulwark · 40 tokens

create-subagent

Generates single-purpose Claude Code sub-agents for use via the Task tool. Use when creating dedicated sub-agents, scaffolding agent definitions, or generating agents with diagnostics and permissions setup.

QBall-Inc/the-bulwark · 42 tokens

test-audit

Audit test suites for T1-T4 violations using AST analysis, mock detection, and multi-stage synthesis. Invoke when user asks to audit tests, check test quality, find mock violations, review test effectiveness, or inspect test suites for over-mocking. Triggers automatic rewrites when quality gates fail.

QBall-Inc/the-bulwark · 0 tokens

code-review

Comprehensive code review with distinct aspect based sections. Use when reviewing code, checking for security issues, finding type safety problems, auditing code quality, or when user asks to review code, PRs or changes. Three-phase workflow runs static tools, LLM judgment, and writes diagnostic log.

QBall-Inc/the-bulwark · 61 tokens