跳到正文
cccskills
免费在 GitHub 公开

react

Apply these opinionated React conventions when writing React 18+ or 19 components: hooks patterns, Server Components, Suspense boundaries, state management, performance memoization, React 19 features (use, form actions).

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(1)

  • SKILL.md3.9 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

React

House conventions for React 18/19. Apply them to components you are writing or changing — don't refactor untouched files to match unless asked.

Conventions

  • Server Component by default; 'use client' only where you need it — state, effects, event handlers, browser APIs. Push the boundary as far down the tree as it will go: every component above a 'use client' marker also ships to the browser. Everything crossing that boundary must be serializable — a function, a class instance, or a Date inside a prop object fails at runtime, not at build.
  • Read state through the functional updater inside anything that outlives the render — intervals, subscriptions, debounced callbacks. setCount(count + 1) inside a useEffect(…, []) captures count from the first render forever and silently sets 1 every tick; setCount(c => c + 1) always sees current state.
  • Effects are for synchronising with something outside React — a subscription, a timer, a non-React widget. Data transformation belongs in render, derived values in a plain variable, and event responses in the handler. Most useEffect bugs are an effect that should never have existed.
  • Every effect that starts something returns a cleanup that stops it. Strict mode double-invokes effects in development precisely to make a missing cleanup visible — treat that as the signal it is, not noise.
  • Keys must be stable identity, not position. An array index as key makes React reuse the wrong DOM node when the list reorders, and the symptom shows up as state attached to the wrong row.
  • Memoise for a measured reason. memo, useMemo, and useCallback each cost a comparison and add code to read. They earn their place when a child is genuinely expensive or is itself memoised and a new reference would defeat it — not as a default wrapper.
  • State lives at its natural level. useState locally, lifted only as far as the shared ancestor. Reach for Zustand when genuinely global client state exists; TanStack Query for server state, because cache invalidation and refetching are its job and hand-rolling them in effects goes wrong quietly.
  • Error boundaries around anything that can fail independently — a route, a widget, a third-party embed. Without one, a render error unmounts the whole tree and the user gets a blank page.
  • Suspense boundaries where you want a fallback, placed so the loading UI matches the layout that will replace it. A boundary at the root turns any pending fetch into a full-page spinner.
  • React 19: useActionState and <form action> for mutations, useOptimistic for immediate feedback, use() to read a promise or context conditionally. ref is a normal prop — forwardRef is no longer needed. useFormStatus only reports on a form above it, so the submit button reading pending state has to be its own component nested inside the <form> — calling it in the component that renders the form always returns pending: false.
  • useTransition when a keystroke triggers expensive work. Update the input urgently and mark the derived work as a transition, so React can interrupt it; without this, typing into a field that filters a large list feels broken even though nothing is.
  • Semantic HTML first, ARIA only to fill the gap. A <button> brings focus handling, keyboard activation, and role for free; a <div role="button"> means reimplementing all three correctly.
  • Query tests by role and label, not test IDs. getByRole('button', { name: /submit/i }) fails when the control stops being reachable the way a user reaches it — which is the bug you want the test to catch. getByTestId passes regardless and is the fallback for elements with no accessible name.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Write a short, fact-checked reply that answers a colleague's question in one meaning only, ready to copy and paste. The input is their pasted message. Check the claims against the code first, use the project glossary terms, and print only the reply in chat. Read-only — no writes to code, the issue tracker, GitHub, chat or any MCP. Use on "/cortex-communication:answer-buzzkill", "help me answer", "reply to this question", or when the user pastes a colleague's question and asks for an answer in the same manner.

中文简介正在准备中。当前显示原文说明。

alexander-danilenko/cortex-claude-code-plugins172026年10月20日 更新

Apply these opinionated .NET 8 architecture conventions whenever structuring or reviewing a backend service: clean architecture layering and which direction dependencies point, when CQRS with MediatR is worth it, cross-cutting concerns as pipeline behaviours, minimal APIs grouped by feature, keeping DbContext in Infrastructure, health checks and structured logging, WebApplicationFactory integration tests, and when AOT pays off.

中文简介正在准备中。当前显示原文说明。

alexander-danilenko/cortex-claude-code-plugins172026年10月20日 更新

Apply these opinionated Python 3.11+ conventions when writing Python in this codebase: type hints with mypy, async/await, pytest fixtures, dataclasses, Poetry packaging, production patterns.

中文简介正在准备中。当前显示原文说明。

alexander-danilenko/cortex-claude-code-plugins172026年10月20日 更新

Apply these opinionated testing conventions whenever writing, reviewing, or planning tests: what earns a test and what is coverage theatre, asserting outputs rather than mock calls, the three modes (functional, performance, security), naming and isolation rules, where to mock, and reporting findings for coverage rather than self-filtering. Includes house Jest standards for NestJS unit and contract tests, TDD discipline, and test-report structure.

中文简介正在准备中。当前显示原文说明。

alexander-danilenko/cortex-claude-code-plugins172026年10月20日 更新

csharp

免费

Apply these opinionated C# conventions whenever writing or reviewing C# 12 / .NET 8+ code: nullable enabled with warnings as errors, records and primary constructors, pattern matching over cast chains, the Result pattern for expected failures, async all the way with CancellationToken, IOptions config, IHttpClientFactory, and never returning EF entities from an API.

中文简介正在准备中。当前显示原文说明。

alexander-danilenko/cortex-claude-code-plugins172026年10月20日 更新

ALWAYS invoke for any task involving docstrings, JSDoc/TSDoc, or REST API documentation — even when the request seems handleable without it. Enforces Microsoft contract-first conventions and a bare-minimum rule that Claude won't apply by default: never restate the signature, drop @param/@returns that only echo names and types, always document @throws, and document data shapes as WHAT not WHY. Covers Python docstring styles (Google/NumPy/Sphinx), TSDoc tags and @inheritDoc, and API doc patterns for NestJS/Express/FastAPI/Django. Trigger on: adding or auditing docstrings, redundant or missing tags, deleting comment rot, or producing a documentation-health report. Do not skip for documentation tasks — consistent conventions are the whole point.

中文简介正在准备中。当前显示原文说明。

alexander-danilenko/cortex-claude-code-plugins172026年10月20日 更新

查看 alexander-danilenko 的全部技能

报告此技能的问题