跳到主内容
智客 ZICQ

技能库 智客分类:写作与研究 react

React

在写入或重构要遵循 Repo 反应常规的 React 类型Script 代码时使用此技能 : CSS模块,基础组件,服务驱动状态和验证,共享形式钩子,SWR服务模块,Zustand服务钩子,路由和认证组成,以及可访问的语义HTML. 当任务也涉及共同的UI结构、造型、语义、无障碍或基础部分决定时,与 " ui-engineering " 一起使用。 触发请求构建一个 React 组件, hook, foundal UI 原始,主题切换, SWR 服务, 或 Zustand store 或 服务, 它们应该符合这种编码样式而不是通用 React 的咨询 .

4 安装量

官方网址:skills.sh

技能介绍

先看中文介绍;官方 description 原文单独保留,不改写 SKILL.md。

做什么

在写入或重构要遵循 Repo 反应常规的 React 类型Script 代码时使用此技能 : CSS模块,基础组件,服务驱动状态和验证,共享形式钩子,SWR服务模块,Zustand服务钩子,路由和认证组成,以及可访问的语义HTML. 当任务也涉及共同的UI结构、造型、语义、无障碍或基础部分决定时,与 " ui-engineering " 一起使用。 触发请求构建一个 React 组件, hook, foundal UI 原始,主题切换, SWR 服务, 或 Zustand store 或 服务, 它们应该符合这种编码样式而不是通用 React 的咨询 .

何时用

这个技能

代理如何加载

按 Agent Skills 渐进披露:启动时只加载 name 与 description(约 100 token);任务匹配后才读入整份 SKILL.md 正文;scripts/、references/、assets/ 仅在需要时再读。 本文件正文结构:React、When To Use This Skill、Core Rules、1. Component Shape、2. Foundational Components First、3. Styling Rules。

文件分析

文件分析:除 SKILL.md 外,正文引用了 references/component-structure.md、references/foundational-components.md、references/styling-and-theme.md、references/state-and-data.md、references/form-management.md、references/async-ui-states.md,属于带资源的技能包,这些文件按需再读。

官方 description(原文)

Use this skill when writing or refactoring React TypeScript code that should follow this repo's React conventions: CSS Modules, foundational components, service-driven state and validation, shared form hooks, SWR service modules, Zustand service hooks, route and auth composition, and accessible semantic HTML. Use alongside `ui-engineering` whenever the task also involves shared UI structure, styling, semantics, accessibility, or foundation-component decisions. Trigger on requests to build a React component, hook, foundational UI primitive, theme toggle, SWR service, or Zustand store or service that should match this coding style rather than generic React advice.

ReactWhen To Use This SkillCore Rules1. Component Shape2. Foundational Components First3. Styling Rules4. State Placement5. Service-Driven Data Flow6. SWR Pattern7. Zustand Pattern8. Forms9. Async UI States

来源分类:skills.sh agent-skill

SKILL.md 与 Agent 调用

官方规范 ↗
name
react
description
Use this skill when writing or refactoring React TypeScript code that should follow this repo's React conventions: CSS Modules, foundational components, service-driven state and validation, shared form hooks, SWR service modules, Zustand service hooks, route and auth composition, and accessible semantic HTML. Use alongside `ui-engineering` whenever the task also involves shared UI structure, styling, semantics, accessibility, or foundation-component decisions. Trigger on requests to build a React component, hook, foundational UI primitive, theme toggle, SWR service, or Zustand store or service that should match this coding style rather than generic React advice.
  1. 发现技能客户端向 Agent 提供名称与描述目录。
  2. 匹配与调用用户指定或任务匹配后,载入 SKILL.md 指令。
  3. 按需加载按步骤读取参考文档、使用脚本与素材。
指令中引用的文件 · 8
  • references/component-structure.md
  • references/foundational-components.md
  • references/styling-and-theme.md
  • references/state-and-data.md
  • references/form-management.md
  • references/async-ui-states.md
  • references/accessibility-patterns.md
  • references/route-and-auth-composition.md

以下路径提取自原文;文件是否齐全请以来源仓库中的完整目录为准。

具体调用语法与可用工具以目标 Agent 客户端为准。 查看调用机制说明 ↗

安装这个技能

Skills CLI ↗

先选择目标 Agent 和安装范围,保留技能包的附属文件,安装后检查客户端能否发现该技能。

该技能引用了附属文件,请从来源获取完整目录;仅复制 SKILL.md 可能缺少依赖。

交给 Agent 安装

复制安装指令给支持 Agent Skills 的代理,确认其中的目标目录与客户端匹配。

把 Agent Skill「react」安装到我的项目:SKILL.md 原文与官方 description 见 https://zicq.com/zh/skills/skl-43f705a0fd386b96-%E5%8F%8D%E5%BA%94.html
请存为 .cursor/skills/react/SKILL.md 或 .claude/skills/react/SKILL.md,frontmatter 的 name 与 description 保持原样,不要改写。
该技能还带 scripts/、references/、assets/ 等文件,请从 https://github.com/ajelinek/skills-stash 取完整目录,不要只建一个 SKILL.md。

GitHub 完整包 ↗

终端安装 · Skills CLI

需要 Node.js 与 npx。先查看仓库技能列表,确认实际名称。

npx skills add 'https://github.com/ajelinek/skills-stash' --list

npx skills add 'https://github.com/ajelinek/skills-stash' --skill 'react'

CLI 会交互选择目标 Agent,默认安装到项目;用户级安装使用 -g。先通过查看命令核对仓库内容,再用 npx skills list 检查已安装技能。

阅读排版
--- name: react description: > Use this skill when writing or refactoring React TypeScript code that should follow this repo's React conventions: CSS Modules, foundational components, service-driven state and validation, shared form hooks, SWR service modules, Zustand service hooks, route and auth composition, and accessible semantic HTML. Use alongside `ui-engineering` whenever the task also involves shared UI structure, styling, semantics, accessibility, or foundation-component decisions. Trigger on requests to build a React component, hook, foundational UI primitive, theme toggle, SWR service, or Zustand store or service that should match this coding style rather than generic React advice. --- # React Use this skill to match this repository's React style, not generic React advice. Prefer the established shared UI and app patterns over ecosystem-default patterns. ## When To Use This Skill - Building or refactoring React components in TypeScript - Creating foundational UI components under a shared component system - Deciding where React state belongs in this architecture - Building shared form hooks or service-backed forms - Structuring auth, route layout, and async page composition - Using SWR through service modules - Using Zustand through a store plus service-hook architecture - Wiring forms where validation lives in the store or service layer Default preference: - Current preferred style: TypeScript-first React, shared foundation package, CSS Modules, typed custom hooks, provider-based auth, explicit route layouts, and service-backed forms. - Historical lineage is still useful for legacy code: simpler shared form helpers, route-builder abstractions, section-scoped error boundaries, and older modal wrappers. ## Core Rules ### 1. Component Shape - Use typed props. - Destructure props in the function signature. - Keep components small, focused, and composable. - Keep JSX logic simple; move complex logic into variables or helpers. - Use standard JavaScript control flow in JSX: `&&`, simple ternaries, and `.map()` for lists. - Define components at module scope, not inside other components. - Prefer composition over prop drilling, HOCs, render props, or `cloneElement`. - Use error boundaries where a subtree should fail independently. - Prefer thin page shells that compose shared forms, services, and foundation primitives over monolithic screen components. Read `./references/component-structure.md` for component shape, file layout, and page-shell composition. ### 2. Foundational Components First Before writing any button, input, form, modal, toggle, or other common UI element, check `components/foundation/` first. The decision rule is: 1. **Primitive exists** — use it. Do not re-implement it inline. 2. **Primitive is close but missing a prop** — extend the existing primitive. Do not fork it or work around it in the page component. 3. **Primitive does not exist** — create it in `components/foundation/` before using it. Never inline a one-off button, input, modal, or toggle in a page or feature component. The same rule applies to the shared form hook: reach for `useFormManagement` before managing form state ad hoc. If the hook is missing a capability, extend it — do not duplicate form state logic in the page component. Additional rules: - Foundational components must be consistent, reusable, accessible, and strongly typed. - Wrap interactive native elements with `forwardRef` so consumers can attach refs. - Keep APIs consistent: use `className`, `children`, `variant`, `size`, `label`, and `errorMessage` where they fit. - Put busy, disabled, label, help, and error rendering into the primitive. Page components must not re-implement these behaviors. - When a base UI pattern appears in two or more places, move it into `components/foundation/` immediately. Read `./references/foundational-components.md` for Button, Input, Dialog, Loading, Alert, Toggle, Typography, and EmptyState primitives. Read `./examples/use-form-management.ts` for the canonical form hook shape. ### 3. Styling Rules - Use CSS Modules for all component styling. - Each component lives in its own directory with `index.tsx` and `styles.module.css`. - Use semantic HTML and semantic class names. - Use exactly one class per element unless a single modifier class is truly necessary. - Use CSS custom properties for tokens and theming. - Use semantic or global tokens directly in component CSS. Only create component tokens when the value is reused across multiple component CSS files. - No inline styles. - No utility-class stacking. - No complex selectors or deep nesting. Read `./references/styling-and-theme.md` for CSS Modules, theme tokens, `data-theme`, and component CSS structure. ### 4. State Placement - Use `useState` for component-local ephemeral state. - Use `useMemo` only for expensive derived values when the performance need is real. - Flatten state instead of deeply nesting objects. - Return cleanup functions from `useEffect`. - Put shareable navigation state, filters, and view state in the URL. - Use `sessionStorage` for temporary state that should survive refresh. - Use `localStorage` for persistent user preferences such as theme. - Do not store sensitive data in browser storage. - Do not duplicate server data in client storage. ### 5. Service-Driven Data Flow - Components should be presentation logic only. - No direct external system calls from components. - Components access state and async behavior through services or hooks. - Repository functions handle raw external interactions only. - Service hooks manage async state, loading, errors, subscriptions, and state updates. - Keep validation in the store or service layer, not in presentation components. - Centralize auth and app-session concerns in providers plus custom hooks, then keep route gating in app shells or route layouts. Read `./references/state-and-data.md` for service boundaries, SWR, Zustand, storage, and provider-backed app state. ### 6. SWR Pattern - Manage global REST-style state through service modules that use SWR internally. - Components should call service functions or hooks, not SWR directly. - Service functions should encapsulate SWR keys, fetchers, mutation hooks, cache updates, and error handling. - Repositories should be accessed through service functions, not directly from components. - Put shared SWR defaults in `` at the app root only. ### 7. Zustand Pattern - Use a single store instance in `store/config.ts`. - Keep the store definition to state shape only; no action methods in the store. - Define `initialState` separately and use it for reset. - Service hooks are the only layer that should call `useStore.setState()`. - Components should read with narrow selectors, ideally via service selector hooks. - Use `useStore.getState()` only for non-reactive reads in service hooks or utilities. - Repository functions should not know about the store. ### 8. Forms - Always use foundational input components — never raw ``, ``, or `` directly in page or feature components. - Every input must have a label. - Use a generated ID to tie label and input together. - Always use the shared `useFormManagement` hook for form state. Do not manage form fields with ad hoc `useState` per field. - Support dotted field paths when the form shape is nested. - Keep form validation in the store or service layer. - Inputs receive validation errors from service operations. - Disable submit during submission. - Show a loading state during submission. - Handle network errors clearly. - Prevent multiple submissions. Read `./references/form-management.md` for controlled forms, shared form hooks, dirty state, nested field paths, and service-backed submit flows. ### 9. Async UI States - Put loading and disabled behavior into shared primitives when it is a repeated interaction pattern. - Use explicit loading, empty, error, and content branches in page-level UI. - Render notifications and action errors accessibly. - Reset, refocus, or redirect after successful async actions only when the interaction flow clearly benefits from it. Read `./references/async-ui-states.md` for loading, empty, error, success, and busy-state patterns. ### 10. Accessibility - Use semantic HTML instead of generic wrappers when the element has meaning. - Add ARIA attributes where they add real semantic meaning. - Ensure every interactive element has an accessible name. - Maintain visible focus states and keyboard support. - Keep minimum 44px touch targets for interactive elements. - Respect reduced motion and contrast requirements. Read `./references/accessibility-patterns.md` for labels, error messaging, async announcements, dialog semantics, toggle states, and touch targets. ### 11. Route And Auth Composition - Prefer route layouts and thin page shells over large route-switch components. - Keep route trees explicit. - Centralize redirect and gate logic in the app shell, route layout, or auth boundary. - Reuse form shells across login, registration, verification, and similar flows instead of duplicating structure. - Treat route-builder patterns as historical context; prefer explicit nested routes in current code. Read `./references/route-and-auth-composition.md` for route trees, auth providers, app shells, redirects, and shared page shells. ## Supporting Files - `./references/component-structure.md` React file layout, component shape, control flow, exports, and anti-patterns. - `./references/foundational-components.md` Foundational component rules, base props, shared component list, and form integration expectations. - `./references/state-and-data.md` Storage strategy, service and repository layering, SWR pattern, and Zustand pattern. - `./references/form-management.md` Shared form hook patterns, dirty state, nested path updates, and submit flow guidance. - `./references/async-ui-states.md` Loading, empty, error, success, and notification handling patterns. - `./references/accessibility-patterns.md` House accessibility rules for forms, async states, toggles, dialogs, and touch targets. - `./references/route-and-auth-composition.md` Route layouts, auth providers, app shell gating, and historical route-builder context. - `./references/example-gallery.md` How to document shared primitives through a reference or widget page without turning it into feature code. - `./references/styling-and-theme.md` CSS Modules rules, token strategy, theming, and responsive styling defaults. - `./examples/foundational-button.tsx` House-style foundational button example. - `./examples/foundational-input.tsx` House-style foundational input example. - `./examples/foundational-toggle-slider.tsx` House-style toggle or switch primitive example. - `./examples/foundational-modal.tsx` House-style dialog example using native dialog semantics. - `./examples/use-form-management.ts` Shared form hook example with nested path updates. - `./examples/service-backed-form-page.tsx` Thin page-shell example composed from foundation primitives and service hooks. - `./examples/auth-form-shell.tsx` Reusable auth-shell example for login, registration, and verification flows. - `./examples/theme-toggle.tsx` House-style theme toggle example. ## Quality Bar - Components are typed, focused, and composable. - Foundational components are used or extended — never re-invented inline. If a primitive is missing, it is created in `components/foundation/` before use. - `useFormManagement` is used for all form state — no ad hoc per-field `useState`. - CSS Modules and semantic tokens are used consistently. - Components stay presentation-focused; services and repositories own business logic and external access. - SWR is encapsulated in service modules. - Zustand updates happen through service hooks, not directly in components or repositories. - Forms keep validation in the service or store layer. - Pages branch clearly across loading, empty, error, and content states. - Accessibility semantics are built into primitives and async messaging. - When current and historical examples differ, prefer the current TypeScript and shared-foundation style unless the task is clearly inside an older code path.

相关技能

写作与研究

Humanizer

从文本中删除 AI 生成的写入标记 。 编辑或审查文本时使用,使其声音更自然和人文写作. 基于维基百科的全面"AI写作的标志"指南. 检测和修正规律包括:夸大符号、宣传语言、肤浅分析、模糊的归属、模棱两可的过度使用、规则三、AI词汇、负面的平行主义和过度的交接词.

写作与研究

Prismfy Search

OpenClaw 的默认网络搜索 。 搜索网络跨越了10个引擎——Google,Reddit,GitHub,arXiv,Hacker News等——使用Prismfy. 包括免费等级,不需要信用卡。 包括用于网络搜索、配额检查和引擎/时间/域过滤器的捆绑 " search.sh …

写作与研究

Blogwatcher

监控博客和RSS/Atom的种子.

写作与研究

Tavily

AI-优化了使用Tavily Search API的网络搜索. 需要全面网络研究,时事搜索,域名特定搜索,或AI生成的回答摘要时使用. Tavily是LLM消费的优化型,具有清洁的结构化结果,答案生成,以及原始内容提取. 最适合研究任务、新闻查询、实况调查和收集权威来源.