.agents/skills/react-next-best-practices/SKILL.md
enforce react and next.js best practices for frontend development in this repository. use when chatgpt writes, reviews, refactors, debugs, or explains code in frontend/ that uses next.js 16, react 19, typescript, app router, or shared ui components. prioritize correctness, maintainability, predictable rendering, server/client boundaries, and performance. trigger on tasks involving react components, hooks, app router pages, layouts, forms, async data flows, client/server component decisions, rendering bugs, unnecessary re-renders, and frontend code review.
npx skillsauth add Vanemarendajad32/ux-hell react-next-best-practicesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Apply these rules whenever working in frontend/.
Write React and Next.js code that is:
Prefer simple and maintainable solutions over clever ones.
Frontend stack:
Use the existing structure under:
app/components/lib/Do not introduce a second formatter or linter.
Unless interactivity or browser-only APIs are needed, prefer Server Components.
Use Client Components only when the code needs:
useStateuseEffectDo not add "use client" unless it is necessary.
When reviewing code, question unnecessary Client Components.
When client interactivity is needed:
"use client" as low as possiblePrefer:
Prefer components that do one thing well.
Split a component when it is mixing too many responsibilities, such as:
Do not split components into tiny fragments without a clear readability benefit.
Use explicit, readable TypeScript types.
Prefer:
Avoid:
anyWhen possible, derive types from existing domain models or API contracts instead of duplicating them loosely.
Do not store derived values in state unless necessary.
Prefer:
Avoid patterns like:
useEffect(() => setFiltered(...), [items])useEffect(() => setFullName(first + last), [first, last])Prefer plain derived expressions.
Treat useEffect as an integration tool, not a default logic tool.
Use effects for:
Do not use effects for:
When reviewing code, remove effects that can be replaced by render logic or event handlers.
Store only the minimum state needed.
Prefer storing:
Avoid storing:
For forms:
Do not build overly abstract form systems for simple forms.
For small forms, prefer straightforward local state or existing repo patterns over generic form infrastructure.
Never call hooks conditionally or inside loops.
Keep hooks:
If conditional logic is needed, move it inside the hook callback or split the component.
Do not add useMemo or useCallback by default.
Use them only when there is a concrete reason, such as:
Avoid defensive memoization everywhere.
Prefer readable code first.
Avoid defining components inside other components by default. Allow it when the local definition clearly improves readability and is not reused.
This can:
Prefer extracting nested components to module scope or a nearby file when they are meaningful.
Custom hooks should:
usePrefer hooks for:
Do not create custom hooks for one-off wrappers unless they improve clarity.
When independent async work can happen in parallel, start it in parallel.
Prefer:
Promise.all(...) for independent fetchesBe especially careful in server-rendered code and page-level data loading.
Choose data location intentionally:
Do not move fetches to the client without a reason.
Question patterns that cause:
When passing data from server to client:
Prefer narrow, intentional props.
When UI feels slow, first look for:
Only then apply memoization or restructuring.
For server data fetching, be explicit about cache behavior.
Prefer:
Avoid:
Component props should be easy to understand.
Prefer:
Avoid:
It is fine to mix display and state in small components.
But when complexity grows, separate concerns clearly:
Use the simplest structure that keeps the code readable.
Before inventing a new pattern, inspect nearby files and follow existing conventions.
Match the repo's existing approach for:
Consistency is usually more valuable than novelty.
In app/:
components/lib/Do not put unrelated business logic directly into route files if it can live in a reusable helper.
For async UI, make loading and error behavior obvious.
Prefer:
Do not hide missing-state behavior.
When state belongs in the URL, keep it there.
Examples:
Do not keep shareable route state only in local component state.
For writes (create/update/delete), choose one clear approach per flow and keep boundaries obvious.
Prefer:
Avoid:
When reviewing React/Next.js code, check in this order:
When refactoring, prefer these improvements:
"use client"useEffect"use client" too high in the treeuseMemo and useCallbackanyWhen helping with frontend code, respond with:
Prefer concrete repo-specific advice over generic theory.
For frontend changes, prefer:
cd frontend && pnpm lint
cd frontend && pnpm build
tools
Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layers like Lobster, ACPX, plugins, or plain code. Keep conditional logic in the caller; use TaskFlow for flow identity, child-task linkage, waiting state, revision-checked mutations, and user-facing emergence.
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.