agentleFS
iliaaliliaal/ai-skills/skills/react-frontend/SKILL.md

react-frontend

Skill43 starsChanged 58 days agoMITView on GitHub

React architecture patterns, TypeScript, Next.js, hooks, and testing. Use when working with React component structure, state management, Next.js routing, Vitest, React Testing Library, reviewing React code, or synchronizing JSON locales and reviewing translations in a React or frontend interface. For visual design and aesthetic direction, use frontend-design instead.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 7 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep derived state in render and user actions in event handlers.

    line 19
  2. Distinctive:

    Never suppress the linter.

    line 39
  3. Very specific:

    Use updater functions (setItems(prev => [...prev, item])) to remove state dependencies

    line 40
  4. Distinctive:

    Always return cleanup for subscriptions, connections, listeners

    line 43
  5. Distinctive:

    Only touch what's necessary.

    line 50
  6. Distinctive:

    No hacky workarounds: if a fix feels wrong, step back and implement the clean solution

    line 51
  7. Distinctive:

    Before adding a new abstraction, verify it appears in 3+ places

    line 52
  8. Very specific:

    No suppressed lint rules (eslint-disable, @ts-ignore) in new code

    line 64
  9. Distinctive:

    Read the relevant reference before implementing or reviewing the matching behavior:

    line 70

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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 Frontend

Verify before implementing: For App Router patterns, React 19 APIs, or version-specific behavior, look up current docs (Context7 query-docs if available, else the framework's official docs via web search) before writing code. Training data may lag current releases.

Working rules

  • Keep derived state in render and user actions in event handlers; use effects for external synchronization.
  • Give async work a lifecycle and cancellation policy; represent failure separately from pending and empty data.
  • Preserve focus when hiding interactive regions and exercise keyboard navigation in a real browser.
  • Validate and authorize every public server action; send only needed fields across server/client boundaries.
  • Measure performance changes and test user-visible behavior, not type-checking alone.

Effects Decision Tree

Effects are escape hatches; most logic should NOT use effects.

NeedSolution
Derived value from props/stateCalculate during render (useMemo if expensive)
Reset state on prop changekey prop on component
Respond to user eventEvent handler
Notify parent of state changeCall onChange in event handler, or fully controlled component
Chain of state updatesCalculate all next state in one event handler
Sync with external systemEffect with cleanup

Effect rules:

  • Never suppress the linter; fix the code instead
  • Use updater functions (setItems(prev => [...prev, item])) to remove state dependencies
  • Move objects/functions inside effects to stabilize dependencies
  • useEffectEvent for non-reactive values (e.g., theme in a connection effect)
  • Always return cleanup for subscriptions, connections, listeners
  • Data fetching cancellation (pick by situation): AbortController for fetch; ignore flag for non-cancellable promises. With React Query, pass the query function's signal to the transport, such as queryFn: ({ signal }) => fetch(url, { signal }). Without consuming that signal, an unused query can finish and populate the cache; do not describe that behavior as transport cancellation.

Discipline

  • Simplicity first: every change as simple as possible, impact minimal code
  • Only touch what's necessary; avoid introducing unrelated changes
  • No hacky workarounds: if a fix feels wrong, step back and implement the clean solution
  • Before adding a new abstraction, verify it appears in 3+ places

References

  • testing.md: Component, hook, and mocking test examples
  • e2e-testing.md: Playwright E2E patterns

Verify

  • TypeScript compiles with zero errors
  • No suppressed lint rules (eslint-disable, @ts-ignore) in new code
  • useEffect dependency arrays not manually overridden
  • No forwardRef usage in React 19+ projects (use ref prop directly)

Task-specific references

Read the relevant reference before implementing or reviewing the matching behavior:

  • For component types, state ownership, async races, focus, or cached query behavior: components-and-state.md.
  • For performance, React APIs, Next.js boundaries, or caching: rendering-and-frameworks.md.
  • For Tailwind CSS: utilities, @theme tokens, CVA/tailwind-variants, dark mode, v3-to-v4 migration, or overflow and hidden pitfalls: tailwind.md.
  • For component, hook, browser, or integration test changes: test-selection.md.
  • For synchronizing JSON locale files or reviewing translations: locale-synchronization.md.

Existing specialized references, when the corresponding topic applies:

  • Tailwind details behind tailwind.md: tailwind-configuration.md, tailwind-v3-to-v4.md, tailwind-class-composition.md, tailwind-component-patterns.md, tailwind-layout-patterns.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.