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

accelint-react-best-practicesaccelint React 最佳实践

Agent Skill

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

总安装

3,960

周安装

165

GitHub Stars

10

下载量

1,320
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

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

简介

accelint-react-best-practices 提供 React 应用的性能优化和最佳实践指导。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中审查或生成 React、Next.js、Vue、Tailwind、CSS 相关代码。
  • 帮助定位组件结构问题、避免常见反模式,并提升代码可维护性。
  • 安装命令为 npx skills add https://github.com/gohypergiant/agent-skills --skill accelint-react-best-practices。
  • 建议结合项目现有设计系统和构建方式使用,避免生成孤立片段;涉及页面改动时需配合本地预览确认效果。

SKILL.md

React Best Practices

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

NEVER Do React

These are the most critical anti-patterns that cause real production issues. Experts learned these the hard way through debugging sessions and performance investigations.

NEVER define components inside components — creates new component type on every render, causing full remount with state loss and DOM recreation. Results in input fields losing focus on keystroke, animations restarting unexpectedly, and useEffect cleanup/setup running on every parent render.

NEVER subscribe to searchParams/localStorage if you only read them in callbacks — causes component to re-render on every URL change or storage event even when the component doesn't display those values. Read directly in the callback instead: new URLSearchParams(window.location.search).

NEVER use object/array dependencies in useEffect — triggers effect on every render since objects are recreated with new references each time. Extract primitive values (id, name) from objects and use those as dependencies instead.

NEVER sync derived state with useState + useEffect — leads to extra re-renders, infinite loops, and stale intermediate states. Calculate derived values during render instead: const fullName = firstName + ' ' + lastName.

NEVER use client-only state (localStorage, cookies, device detection) directly in SSR components — causes hydration mismatches where server HTML doesn't match client render, resulting in React warnings, visual flickering, and broken interactivity. Use synchronous inline <script> before React hydrates.

NEVER use forwardRef in React 19+ — deprecated API. Use ref as a regular prop instead: function MyInput({ref}) {return <input ref={ref} />}.

NEVER create callbacks/objects/arrays inline as props to memoized components — breaks memoization since new reference is created each render. Extract to module scope, useMemo, or useCallback: const config = useMemo(() => ({theme}), [theme]).

NEVER put user interaction logic in useEffect — if it's triggered by a button click or form submit, put it directly in the event handler. Effects are for synchronization with external systems, not user-triggered actions.

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

4. Use the Report Template

When this skill is invoked, use the standardized report format:

Template: assets/output-report-template.md

The report format provides:

  • Executive Summary with impact assessment
  • Severity levels (Critical, High, Medium, Low) for prioritization
  • Impact analysis (potential bugs, type safety, maintainability, runtime failures)
  • Categorization (Type Safety, Safety, State Management, Return Values, Code Quality)
  • Pattern references linking to detailed guidance in references/
  • Phase 2 summary table for tracking all issues

When to use the audit template:

  • Skill invoked directly via /accelint-react-best-practices <path>
  • User asks to "review code quality" or "audit code" across file(s), invoking skill implicitly

When NOT to use the report template:

  • User asks to "fix this type error" (direct implementation)
  • User asks "what's wrong with this code?" (answer the question)
  • User requests specific fixes (apply fixes directly without formal report)

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

Using Skill Patterns Appropriately

Each reference file demonstrates ONE proven pattern, but React problems often have multiple valid solutions.

When applying patterns:

  1. ✅ Present the pattern from the reference file
  2. ✅ Mention alternative approaches when they exist
  3. ✅ Consider user's React version, project complexity, and team preferences
  4. ✅ For simple cases, suggest simpler solutions even if not in references

Example: For SSR hydration issues, prevent-hydration-mismatch.md shows the synchronous script approach, but a simple "mounted flag" pattern may be more appropriate for basic use cases.

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

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

34.7%
按下载量换算458

Claude

30.64%
按下载量换算404

Cursor

17.49%
按下载量换算231

Gemini CLI

8.58%
按下载量换算113

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

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

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills