agentleFS
amirrezaalastiamirrezaalasti/codescribe/skills/coding/react-best-practices/SKILL.md

react-best-practices

Skill2 starsChanged 4 months agoMITView on GitHub

Build React UIs with clear composition, correct state placement, disciplined effects, and basic accessibility. Use when writing React components, hooks, fixing re-renders or effect bugs, or when the user mentions React, JSX, or client UI state.

38 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use parallel-agents, web-design-guidelines and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • parcadeiSkill

    parallel-agents

    Parallel Agent Orchestration

    Also in 3 projects that use this

  • VercelSkill

    web-design-guidelines

    Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".

    Also in 7 projects that use this

  • JetBrainsSkill

    webapp-testing

    Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

    Also in 7 projects that use this

  • xfstudioSkill

    clean-code

    Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments

    Also in 3 projects that use this

  • ttmouseSkill

    notebooklm

    Automate Google NotebookLM - create notebooks, add sources, generate podcasts/videos/quizzes, download artifacts. Supports browser-based content extraction for anti-crawler platforms (Twitter/X, LinkedIn, etc.). Activates on explicit /notebooklm or intent like "create a podcast about X

    Also in 3 projects that use this

  • MicrosoftSkill

    mcp-builder

    Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

    Also in 6 projects that use this

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 33 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Prefer deriving state over syncing with effects

    line 21
  2. Distinctive:

    State placement: Keep state as local as possible.

    line 27
  3. Very specific:

    Effects are escape hatches: Use useEffect for synchronizing with external systems (DOM, network subscriptions), not for computing …

    line 28
  4. Distinctive:

    Lists need stable keys: Use stable IDs, not array indexes, when order can change.

    line 29
  5. Very specific:

    Performance: Do not add useMemo/useCallback by default.

    line 31
  6. Very specific:

    Accessibility baseline: Use button/link correctly.

    line 32
  7. Very specific:

    Tag unfinished or risky work: Use the global tagged-code-comments convention (🔴 FIXME(P0):, 🟠 TODO(P1):, {/* 🟡 UX(P2): … */}).

    line 33

“Common” is measured: kept by at least 6 in 10 of the 33 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

React Best Practices

Defaults

  • Function components + hooks
  • Colocate state with the nearest common consumer
  • Prefer deriving state over syncing with effects
  • Accessibility: semantic HTML first; labels for inputs; keyboard reachability

Instructions

  1. Composition over configuration. Split UI into small components with clear props. Prefer children/slots over boolean prop sprawl (isHeader && …).
  2. State placement. Keep state as local as possible. Lift only when siblings must share. Prefer URL/search params for shareable UI state when the app already does.
  3. Effects are escape hatches. Use useEffect for synchronizing with external systems (DOM, network subscriptions), not for computing renderable values. Prefer event handlers for user-driven updates.
  4. Lists need stable keys. Use stable IDs, not array indexes, when order can change.
  5. Controlled vs uncontrolled. Pick one per input; do not flip-flop. For forms, follow the project's form library if present.
  6. Performance. Do not add useMemo/useCallback by default. Add them when profiling or when referential stability is required by a child/effect dep. Follow React Compiler guidance if the project uses it.
  7. Accessibility baseline. Use button/link correctly; associate <label htmlFor>; manage focus for dialogs; do not rely on color alone.
  8. Tag unfinished or risky work. Use the global tagged-code-comments convention (🔴 FIXME(P0):, 🟠 TODO(P1):, {/* 🟡 UX(P2): … */}). Never leave silent stubs. End with an Open follow-ups table so the developer must check P0/P1 before ship.

Effect anti-pattern

// Bad: syncing derived state
const [fullName, setFullName] = useState("");
useEffect(() => {
  setFullName(first + " " + last);
}, [first, last]);

// Good: derive during render
const fullName = `${first} ${last}`;

Component sketch

type UserCardProps = {
  name: string;
  onSelect: (id: string) => void;
  id: string;
};

export function UserCard({ id, name, onSelect }: UserCardProps) {
  return (
    <button type="button" onClick={() => onSelect(id)}>
      {name}
    </button>
  );
}

Anti-patterns

  • Prop drilling deep trees when context or composition would clarify
  • Effects that set state solely to mirror props
  • key={index} on reorderable lists
  • Div soup for interactive elements (div onClick instead of button)

Additional resources

  • references/checklist.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.