Back to Skills

react

KubrickCode
Updated Yesterday
151 views
1
1
View on GitHub
Metareacttestingapidesign

About

This skill provides React development standards and best practices for building high-quality components. It covers functional components, hooks usage, state management, performance optimization, and accessibility compliance. Use it when developing React components, creating custom hooks, or implementing TypeScript integration for type-safe components.

Quick Install

Claude Code

Recommended
Plugin CommandRecommended
/plugin add https://github.com/KubrickCode/ai-config-toolkit
Git CloneAlternative
git clone https://github.com/KubrickCode/ai-config-toolkit.git ~/.claude/skills/react

Copy and paste this command in Claude Code to install this skill

Documentation

React Development Standards

Component Structure

Rules Per File Component

Exported components should be one per file when possible; internal components can have multiple if necessary (not recommended).

  • Forbid export default (refactoring and tree-shaking issues)
  • Use named exports only
  • Don't export internal helper components
  • File order: Main exported component → Additional exported components → Internal helper components

State Management Rules

State Management Hierarchy

  1. Local State (useState): Used only in a single component
  2. Props Drilling: Allow maximum 2 levels
  3. Context API: Use when 3+ levels of prop drilling needed
  4. Global State (Zustand, etc.):
    • Shared across 5+ components
    • Server state synchronization needed
    • Complex state logic (computed, actions)
    • Developer tools support needed

Hook Usage Rules

Custom Hook Extraction Criteria

  • 3+ combinations of useState/useEffect
  • Reused in 2+ components
  • 50+ lines of logic

Minimize useEffect Usage

  • useEffect only for external system synchronization
  • Handle state updates in event handlers
  • Calculate derived values directly or with useMemo
  • Use only when truly necessary and comment why
// ❌ Bad: useEffect for state synchronization
useEffect(() => {
  setFullName(`${firstName} ${lastName}`);
}, [firstName, lastName]);

// ✅ Good: Direct calculation
const fullName = `${firstName} ${lastName}`;

Props Rules

Rules for Adding Props to Common Components

  • Review structure before adding new props (prevent indiscriminate prop additions at shared level)
  • Check for single responsibility principle violations
  • Consider composition pattern for 3+ optional props
  • Review if can be unified with variant prop

Conditional Rendering

Basic Rules

// Simple condition: && operator
{isLoggedIn && <UserMenu />}

// Binary choice: ternary operator
{isLoggedIn ? <UserMenu /> : <LoginButton />}

// Complex condition: separate function or early return
const renderContent = () => {
  if (status === 'loading') return <Loader />;
  if (status === 'error') return <Error />;
  return <Content />;
};

Activity Component

  • Use when pre-rendering hidden parts or maintaining state is needed
  • Manage with visible/hidden mode
  • Utilize for frequently toggled UI like tab switching, modal contents

Memoization

Using React Compiler

  • Rely on automatic memoization
  • Manual memoization (React.memo, useMemo, useCallback) only for special cases
  • Use as escape hatch when compiler cannot optimize

GitHub Repository

KubrickCode/ai-config-toolkit
Path: .claude/skills/react

Related Skills

evaluating-llms-harness

Testing

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

View skill

content-collections

Meta

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill

Algorithmic Art Generation

Meta

This skill helps developers create algorithmic art using p5.js, focusing on generative art, computational aesthetics, and interactive visualizations. It automatically activates for topics like "generative art" or "p5.js visualization" and guides you through creating unique algorithms with features like seeded randomness, flow fields, and particle systems. Use it when you need to build reproducible, code-driven artistic patterns.

View skill