Agent skill

React Best Practices

by ProgrammerAnthony in ProgrammerAnthony/Expert-Coding-Harness

A skill your agent uses when 用户需要React项目开发指导、代码规范制定、最佳实践落地、性能优化、架构设计时。触发场景:React开发、React代码优化、React架构设计、React Hooks使用、Next.js开发、React组件设计、React性能优化。

MITAuto-check passedFrontend & Design

Install React Best Practices

skills CLI
$ npx skills add ProgrammerAnthony/Expert-Coding-Harness --skill react-best-practices -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ProgrammerAnthony/Expert-Coding-Harness react-best-practices --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ProgrammerAnthony/Expert-Coding-Harness.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/react-best-practices .claude/skills/react-best-practices && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
react-best-practices
GitHub stars
235
Token cost
~693 tokens
SKILL.md length
110 words
Files
6 (incl. references)
Skills in repo
23
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when 用户需要React项目开发指导、代码规范制定、最佳实践落地、性能优化、架构设计时。触发场景:React开发、React代码优化、React架构设计、React Hooks使用、Next.js开发、React组件设计、React性能优化。

  • Works in 10 steps: 组件拆分原则 → Props设计 → 组件通信 → …
  • 用户需要React项目开发指导、代码规范制定、最佳实践落地、性能优化、架构设计时。触发场景:React开发、React代码优化、React架构设计、React Hooks使用、Next.js开发、React组件设计、React性能优化
  • SKILL.md covers 模式识别, 核心最佳实践体系, 输出规范 and 参考资源
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

React Best Practices is an agent skill from ProgrammerAnthony/Expert-Coding-Harness. Use when 用户需要React项目开发指导、代码规范制定、最佳实践落地、性能优化、架构设计时。触发场景:React开发、React代码优化、React架构设计、React Hooks使用、Next.js开发、React组件设计、React性能优化。

Its SKILL.md is about 690 tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files, including reference files (for example `README.md`, `references/nextjs-best-practices.md` and `references/react-component-design-guide.md`).

It sits in Frontend & Design, covering React components. It works with React and Next.js. The repository describes itself as: 生产级 AI Agent 技能集,辅助AI Harness应用于企业开发,覆盖代码审查、代码安全审计、TDD、需求工程、实施计划与子代理编排、架构设计、调试、前端开发与技能创建全流程。 The licence is MIT.

When your agent uses it

  • 用户需要React项目开发指导、代码规范制定、最佳实践落地、性能优化、架构设计时。触发场景:React开发、React代码优化、React架构设计、React Hooks使用、Next.js开发、React组件设计、React性能优化
  • Tasks that involve React components

Example prompts

  • “/react-best-practices”

Workflow steps

10 steps, taken from the step headings in SKILL.md.

  1. 组件拆分原则
  2. Props设计
  3. 组件通信
  4. Hooks使用规则
  5. 常用Hooks最佳实践
  6. 状态管理选型
  7. 状态管理最佳实践
  8. 渲染优化
  9. 列表优化
  10. 懒加载优化

What it can do on your machine

Read from SKILL.md and the folder at commit ab0b827. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are markdown).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

React Best Practices loads about 693 tokens when it runs, and up to ~5k if it reads all its reference files. Until then it costs about 37 tokens; SKILL.md has 110 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~37
When it runs · the whole SKILL.md, loaded when a task matches
~693
With references · SKILL.md plus every file in references/, read only if the agent opens them
~5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ProgrammerAnthony/Expert-Coding-Harness at commit ab0b827, republished under its MIT licence (© ProgrammerAnthony). 110 words, ~693 tokens.

Download SKILL.mdSave it as .claude/skills/react-best-practices/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
react-best-practices
description
Use when 用户需要React项目开发指导、代码规范制定、最佳实践落地、性能优化、架构设计时。触发场景:React开发、React代码优化、React架构设计、React Hooks使用、Next.js开发、React组件设计、React性能优化。

React最佳实践专家

铁律:基于React官方推荐和行业通用最佳实践给出建议,结合项目实际情况,不盲目追求新技术。优先考虑代码的可维护性和团队的接受度。

模式识别

启动时识别用户场景:

你的需求是:
1. 开发指导 — React项目开发过程中的问题解答、最佳实践建议
2. 代码优化 — 现有React代码的优化、重构
3. 架构设计 — React项目的架构设计、目录结构规划、状态管理选型
4. 规范制定 — React团队开发规范、代码规范、最佳实践文档编写

核心最佳实践体系

一、组件设计
1. 组件拆分原则
  • 单一职责原则:一个组件只做一件事
  • 颗粒度适中:避免超大组件,也避免过度拆分导致组件碎片化
  • 组件分层:基础组件/业务组件/页面组件分层清晰
  • 可复用性优先:通用逻辑和UI抽象为公共组件
2. Props设计
  • Props语义化,见名知意,避免过于复杂的Props结构
  • 合理设置默认值,避免空值错误
  • 避免Props Drilling:使用Context/状态管理库/组件组合解决
  • 避免传递不必要的Props,减少组件重渲染风险
3. 组件通信
  • 父子组件:Props + 回调函数
  • 兄弟组件:提升状态到公共父组件,或使用状态管理
  • 跨层级组件:Context API(适合低频更新的全局状态)或状态管理库
  • 非耦合组件:事件总线(慎用,避免逻辑混乱)
二、Hooks使用规范
1. Hooks使用规则
  • 只能在React组件顶层或自定义Hooks中使用
  • 不能在循环、条件判断、嵌套函数中使用
  • 自定义Hooks命名必须以use开头
2. 常用Hooks最佳实践
  • useState:合理拆分状态,避免单个state过于复杂
  • useEffect:依赖数组必须完整,避免无限循环和逻辑错误;及时清理副作用(定时器、事件监听、订阅)
  • useMemo/useCallback:只在需要的时候使用,避免过度优化带来的复杂度提升
  • useContext:拆分Context,避免大Context导致的全局重渲染
  • useReducer:适合复杂状态逻辑,或状态更新依赖之前的状态的场景
  • 自定义Hooks:抽象复用的状态逻辑,保持组件简洁
三、状态管理
1. 状态管理选型
  • 本地状态:组件内部状态使用useState/useReducer
  • 全局状态:
    • 小型项目:Context API + useReducer足够
    • 中型项目:Zustand/Jotai等轻量级状态管理库
    • 大型复杂项目:Redux Toolkit/Rematch等成熟状态管理方案
  • 服务端状态:使用React Query/SWR等专门的服务端状态管理库,避免和客户端状态混为一谈
2. 状态管理最佳实践
  • 区分本地状态和全局状态,避免将所有状态都放到全局
  • 状态扁平化,避免嵌套过深,便于更新和访问
  • 不可变更新:遵循React不可变数据原则,避免直接修改状态
  • 状态 selector 优化:使用memoized selector减少不必要的重渲染
四、性能优化
1. 渲染优化
  • 使用React.memo memo化组件,避免不必要的重渲染
  • 合理使用useMemo/useCallback缓存计算结果和回调函数
  • 拆分大组件,将变化的部分和不变的部分分离
  • 避免在render阶段执行昂贵的计算
2. 列表优化
  • 长列表使用虚拟滚动(react-window/react-virtualized)
  • 列表项必须绑定稳定的key,禁止使用index作为key
  • 批量更新列表数据,避免频繁触发重渲染
3. 懒加载优化
  • 路由懒加载:使用React.lazy + Suspense实现路由级别的代码分割
  • 组件懒加载:非首屏组件按需加载
  • 大体积第三方库按需引入,避免打包体积过大
五、Next.js专项最佳实践
  • 合理选择渲染模式:SSR/SSG/ISR/CSR根据页面场景选择
  • 使用App Router的新特性:Server Components减少客户端JS体积
  • 优化数据获取:使用fetch缓存、并行请求、避免瀑布流请求
  • 图片优化:使用next/image自动优化图片格式、大小、懒加载
  • 字体优化:使用next/font自动优化字体加载,避免布局偏移
六、可维护性规范
  • 组件命名使用大驼峰,文件名和组件名保持一致
  • TypeScript类型定义完整,避免any类型滥用
  • 复杂逻辑添加必要的注释,说明设计思路和注意事项
  • 避免副作用在组件顶层执行,统一放到useEffect中
  • 统一错误处理:使用Error Boundary捕获组件渲染错误
  • 单元测试:公共组件和复杂逻辑组件必须写单元测试

输出规范

根据用户场景给出结构化的建议:

markdown
### 📝 最佳实践建议
#### 必做项
- [建议内容]:[具体做法,为什么要这么做]
- 反例:[错误的写法示例]
- 正例:[正确的写法示例]

#### 建议项
- [建议内容]:[具体做法,收益是什么]
- 适用场景:[什么情况下适用]

#### 可选优化
- [优化内容]:[具体做法,适用场景]

参考资源

  • references/react-hooks-cheatsheet.md — React Hooks使用速查表
  • references/react-component-design-guide.md — React组件设计指南
  • references/react-state-management-comparison.md — React状态管理方案对比
  • references/nextjs-best-practices.md — Next.js开发最佳实践

© ProgrammerAnthony, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files (references) in skills/react-best-practices of ProgrammerAnthony/Expert-Coding-Harness.

  • SKILL.md
  • README.md
  • references/nextjs-best-practices.md
  • references/react-component-design-guide.md
  • references/react-hooks-cheatsheet.md
  • references/react-state-management-comparison.md

Open the folder on GitHubat commit ab0b827

Compare with similar skills

React Best Practices next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

React Best Practices compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
React Best Practices this skillProgrammerAnthony/Expert-Coding-Harness235—~693Automated safety check: PassMIT
Chakra UI v3 Builderchakra-ui/chakra-ui41k—~3.1kAutomated safety check: PassMIT
React View Transitions Guidevercel-labs/next-beats16710 repos~3.1kAutomated safety check: PassMIT
Vercel React Best Practicessanity-io/sanity6.4k130 repos~1.6kAutomated safety check: PassMIT
GSAP for Reactgreensock/gsap-skills16k4 repos~1.6kAutomated safety check: PassMIT
Chakra UI v2 to v3 Migrationchakra-ui/chakra-ui41k—~3.4kAutomated safety check: PassMIT

Similar skills

  • Chakra UI v3 Builder

    chakra-ui/chakra-ui

    Builds responsive, accessible Chakra UI v3 components and layouts, sets up Chakra in new or existing projects, and designs themes with tokens, semantic tokens and recipes.

    41k GitHub stars~3.1k tokensUpdated yesterday
    Frontend & DesignAuto-check passed
  • React View Transitions Guide

    vercel-labs/next-beats

    Official

    Guides implementing animated page and state transitions in React with the native View Transition API, covering shared elements, list reorders and directional navigation.

    167 GitHub starsUsed in 10 repos~3.1k tokens
    Frontend & DesignAuto-check passed
  • Official

    React and Next.js performance optimization guidelines from Vercel Engineering.

    6.4k GitHub starsUsed in 130 repos~1.6k tokens
    Frontend & DesignAuto-check passed
  • GSAP for React

    greensock/gsap-skills

    Shows how to run GSAP animations in React and Next.js with the useGSAP hook, refs, scoped selectors and automatic cleanup on unmount.

    16k GitHub starsUsed in 4 repos~1.6k tokens
    Frontend & DesignAuto-check passed
  • Chakra UI v2 to v3 Migration

    chakra-ui/chakra-ui

    Guides an upgrade from Chakra UI v2 to v3: inspect the project, swap packages, run the official codemod, then fix provider, color mode, props, theming and Next.js code.

    41k GitHub stars~3.4k tokensUpdated yesterday
    Frontend & DesignAuto-check passed
  • Creative Tim UI Blocks

    creativetimofficial/ui

    Helps install, generate and review Creative Tim UI blocks: shadcn/ui-based React and Tailwind sections that follow a restrained, production-minded design philosophy.

    12k GitHub stars~2.1k tokensUpdated 6 mo ago
    Frontend & DesignAuto-check: notes

More from ProgrammerAnthony/Expert-Coding-Harness

All 23 skills in this repo
  • Architecture Advisor

    ProgrammerAnthony/Expert-Coding-Harness

    A skill your agent uses when 用户需要设计新系统架构、评审或优化已有系统架构、选择技术方案时。触发场景:架构分析、架构设计、系统设计、architecture、架构优化、系统架构、架构评审、架构咨询、技术方案、技术设计、如何组织代码结构、模块划分、服务拆分、数据库选型、微服务设计。

    235 GitHub stars~673 tokensUpdated 4 mo ago
    Auto-check passed
  • Code Review Expert

    ProgrammerAnthony/Expert-Coding-Harness

    A skill your agent uses when 用户要求审查代码、评估代码质量、提交 PR 前检查、发现代码有潜在问题时。触发场景:代码审查、code review、审查代码、review、检查代码、代码检查、代码质量、代码评审、这段代码有问题吗、帮我看看代码、合并前检查。

    235 GitHub stars~806 tokensUpdated 4 mo ago
    Auto-check passed
  • Code Security Audit

    ProgrammerAnthony/Expert-Coding-Harness

    A skill your agent uses when 用户需要对代码进行安全审计、发现安全漏洞、上线前安全评估、检查代码是否存在安全风险时。触发场景:代码安全审计、安全审计、白盒审计、安全扫描、漏洞检测、漏洞挖掘、SQL注入、命令注入、XSS、SSRF、反序列化、认证绕过、越权、代码安全检查、security audit、code…

    235 GitHub stars~1.6k tokensUpdated 4 mo ago
    Auto-check passed
  • Debug Expert

    ProgrammerAnthony/Expert-Coding-Harness

    A skill your agent uses when 程序出现错误、异常、崩溃,或行为与预期不符,或测试失败,或无法定位问题根因时。触发场景:调试、debug、报错、错误、异常、bug、问题排查、故障排查、不工作、崩溃、无法运行、出错了、为什么不生效、运行报错、跑不起来、程序挂了。

    235 GitHub stars~986 tokensUpdated 4 mo ago
    Auto-check passed
  • Frontend Code Review

    ProgrammerAnthony/Expert-Coding-Harness

    A skill your agent uses when 用户需要审查前端代码(React/Vue/Next.js/TypeScript/Tailwind等)、检查代码质量、性能问题、可维护性、安全漏洞、最佳实践落地时。触发场景:前端代码评审、前端代码优化、React/Vue代码检查、TypeScript代码审查、前端性能优化、前端安全审计、前端代码规范检查。

    235 GitHub stars~614 tokensUpdated 4 mo ago
    Auto-check passed
  • Frontend Performance Optimization

    ProgrammerAnthony/Expert-Coding-Harness

    A skill your agent uses when 用户需要优化前端性能、提升页面加载速度、减少白屏时间、优化交互流畅度、进行性能排查时。触发场景:前端性能优化、页面加载慢、白屏时间长、卡顿、LCP/FID/CLS指标优化、前端性能分析、打包体积优化。

    235 GitHub stars~701 tokensUpdated 4 mo ago
    Auto-check passed

Works with

Questions about React Best Practices

What does React Best Practices do?

A skill your agent uses when 用户需要React项目开发指导、代码规范制定、最佳实践落地、性能优化、架构设计时。触发场景:React开发、React代码优化、React架构设计、React Hooks使用、Next.js开发、React组件设计、React性能优化。. React Best Practices is an agent skill from ProgrammerAnthony/Expert-Coding-Harness.

When should I use React Best Practices?

React Best Practices fits situations like: 用户需要React项目开发指导、代码规范制定、最佳实践落地、性能优化、架构设计时。触发场景:React开发、React代码优化、React架构设计、React Hooks使用、Next.js开发、React组件设计、React性能优化; tasks that involve React components.

How do I install React Best Practices in Claude Code?

Run `npx skills add ProgrammerAnthony/Expert-Coding-Harness --skill react-best-practices -a claude-code`. Or copy the skill folder (skills/react-best-practices in ProgrammerAnthony/Expert-Coding-Harness) into .claude/skills/react-best-practices in your project. Claude Code loads it when a task matches its description.

How do I install React Best Practices in Codex?

Run `npx skills add ProgrammerAnthony/Expert-Coding-Harness --skill react-best-practices -a codex`. Or copy the skill folder (skills/react-best-practices in ProgrammerAnthony/Expert-Coding-Harness) into .agents/skills/react-best-practices in your project. Codex loads it when a task matches its description.

Can I use React Best Practices in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ProgrammerAnthony/Expert-Coding-Harness --skill react-best-practices -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/react-best-practices, .gemini/skills/react-best-practices, .github/skills/react-best-practices and .opencode/skills/react-best-practices in your project.

What does React Best Practices need to run?

SKILL.md names no scripts, command-line tools or credentials: React Best Practices is instructions for the agent only.

Does React Best Practices access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is React Best Practices safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does React Best Practices use?

React Best Practices is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does React Best Practices use?

About 693 tokens (SKILL.md is roughly 2.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 4.3k tokens, read only when the agent opens those files.

What are the alternatives to React Best Practices?

Skills that share tags, products or a category with React Best Practices: Chakra UI v3 Builder (chakra-ui/chakra-ui, 41k stars), React View Transitions Guide (vercel-labs/next-beats, 167 stars), Vercel React Best Practices (sanity-io/sanity, 6.4k stars) and GSAP for React (greensock/gsap-skills, 16k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains React Best Practices?

ProgrammerAnthony (a GitHub user) maintains it in ProgrammerAnthony/Expert-Coding-Harness, which has 235 GitHub stars. The repository holds 23 skills in this directory. The repository was last updated on May 11, 2026.

Source: ProgrammerAnthony/Expert-Coding-Harness on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.