Token导航 LogoToken导航TokenDH.com
开发规范需要联网github未标认证来源可访问clear审计通过

react-best-practicesReact 最佳实践

Agent Skill

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

总安装

465

周安装

19

GitHub Stars

10

下载量

149
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:react-best-practices(React 最佳实践)
来源仓库:https://github.com/gohypergiant/agent-skills
仓库路径:skills/react-best-practices
安装命令:
npx skills add https://github.com/gohypergiant/agent-skills --skill react-best-practices
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/gohypergiant/agent-skills --skill react-best-practices

简介

react-best-practices 用于辅助前端页面、组件、样式和交互逻辑的开发与维护。

  • 适合生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构或定位布局问题。
  • 使用时需结合项目现有设计系统、路由和构建方式,避免生成孤立片段;涉及页面改动时应配合本地预览和构建检查。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装并使用。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

React Best Practices

Comprehensive performance optimization and best practices for React applications, designed for AI agents and LLMs working with React code.

When to Activate This Skill

Use this skill when the task involves:

Writing React Code

  • Creating new React components or hooks
  • Writing JSX elements or fragments
  • Implementing state management with useState, useReducer, etc.
  • Setting up effects with useEffect, useLayoutEffect
  • Creating memoized values or components with useMemo, useCallback, memo()

Refactoring React Code

  • Optimizing component re-renders
  • Reducing unnecessary state updates
  • Simplifying complex effect dependencies
  • Extracting components for better composition
  • Converting class components to functional components

Performance Optimization

  • Investigating slow renders or UI jank
  • Reducing bundle size (hoisting static JSX, optimizing SVG)
  • Implementing lazy loading or code splitting
  • Optimizing list rendering (virtualization, content-visibility)
  • Fixing memory leaks in effects or subscriptions

React-Specific Issues

  • Resolving hydration mismatches in SSR/SSG applications
  • Fixing stale closure bugs in callbacks
  • Debugging infinite re-render loops
  • Preventing unnecessary effect re-runs
  • Managing derived state correctly

Code Review

  • Reviewing React code for performance anti-patterns
  • Identifying improper use of hooks
  • Checking for React 19 deprecated patterns (forwardRef, default imports)
  • Ensuring proper memoization strategies

When NOT to Use This Skill

Do not activate for:

  • General JavaScript/TypeScript questions unrelated to React
  • Build configuration (webpack, vite, etc.) unless React-specific
  • CSS styling unless related to React performance (animations, content-visibility)
  • Backend API development
  • Testing setup (use a testing-specific skill if available)

Example Trigger Phrases

This skill should activate when users say things like:

Performance Issues:

  • "This component is re-rendering too much"
  • "My React app is slow when scrolling"
  • "Optimize this React component for performance"
  • "The input feels laggy when typing"
  • "This page takes forever to load initially"

Debugging Issues:

  • "Why is my useEffect running infinitely?"
  • "I'm getting hydration errors in Next.js"
  • "This callback always has stale/old values"
  • "My effect keeps re-subscribing to events"

Code Review:

  • "Review this React code for performance issues"
  • "Is this React component following best practices?"
  • "Can you optimize this React hook?"
  • "Check if this component has any performance problems"

React 19 Migration:

  • "Update this code to React 19"
  • "Replace forwardRef with the new pattern"
  • "Fix these React 19 deprecation warnings"
  • "Migrate to React 19 best practices"

Refactoring:

  • "Refactor this component to be more performant"
  • "Clean up these useEffect dependencies"
  • "Improve the performance of this list rendering"

How to Use

This skill uses a progressive disclosure structure to minimize context usage:

1. Start with the Overview (AGENTS.md)

Read AGENTS.md for a concise overview of all rules with one-line summaries.

2. Load Specific Rules as Needed

When you identify a relevant optimization, load the corresponding reference file for detailed implementation guidance:

Re-render Optimizations:

Rendering Performance:

Advanced Patterns:

Misc:

Quick References:

Automation Scripts:

  • scripts/ - Helper scripts to detect anti-patterns

3. Apply the Pattern

Each reference file contains:

  • ❌ Incorrect examples showing the anti-pattern
  • ✅ Correct examples showing the optimal implementation
  • Explanations of why the pattern matters

Examples

Example 1: Optimizing Re-renders

Task: "This component re-renders too frequently when the user scrolls"

Approach:

  1. Read AGENTS.md overview
  2. Identify likely cause: subscribing to continuous values (scroll position)
  3. Load subscribe-derived-state.md or transitions-non-urgent-updates.md
  4. Apply the pattern from the reference file

Example 2: Fixing Stale Closures

Task: "This callback always uses the old state value"

Approach:

  1. Read AGENTS.md overview
  2. Identify issue: stale closure in useCallback
  3. Load functional-setstate-updates.md
  4. Replace direct state reference with functional update

Example 3: SSR Hydration Mismatch

Task: "Getting hydration errors with localStorage theme"

Approach:

  1. Read AGENTS.md overview
  2. Identify issue: client-only state causing mismatch
  3. Load prevent-hydration-mismatch.md
  4. Implement synchronous script pattern

Important Notes

React Compiler Awareness

Many manual optimization patterns (memo, useMemo, useCallback, hoisting static JSX) are automatically handled by React Compiler.

Before optimizing, check if the project uses React Compiler:

  • If enabled: Skip manual memoization, but still apply state/effect/CSS optimizations
  • If not enabled: Apply all relevant optimizations from this guide

See react-compiler-guide.md for a complete breakdown of what the compiler handles vs what still needs manual optimization.

React 19+ Features

This skill covers React 19 features including:

  • useEffectEvent (19.2+) for stable event handlers
  • <Activity> component for preserving hidden component state
  • ref as a prop (replaces deprecated forwardRef)
  • Named imports only (no default import of React)

Performance Philosophy

  • Start with correct code, then optimize
  • Measure before optimizing
  • Optimize slowest operations first (network > rendering > computation)
  • Avoid premature optimization of trivial operations

Code Quality Principles

  • Prefer simple, readable code over clever optimizations
  • Only add complexity when measurements justify it
  • Document non-obvious performance optimizations

Additional Resources

Catch up on React 19 features:

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

29.9%
按下载量换算45

github-copilot

20.3%
按下载量换算30

windsurf

16.53%
按下载量换算25

OpenCode

12.38%
按下载量换算18

Antigravity

7.49%
按下载量换算11

trae

3.55%
按下载量换算5

安全审计

Gen Agent Trust Hub

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills