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.
Apply these strategies to keep components, hooks, and methods focused, testable, and readable. Rules are split by file type into dedicated reference files — load only the one matching the code being simplified.
| 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. | | Composition | Prefer composing small components and utilities over large, multi-purpose blocks. |
Use the file where the function lives to pick the reference file:
*.tsx → components → references/component-simplification.mduse*.ts → hooks → references/hook-simplification.md*.ts (plain functions) → methods → references/method-simplification.mdPlain TypeScript functions are always in *.ts, never in *.tsx. Load the matching reference file first, then apply the Shared rules below regardless of file type.
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.undefined, apply its fallback once at destructuring (const { x = fallback } = source) instead of repeating x ?? fallback at every call site that reads it.i18n.language) is read several times in one scope, destructure it once near the top (const { language } = i18n, or const { i18n: { language } } = useTranslation()) and reuse the local binding.*.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 per-function threshold defined in references/method-simplification.md.market-list-item.tsx, use-market-filters.ts, <name>.utils.ts, (e.g. market-list.utils.ts).get xyz() { return ... }) to promote DRY and simplify method bodies.npx skills add Lichens-Innovation/react-single-responsibility下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer