AGENT SKILL

react

React core guidance for purity, state modeling, effects discipline, and predictable component design in React projects.

使用场景前端开发
License 许可
MIT
最近更新
2026-09-14
Stars
★ 1
Forks
0

01 前言 Front Matter

name
react
agents
[ "coder", "sidekick-reviewer", "architect", "feature-designer", "feature-reviewer", "planner", "ask", "builder", "orchestrator" ]
detect
{ "content": [ { "file": "package.json", "contains": "\"react\"" } ] }
description
React core guidance for purity, state modeling, effects discipline, and predictable component design in React projects.

03 SKILL.md 正文

Scope

  • In scope: React component/hook correctness, render purity, state updates, effect usage, and compositional design patterns.
  • Out of scope: Next.js-specific routing/caching/runtime concerns (covered by the nextjs skill) and framework-agnostic browser styling conventions.

Invariants

  • Components and Hooks MUST be pure: no side effects during render.
  • Props and state are immutable snapshots; updates must create new values.
  • Effects are for synchronizing with external systems only, not for deriving render data.
  • State should be minimal and normalized; derive values in render when possible.
  • Keys in lists must be stable identifiers, never array index when order can change.

Validation Checklist

Failure Handling

  • If logic depends on mutating objects/arrays in place, stop and refactor to immutable updates before proceeding.
  • If an Effect exists only to compute derived UI data, replace it with render-time derivation or memoization.
  • If hook ordering is conditional, block the change and restore Rules of Hooks compliance.

High-Value React Practices

  • Move business rules into testable pure functions, keep components focused on rendering.
  • Keep hooks small and single-purpose; split hooks when responsibilities diverge.
  • Prefer controlled boundaries for async state (idle/loading/success/error unions).
  • Memoize only when profiling or clear render hotspots justify it.

04 同仓库更多 Skills