skills/react-single-responsibility/SKILL.md
Strategies to simplify components, hooks, and methods: decomposition order (utilities, hooks, sub-components), early returns, control flow, parameter design, and code smell fixes. Use when the user says: ungodify this method/function/component, simplify this method/function/component, make this method/function/component less complex; or when refactoring a large component, hook, or function, reducing complexity, applying single responsibility, or asking how to simplify a component, hook, or method.
npx skillsauth add lichens-innovation/ai-dev-tools react-single-responsibilityInstall 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 strategies to keep components, hooks, and methods focused, testable, and readable. Rules are split into component, hook, and method simplification.
| Principle | Rule | | ------------------------- | --------------------------------------------------------------------------------------------- | | KISS | Simplest solution that works. Avoid over-engineering. | | Single responsibility | One clear responsibility per component or function; extract utilities, hooks, sub-components. | | DRY | Extract common logic; create reusable functions or components. | | YAGNI | Don't build features before they're needed. | | Composition | Prefer composing small components and utilities over large, multi-purpose blocks. |
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.
Rules that apply when reducing complexity of a React component.
Apply in this order:
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.
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.
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.
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.
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).if (isLoading) return <Spinner />; if (error) return <ErrorMessage />; ... One condition per line; avoid nested ternary operators (“ternary hell”).const hasItems = items.length > 0; { hasItems && <List /> }) so 0 is not rendered.component-name.utils.ts) to avoid new references every render.selectedItem = items.find(i => i.id === selectedId)). Avoids stale references when the list updates.useMemo(() => count * 2, [count]), useCallback(() => setOpen(true), [])). Use only when: profiling shows a real performance problem.useQuery / useMutation) instead of manual useState + useEffect — reduces boilerplate and keeps the component simpler.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).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.
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.
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.
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.
{ data, isLoading, error } or { value, onChange }). Avoid returning large bags of unrelated state and setters; split into separate hooks instead..utils.ts file instead of a custom hook. Only introduce a hook when you need React’s lifecycle or state.use-<name>.ts (e.g. use-market-filters.ts, use-pagination.ts). Reusable hooks → src/hooks/; feature-specific → feature’s hooks/ subdirectory.<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..utils.ts using destructuring within the signature.Rules that apply when reducing complexity of a function or method (non-component).
Only apply in *.ts (plain functions) → threshold 40 lines.
const isXyz({ arg1, arg2 }: MyArgs): boolean) with early returns instead of mutable loop accumulators.Array.includes(value) for multiple value checks; Array.some(predicate) for existence checks. Extract complex expressions into named variables (destructuring, intermediate vars) for readability.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.fn(data, true). Use an options object with a named flag (e.g. { userId, includeArchived }: CreateUserArgs) or separate functions when behavior diverges.param?: Type; defaults in destructuring (e.g. { page = 1, size = 10 }).getMarketsForUser({ userId, status }: GetMarketsForUserArgs) instead of getActiveMarketsForUser and getClosedMarketsForUser).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.*.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.market-list-item.tsx, use-market-filters.ts, <name>.utils.ts, (e.g. market-list.utils.ts).tools
Reference for managing Claude Code plugins and marketplaces: install, update, remove plugins; add, update, remove marketplaces. Use when the user asks how to install a plugin, remove a marketplace, update plugins, or manage their Claude Code plugin setup.
tools
Scaffolds a new subagent in the ai-dev-tools marketplace repository: creates the agent directory, AGENTS.md file, and symlinks it into the chosen plugin. Use when the user asks to add a subagent, create an agent, or scaffold a subagent in the marketplace.
tools
Scaffolds a new skill in the ai-dev-tools marketplace repository: creates the skill directory and SKILL.md boilerplate directly inside the chosen plugin. Use when the user asks to add a new skill, create a skill, or scaffold a skill in the marketplace.
tools
Scaffolds a new plugin in the ai-dev-tools marketplace repository: creates the plugin directory, plugin.json manifest, skills/ folder, and registers it in marketplace.json. Use when the user asks to add a new plugin, create a plugin, or register a plugin in the marketplace.