Agent Skillssimstudioai/sim › you-might-not-need-a-memo

you-might-not-need-a-memo

GitHub

分析并修复代码中 useMemo 和 React.memo 的反模式,如滥用记忆化、依赖错误等。通过下移状态或提升组件优化性能,避免不必要的记忆化开销。

.agents/skills/you-might-not-need-a-memo/SKILL.md simstudioai/sim

Trigger Scenarios

需要审查或修复 React 组件性能问题 检查代码是否存在无效的 useMemo 或 React.memo 使用

Install

npx skills add simstudioai/sim --skill you-might-not-need-a-memo -g -y
More Options

Non-standard path

npx skills add https://github.com/simstudioai/sim/tree/main/.agents/skills/you-might-not-need-a-memo -g -y

Use without installing

npx skills use simstudioai/sim@you-might-not-need-a-memo

指定 Agent (Claude Code)

npx skills add simstudioai/sim --skill you-might-not-need-a-memo -a claude-code -g -y

安装 repo 全部 skill

npx skills add simstudioai/sim --all -g -y

预览 repo 内 skill

npx skills add simstudioai/sim --list

SKILL.md

Frontmatter
{
    "name": "you-might-not-need-a-memo",
    "description": "Analyze and fix useMemo\/React.memo anti-patterns in your code",
    "argument-hint": "[scope] [fix=true|false]"
}

You Might Not Need a Memo

Arguments:

  • scope: what to analyze (default: your current changes). Examples: "diff to main", "PR #123", "src/components/", "whole codebase"
  • fix: whether to apply fixes (default: true). Set to false to only propose changes.

User arguments: $ARGUMENTS

References

Read before analyzing:

  1. https://overreacted.io/before-you-memo/ — two techniques to avoid memo entirely

Anti-patterns to detect

  1. Wrapping a slow component in React.memo when state can be moved down: If a component re-renders because of state it doesn't use, move that state into a smaller child component instead of memoizing. The slow component stops re-rendering without memo.
  2. Wrapping in React.memo when children can be lifted up: If a parent owns state that changes frequently, extract the stateful part and pass the expensive subtree as children. Children passed as props don't re-render when the parent's state changes.
  3. useMemo on cheap computations: Filtering or mapping a small array, string concatenation, simple arithmetic — these don't need memoization. Only memoize when you've measured a performance problem.
  4. useMemo with constantly-changing deps: If the dependency array changes on every render, useMemo does nothing — it recalculates every time. Fix the deps or remove the memo.
  5. useMemo to create objects/arrays passed as props: Instead of memoizing to prevent child re-renders, consider whether the child even needs referential stability. If the child doesn't use React.memo or pass it to a dep array, the memo is wasted.
  6. React.memo on components that always receive new props: If the parent always passes new objects, arrays, or callbacks, React.memo's shallow comparison always fails. Fix the parent instead of memoizing the child.
  7. useMemo for derived state: If you're computing a value from props or state, just compute it inline during render. React renders are fast. const fullName = first + ' ' + last doesn't need useMemo.

Steps

  1. Read the reference above to understand the two core techniques (move state down, lift content up)
  2. Analyze the specified scope for the anti-patterns listed above
  3. If fix=true, apply the fixes. If fix=false, propose the fixes without applying.

Version History

  • ceda457 Current 2026-08-20 15:29

Same Skill Collection

.agents/skills/add-block-preview/SKILL.md
.agents/skills/add-block/SKILL.md
.agents/skills/add-column-type/SKILL.md
.agents/skills/add-connector/SKILL.md
.agents/skills/add-enrichment/SKILL.md
.agents/skills/add-feature-flag/SKILL.md
.agents/skills/add-hosted-key/SKILL.md
.agents/skills/add-integration/SKILL.md
.agents/skills/add-managed-cli/SKILL.md
.agents/skills/add-model/SKILL.md
.agents/skills/add-tools/SKILL.md
.agents/skills/add-trigger/SKILL.md
.agents/skills/babysit/SKILL.md
.agents/skills/cleanup/SKILL.md
.agents/skills/council/SKILL.md
.agents/skills/db-migrate/SKILL.md
.agents/skills/design-taste-frontend/SKILL.md
.agents/skills/emcn-design-review/SKILL.md
.agents/skills/emil-design-eng/SKILL.md
.agents/skills/make-interfaces-feel-better/SKILL.md
.agents/skills/memory-load-check/SKILL.md
.agents/skills/react-query-best-practices/SKILL.md
.agents/skills/ship/SKILL.md
.agents/skills/tool-registry-boundary/SKILL.md
.agents/skills/v2-api-conventions/SKILL.md
.agents/skills/validate-connector/SKILL.md
.agents/skills/validate-integration/SKILL.md
.agents/skills/validate-model/SKILL.md
.agents/skills/validate-trigger/SKILL.md
.agents/skills/you-might-not-need-a-callback/SKILL.md
.agents/skills/you-might-not-need-a-comment/SKILL.md
.agents/skills/you-might-not-need-an-effect/SKILL.md
.agents/skills/you-might-not-need-state/SKILL.md
.agents/skills/you-might-not-need-url-state/SKILL.md
.claude/skills/add-settings-page/SKILL.md
helm/sim/.claude/skills/sim-helm/SKILL.md
.agents/skills/migrate-application-operation/SKILL.md

Metadata

Files
0
Version
ceda457
Hash
36bb1382
Indexed
2026-08-20 15:29

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-25 07:25
浙ICP备14020137号-1 $방문자$