# React patterns

> React patterns is an open-source agent skill for developer tools. Guides an agent on when React effects, dependencies and refs are appropriate. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/tonyghiani/ai-essentials/tree/main/skills/react-patterns
- **Repository:** https://github.com/tonyghiani/ai-essentials
- **GitHub stars:** 7
- **License:** MIT
- **Skill name:** react-patterns
- **Collection:** https://github.com/tonyghiani/ai-essentials
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-03

## About

This skill steers an AI coding agent toward disciplined React code, centred on the idea that an effect exists only to synchronise React with something outside React. Before writing or reviewing effects, refs or DOM access, the agent is pushed to derive values during render, reset state through keys, and move user-driven logic into event handlers. It also covers effect cleanup and idempotent setup, dependency arrays that must match what the effect reads, and data fetching that avoids races and unnecessary refetches.

The guidance is delivered as a written checklist and code patterns inside a single SKILL.md file, with no scripts or bundled tools. The agent applies it as review criteria: each effect should map to an external system, every async effect should guard against stale responses, and ref.current should only be touched in handlers or effects. Examples are written in TSX and reference hooks such as useEffect, useLayoutEffect, useRef and useMemo, plus React Query and framework loaders as preferred alternatives to hand-rolled fetching.

The skill expects a React codebase and an agent that loads skills from a SKILL.md folder. It does not set a tool allowlist, and the lint rules it mentions (eslint-plugin-react-hooks, REACT_EFFECT_RULES) apply only when the project uses them.

## When your agent uses it

> Effect, dependency, and ref discipline for React. Invoke before writing or reviewing any useEffect, useLayoutEffect, useRef, or DOM access, and when a component has state that could be derived instead. Catches the failure modes that cause stale UI, double-fetch, and render loops.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/tonyghiani/ai-essentials/tree/HEAD/skills/react-patterns)
- [License: MIT](https://github.com/tonyghiani/ai-essentials/tree/HEAD/skills/react-patterns)

## Features

- **Effect necessity check:** Helps the agent decide whether an effect is needed at all or whether logic belongs in render or an event handler.
- **Cleanup and idempotency rules:** Requires teardown that fully undoes setup and setup that stays safe under Strict Mode double-mounting.
- **Dependency array discipline:** Covers including every reactive value, avoiding suppressed lint warnings, and shrinking dependency lists.
- **Data fetching guidance:** Favours framework or library fetching APIs and covers race handling and a loading, error and value contract.
- **Ref and DOM safety:** Explains when to use refs versus state and which DOM operations are safe on React-owned nodes.
- **Review checklist:** Provides six questions the agent can run through when reviewing effects, state, dependencies and refs.

## Good for

- Review a React component for unnecessary useEffect calls
- Refactor derived state into computed values during render
- Fix stale data or race conditions in a fetch effect
- Add a subscription or event listener with proper cleanup
- Replace a list of refs with a single Map-based ref
- Audit dependency arrays for suppressed hook lint warnings

## Install

### Claude Code

This skill ships in the `ai-essentials` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add tonyghiani/ai-essentials
/plugin install ai-essentials@ai-essentials
```

Or copy only this skill to `~/.claude/skills/react-patterns`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/tonyghiani/ai-essentials.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/react-patterns &&
cp -R "$tmp/skills/react-patterns" ~/.claude/skills/react-patterns &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/react-patterns` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/react-patterns` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/tonyghiani/ai-essentials.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/react-patterns &&
cp -R "$tmp/skills/react-patterns" ~/.agents/skills/react-patterns &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/react-patterns` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/react-patterns` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/tonyghiani/ai-essentials.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/react-patterns &&
cp -R "$tmp/skills/react-patterns" ~/.cursor/skills/react-patterns &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/react-patterns` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/tonyghiani/ai-essentials.git --path skills/react-patterns
```

Or copy the folder to `~/.gemini/skills/react-patterns` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/react-patterns`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/tonyghiani/ai-essentials.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/react-patterns &&
cp -R "$tmp/skills/react-patterns" ~/.copilot/skills/react-patterns &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/react-patterns` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/tonyghiani/ai-essentials.git
```

Then copy `ai-essentials/skills/react-patterns` into your agent's skills folder as `react-patterns`. Agents that support SKILL.md read one folder per skill.

## FAQ

### When does React patterns trigger?

It is meant to be invoked before writing or reviewing useEffect, useLayoutEffect, useRef or DOM access, and when a component has state that could be derived instead.

### Does React patterns run any scripts or need extra tools?

No scripts are included and the folder contains a single file. The skill does not set an allowed tools list.

### Which AI clients does React patterns support?

It is a plain SKILL.md folder, so it follows the shared agent skills format and is not tied to a specific client.

### What kind of code does React patterns expect?

Its examples are written in TSX for React components and hooks, so it is aimed at React projects.

### How do I install React patterns in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/react-patterns to use it in all your projects, or to .claude/skills/react-patterns in one project. Or install the ai-essentials plugin, which includes it: /plugin marketplace add tonyghiani/ai-essentials, then /plugin install ai-essentials@ai-essentials.

### Does React patterns run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use React patterns?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to React patterns?

The closest alternatives to React patterns are Frontend react, Frontend patterns, React19 source patterns, Marco code style and Coding standards.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Frontend react](https://ai-powered.com/skills/frontend-react): Frontend react is an open-source agent skill for developer tools.
- [Frontend patterns](https://ai-powered.com/skills/frontend-patterns-fmarzochi): Frontend patterns is an open-source agent skill for developer tools.
- [React19 source patterns](https://ai-powered.com/skills/react19-source-patterns): React19 source patterns is an open-source agent skill for developer tools.
- [Marco code style](https://ai-powered.com/skills/marco-code-style): Marco code style is an open-source agent skill for developer tools.
- [Coding standards](https://ai-powered.com/skills/coding-standards-abdullayevtemurmalik): Coding standards is an open-source agent skill for developer tools.
- [React perf](https://ai-powered.com/skills/react-perf): React perf is an open-source agent skill for developer tools.
- [Readable code](https://ai-powered.com/skills/readable-code): Readable code is an open-source agent skill for developer tools.
- [Vercel react native skills](https://ai-powered.com/skills/vercel-react-native-skills): Vercel react native skills is an open-source agent skill for cloud and infrastructure.

---
Source: https://ai-powered.com/skills/react-patterns-tonyghiani
