react-patterns

Practical guidance for organising React applications, a JavaScript library for building user interfaces. It covers components, hooks, state management, and performance techniques.

In plain words
What is it for?
Use it when designing React components, writing custom hooks, choosing a state-management approach, and reducing unnecessary rendering with memoisation.
Why use it?
It helps developers choose clear ways to compose interface parts and manage changing data. It also explains where local, shared, server, and global state can fit.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/nth5693/gemini-kit/react-patterns
Any agent
npx skills add nth5693/gemini-kit --skill react-patterns
Clone the repo
git clone --depth 1 https://github.com/nth5693/gemini-kit

Made for: Claude Code, Codex.

Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 474 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00000 $0.00474
Opus 5 $0.00000 $0.00237
Sonnet 5 $0.00000 $0.00095
Haiku 4.5 $0.00000 $0.00047

Measured 2d ago against content hash 1ea58787a6b7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 2d 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.

skills/react-patterns/SKILL.md · 84 lines

What it actually says

React Patterns Skill

Overview

Modern React patterns, hooks, and state management principles.

Core Principles

1. Component Composition

  • Prefer composition over inheritance
  • Use children prop for flexibility
  • Create compound components for related UI

2. Hooks Best Practices

// Custom hook pattern
function useUser(userId: string) {
  const [user, setUser] = useState<User | null>(null);
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState<Error | null>(null);

  useEffect(() => {
    fetchUser(userId)
      .then(setUser)
      .catch(setError)
      .finally(() => setLoading(false));
  }, [userId]);

  return { user, loading, error };
}

3. State Management

  • Local state: useState for component-level
  • Shared state: Context + useReducer
  • Server state: React Query, SWR
  • Global state: Zustand, Jotai

4. Performance Patterns

// Memoization
const MemoizedComponent = React.memo(({ data }) => {
  return <div>{data.name}</div>;
});

// useMemo for expensive computations
const sortedItems = useMemo(() => {
  return items.sort((a, b) => a.name.localeCompare(b.name));
}, [items]);

// useCallback for stable references
const handleClick = useCallback(() => {
  doSomething(id);
}, [id]);

5. Error Boundaries

class ErrorBoundary extends React.Component {
  state = { hasError: false };

  static getDerivedStateFromError(error) {
    return { hasError: true };
  }

  componentDidCatch(error, errorInfo) {
    logError(error, errorInfo);
  }

  render() {
    if (this.state.hasError) {
      return <FallbackUI />;
    }
    return this.props.children;
  }
}

Anti-Patterns to Avoid

  • ❌ Prop drilling (use Context instead)
  • ❌ Mutating state directly
  • ❌ Missing dependency arrays
  • ❌ Over-using useEffect
  • ❌ Inline function definitions in render
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. 2d ago First seen · 84 lines · 0 tokens per session scan A 1ea58787a6b7

Subscribe to this mod's changes

react-patterns is a skill published in the GitHub repository nth5693/gemini-kit (374 stars, last pushed 5mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 474 tokens. 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-08-30.

Related

Other skills, from other repositories

triage-issue

Investigate a reported bug to root cause, then emit a TDD-shaped fix plan as an issue artifact. Trigger when the user reports a bug, says "triage", asks for issue investigation, or wants a fix plan before code changes.

OutlineDriven/odin-gemini-cli-extension · 54 tokens

minimalist-general

Subtraction-first thinking for non-coding tasks: writing, planning, research, summarizing, decision-making, or any request that isn't producing code. Same discipline as the minimalist coding skill — question whether the ask is even needed, reuse what already exists, do the smallest thing that fully answers it …

DivyeshJayswal/minimalist · 160 tokens

minimalist

Subtraction-first engineering for any coding task. Use when writing, fixing, refactoring, reviewing, or designing code; when choosing dependencies; or whenever the user asks for minimalist, less code, simplest thing, YAGNI, or complains about bloat. Prefer deletion, existing code, stdlib, and native platform features…

DivyeshJayswal/minimalist · 77 tokens

minimalist-audit

Audit a codebase or directory for deletion candidates: dead code, unused dependencies, single-use abstractions, config that never varies, and duplicated helpers. Use when the user says "minimalist audit" or asks what can be deleted from a project.

DivyeshJayswal/minimalist · 55 tokens

minimalist-gain

Report what minimalist actually measured in this session or project — LOC avoided, scope rejected, dependencies declined. Use when the user says "minimalist gain", "what did you save", or asks for the savings report.

DivyeshJayswal/minimalist · 48 tokens

minimalist-review

Review code, a diff, or a PR strictly for bloat: unrequested abstractions, dead scope, dependency creep, symptom-patching, and drive-by changes. Use when the user says "minimalist review", asks "is this over-engineered?", or wants a leanness review of a change.

DivyeshJayswal/minimalist · 67 tokens