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.

71 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use react-native-skills, composition-patterns and 9 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.
  • eeaSkill

    react-native-skills

    React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

    Also in 4 projects that use this

  • eeaSkill

    composition-patterns

    React composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.

    Also in 4 projects that use this

  • mcollinaSkill

    fastify-best-practices

    Guides development of Fastify Node.js backend servers and REST APIs using TypeScript or JavaScript. Use when building, configuring, or debugging a Fastify application — including defining routes, implementing plugins, setting up JSON Schema validation, handling errors, optimising performance, managing authentication, configuring CORS and security headers, integrating databases, working with WebSockets, and deploying to production. Covers the full Fastify request lifecycle (hooks, serialization, logging with Pino) and TypeScript integration via strip types. Trigger terms: Fastify, Node.js server, REST API, API routes, backend framework, fastify.config, server.ts, app.ts.

    Also in 3 projects that use this

  • KadajettSkill

    nestjs-best-practices

    NestJS best practices and architecture patterns for building production-ready applications. This skill should be used when writing, reviewing, or refactoring NestJS code to ensure proper patterns for modules, dependency injection, security, and performance.

    Also in 3 projects that use this

  • MicrosoftSkill

    planning-with-files

    **USE THIS FOR COMPLEX TASKS.** Implements Manus-style file-based planning for multi-step tasks. Creates task_plan.md, findings.md, and progress.md in .agent_cache/<task-name>/. Use when: implementing multiple APIs, refactoring modules, research tasks, or ANY task requiring >5 tool calls.

    Also in 5 projects that use this

  • VercelSkill

    vercel-deploy

    Deploy applications and websites to Vercel with a claimable preview. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment". No authentication required - returns preview URL and claimable deployment link.

    Also in 3 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 59 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 59 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.