Token导航 LogoToken导航

Agent Skill · 研究检索

react-single-responsibility(React single responsibility 搜索)

用于辅助前端页面、组件、样式和交互逻辑的开发与维护。它适合让 Agent 生成或审查 React、Next.js、Vue、Tailwind、CSS 等相关代码,整理组件结构,或定位布局和性能问题。使用时需要结合项目现有设计系统、路由和构建方式,避免只生成孤立片段;涉及页面改动时,应配合本地预览和构建检查确认视觉效果。

react-single-responsibility 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 48,806。

总安装 675周安装 29GitHub Stars 公开资料未说明下载 237核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:react-single-responsibility(React single responsibility 搜索)
来源仓库:https://github.com/lichens-innovation/skills
仓库路径:skills/react-single-responsibility
安装命令:
npx skills add https://github.com/lichens-innovation/skills --skill react-single-responsibility
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/lichens-innovation/skills --skill react-single-responsibility

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

辅助 React 组件单一职责原则相关研究与开发。适用于生成或审查高内聚、低耦合的组件代码。可整理组件拆分策略,定位职责混杂的性能与可维护性问题。需结合项目架构风格与团队规范使用,避免过度拆分。建议在复杂组件重构时配合人工评审使用。

react-single-responsibility 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/react-single-responsibility

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/lichens-innovation/skills --skill react-single…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

react-single-responsibility 怎么安装?

在终端执行 npx skills add https://github.com/lichens-innovation/skills --skill react-single-responsib…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

react-single-responsibility 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

react-single-responsibility 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

react-single-responsibility 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

react-single-responsibility 用的人多吗?

公开数据是累计安装 675 次,近一周安装 29 次,下载 237 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

react-single-responsibility 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
react-single-responsibility

React single responsibility 搜索 · 本页

675—需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Single Responsibility — Simplify Components & Methods

Apply these strategies to keep components, hooks, and methods focused, testable, and readable. Rules are split into component, hook, and method simplification.


Principles

PrincipleRule
KISSSimplest solution that works. Avoid over-engineering.
Single responsibilityOne clear responsibility per component or function; extract utilities, hooks, sub-components.
DRYExtract common logic; create reusable functions or components.
YAGNIDon't build features before they're needed.
CompositionPrefer composing small components and utilities over large, multi-purpose blocks.

Which rules apply

Use the file where the function lives: ***.tsx → components ("Simplifying a component"); use*.ts → hooks ("Simplifying a hook"); *.ts** → plain functions ("Simplifying a method"). Plain TypeScript functions are always in *.ts, never in *.tsx.


Simplifying a component (filename pattern *.tsx)

Rules that apply when reducing complexity of a React component.

Decomposition (avoid God Component)

Apply in this order:

  1. Extract pure utilities first — Logic with no React dependency → pure functions. More than one argument → object destructuring within the method signature. Reusable → src/utils/xyz.utils.ts; feature-specific → component-name.utils.ts next to the component.
  2. Form state (multiple useState) — When multiple useState calls are used to manage the full state of an input form: refactor the code to use the react-hook-form library, which simplifies the form, its validation, its state, and its submission.
  3. Extract logic into hooks — State, effects, derived logic → hooks (use-xyz.ts). Reusable → src/hooks/; feature-specific → feature's hooks/ subdirectory. Prefer a plain arrow function over a custom hook when you don't need React primitives.
  4. Split the visual layer into sub-components — If render/TSX exceeds roughly 100 lines, extract sub-components with clear props and a single responsibility. Avoid internal renderXyz() methods: turn each into a regular component (own file, own props). Each sub-component must live in its own file; use parent file name as prefix: parent-name-<sub-component-name>.tsx (e.g. market-list-item.tsx, market-list-filters.tsx for parent market-list.tsx). Large component (>150 lines) → split into list container, list item, filters, pure functions and hook(s) as necessary for data logic.

Structure and readability

  • Order inside the component: types → state → computed const → effects → handlers → render.
  • Handlers: If a handler depends only on pure TypeScript it can be moved to component-name.utils.ts next to the component; otherwise, if the handler is very simple (e.g. one line) keep it inline in the onClick or other event props; finally, if the handler is more complex or involves state, use one arrow function per handler (e.g. const handleClick = () => {...}). Always avoid factories that return handlers (double arrow functions).
  • Early returns in render — Keep the main path flat: if (isLoading) return <Spinner />; if (error) return <ErrorMessage />;... One condition per line; avoid nested ternary operators (“ternary hell”).
  • Boolean in JSX — Use explicit computed boolean (e.g. const hasItems = items.length > 0; {hasItems && <List />}) so 0 is not rendered.
  • Static data — Constants and pure functions that don't depend on props or state → outside the component (relocate into component-name.utils.ts) to avoid new references every render.

React-specific

  • Selected items — Store selection by ID in state; derive the full item from the list (e.g. selectedItem = items.find(i => i.id === selectedId)). Avoids stale references when the list updates.
  • useMemo / useCallback — only when absolutely necessary — Default: do not use. Re-renders are often an acceptable tradeoff to promote readability. These hooks add complexity and recent React compilers already optimize renders. Avoid for trivial cases (e.g. useMemo(() => count * 2, [count]), useCallback(() => setOpen(true), [])). Use only when: profiling shows a real performance problem.
  • Data fetching — Prefer TanStack Query (useQuery / useMutation) instead of manual useState + useEffect — reduces boilerplate and keeps the component simpler.
  • Form state — When multiple useState calls are used to manage a form, consider using react-hook-form to simplify the form and its state (validation, submission, and field registration in one place).

Simplifying a hook (filename pattern use*.ts)

Rules that apply when reducing complexity of a custom React hook. Apply single responsibility by extracting pure logic into utilities and splitting broad hooks into smaller, focused ones.

Decomposition order

  1. Extract pure JS utilities first — Any logic that has no dependency on React (no useState, useEffect, context, etc.) → move to pure exported arrow functions. For more than one argument, use object destructuring in the function signature and define the parameter interface just above the function. Put extracted arrow function(s) in <component-name>.utils.ts next to the component or <hook-name>.utils.ts next to the hook, or in src/utils/ if reusable. Examples: formatting, validation, computing derived values from plain data, building query params or request bodies. Pure functions are easier to test and reuse outside the hook.
  2. Consider enriching an existing state manager — Before creating new specialized hooks, check if the project already uses a state manager (e.g. Zustand, MobX, Redux). If so, consider adding the business logic there: actions, derived state, and domain rules can live in the store and slim down the hooks. Hooks then become thin selectors or one-off bindings (e.g. useStore(selector)), and the store encapsulates the domain. Prefer extending the existing store over multiplying hooks that each hold their own state.
  3. Split into specialized hooks — If no store fits or the logic is purely local/UI, and the hook still handles several concerns (e.g. fetching + filtering + pagination) or states, extract one hook per concern: e.g. useFetchItems, useItemsFilter, usePagination. Compose them in the component or in a thin “orchestrator” hook that only wires the others. Each hook should have one clear responsibility and a name that reflects it.

Hook design

  • Narrow return shape — Prefer returning a small, stable object (e.g. {data, isLoading, error} or {value, onChange}). Avoid returning large bags of unrelated state and setters; split into separate hooks instead.
  • Plain function vs hook — If the logic doesn’t need React primitives (state, effects, context), use a plain function in a .utils.ts file instead of a custom hook. Only introduce a hook when you need React’s lifecycle or state.
  • Dependencies — Keep hook inputs explicit (parameters); avoid reading from context or globals inside the hook unless that’s the hook’s sole purpose. Easier to test and reason about.

File and naming

  • One hook per file when the hook is non-trivial; file name: use-<name>.ts (e.g. use-market-filters.ts, use-pagination.ts). Reusable hooks → src/hooks/; feature-specific → feature’s hooks/ subdirectory.
  • Co-locate utilities — <hook-name>.utils.ts next to the hook for helpers used only by that hook; <main-component-name>.utils.ts next to the main component for helpers used by main component and its sub-components; shared logic → src/utils/ or domain-specific utils module.

Quick checklist (hooks)

  • Does the hook contain logic with no React dependency? → extract to pure arrow functions in .utils.ts using destructuring within the signature.
  • Does the hook do more than one thing? → consider enriching the project’s state manager (Zustand, MobX, etc.) first; otherwise split into smaller pure JS utilities, or specialized hooks (e.g. fetch vs filter vs pagination) and compose.
  • Could this be a plain function? → if it doesn’t need state/effects/context, use a utility instead of a hook.
  • Is the return type a large, mixed bag? → consider splitting the hook or returning a smaller, focused API.

Simplifying a method (filename pattern *.ts)

Rules that apply when reducing complexity of a function or method (non-component).

Long function (>40 in *.ts)

Only apply in ***.ts (plain functions) → threshold 40 lines**.

  • Signal: Scrolling to understand a single function.
  • Fix: Extract into smaller, named arrow functions. Apply single responsibility: each new method must stay simple and focused on one task only (e.g. validate → fetch → persist → notify). Each step should be testable in isolation.

Control flow

  • Early returns — Prefer early returns over nested if/else (max ~2 levels of nesting).
  • const over let — Prefer const; use reduce or pure helpers (e.g. const isXyz({arg1, arg2}: MyArgs): boolean) with early returns instead of mutable loop accumulators.
  • Clear conditionals — Use Array.includes(value) for multiple value checks; Array.some(predicate) for existence checks. Extract complex expressions into named variables (destructuring, intermediate vars) for readability.

Parameters

  • Long parameter list (>1 param) — As soon as a function or method has more than one parameter (2+ arguments), use a single params object with destructuring and extract the parameter interface immediately above the function signature (e.g. interface CreateUserArgs). Avoids wrong order and unclear meaning at the call site. The interface name matches the method name but starts with a capital letter and ends with Args (e.g. for getThisMethod, use interface GetThisMethodArgs). This rule is also enforced as a coding standard (see react-coding-standards, common-coding-patterns); during normalization, apply it to every such function.
  • Interface used only for one method — When an interface exists solely to type a single method’s signature, place it immediately above that method (colocation). This self-documents the signature that follows and keeps the type next to its only consumer.
  • Boolean flag parameter — Avoid fn(data, true). Use an options object with a named flag (e.g. {userId, includeArchived}: CreateUserArgs) or separate functions when behavior diverges.
  • Conventions — Destructuring for multiple params; extract parameters into named interfaces; optional as param?: Type; defaults in destructuring (e.g. {page = 1, size = 10}).

Duplication (DRY)

  • Signal: Copy-paste with minor variations.
  • Fix: Extract a parameterized arrow function (e.g. single getMarketsForUser({userId, status}: GetMarketsForUserArgs) instead of getActiveMarketsForUser and getClosedMarketsForUser).

Shared (components and methods)

Object destructuring

  • Use object destructuring when reading or passing object attributes so that attribute names are explicit and the code stays readable. Applies to: component props (e.g. const {isLoading, error, data} = props or in the signature), function parameters (e.g. const fn = ({a, b}: FnArgs) =>...), and local objects when you use several properties (e.g. const {name, status} = item). Prefer destructuring when it clarifies usage and improves readability; avoid when a single property is used once.

Coupling (shotgun surgery)

  • Signal: One feature change requires edits in many files.
  • Fix: Co-locate related logic (e.g. feature folder with its own components, hooks, utils, types); reduce coupling and centralize domain logic where it belongs.

File and size guidelines

  • ***.tsx (components) — Must not exceed 150 lines**. Plain functions live in *.ts, not in *.tsx.
  • ***.ts (pure TypeScript) — 200–400 lines typical per file; 2000 lines absolute maximum. Plain functions (methods) use the 40-line** per-function threshold above.
  • File names: kebab-case. Examples: market-list-item.tsx, use-market-filters.ts, <name>.utils.ts, (e.g. market-list.utils.ts).

Quick checklist

  • Does it do more than one thing? → if yes: extract pure utilities, hooks, or sub-components (component) or smaller named functions (method).
  • More than 1 parameter? → always use a single options object, an extracted parameter interface immediately above the signature, and destructuring (applies to every function with 2+ args; see also react-coding-standards).
  • Copy-pasted code? → extract and parameterize.
  • Control flow deeply nested? → use early returns and intermediate variables.
  • Comments explaining *what*? → rename for self-documenting code; keep comments for *why* only.

平台分布

Codex

37.1%
按下载量换算88

Claude

27.82%
按下载量换算66

Cursor

18.18%
按下载量换算43

Gemini CLI

9.8%
按下载量换算23

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills