بنقرة واحدة
you-might-not-need-an-effect
// Analyze code for useEffect anti-patterns and refactor to simpler alternatives. Use when the user says "you might not need an effect", "check effects", "useEffect audit", or asks to review useEffect usage.
// Analyze code for useEffect anti-patterns and refactor to simpler alternatives. Use when the user says "you might not need an effect", "check effects", "useEffect audit", or asks to review useEffect usage.
Create a GitHub issue from recent changes, commit only relevant diffs on a short-lived task branch, push that branch, and open a PR into master that will close the issue on merge. Use when the user says "make closed issue", "close issue", or wants to create a tracked, already-resolved GitHub issue for completed work.
Commit current work by reviewing diffs, splitting into logical commits, and writing standardized messages. Use when the user says "commit", "commit this", "commit current work", or asks to create a git commit.
Scan recent changes for AI-generated code slop and remove it. Use when the user says "deslop", "remove slop", "clean up AI code", or asks to remove AI-generated artifacts from the codebase.
Perform a refactor pass focused on simplicity after recent changes. Use when the user asks for a refactor/cleanup pass, simplification, dead-code removal, or says "refactor pass".
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill for X". Use this to search the open skill ecosystem.
Review an open GitHub pull request, inspect feedback from CI, review bots, and human reviewers, decide which findings are valid, implement fixes on the PR branch, merge the PR into master when it is ready, and finalize the linked GitHub issue and project status after merge. Use when the user says "check the PR", "address review comments", "review PR feedback", or "merge this PR".
| name | you-might-not-need-an-effect |
| description | Analyze code for useEffect anti-patterns and refactor to simpler alternatives. Use when the user says "you might not need an effect", "check effects", "useEffect audit", or asks to review useEffect usage. |
| disable-model-invocation | true |
Analyze code for useEffect anti-patterns and refactor to simpler, more correct alternatives.
Based on https://react.dev/learn/you-might-not-need-an-effect
diff to main, src/hooks/, whole codebasetrue). Set to false to only propose changes.Determine scope — get the relevant code:
git diff for uncommitted changes.ts files for useEffectScan for anti-patterns — check each useEffect against the patterns below
Fix or propose — depending on the fix argument:
fix=true: apply the refactors, then verify with yarn buildfix=false: list each anti-pattern found with a before/after code suggestionReport — summarize what was found and changed
If you're computing something from existing props or state, calculate it during render.
// ❌ Anti-pattern
const [fullName, setFullName] = useState('');
useEffect(() => {
setFullName(firstName + ' ' + lastName);
}, [firstName, lastName]);
// ✅ Fix — derive during render
const fullName = firstName + ' ' + lastName;
// ❌ Anti-pattern
const [filtered, setFiltered] = useState([]);
useEffect(() => {
setFiltered(items.filter(item => item.active));
}, [items]);
// ✅ Fix — calculate during render (useMemo only if profiling shows it's needed)
const filtered = items.filter(item => item.active);
// ❌ Anti-pattern
useEffect(() => {
setComment('');
}, [postCid]);
// ✅ Fix — use key on the component to reset state
<CommentForm key={postCid} />
// ❌ Anti-pattern
const [data, setData] = useState(null);
useEffect(() => {
const unsub = someStore.subscribe((s) => setData(s.data));
return unsub;
}, []);
// ✅ Fix — use the Zustand store directly
const data = useSomeStore((s) => s.data);
// ❌ Anti-pattern
useEffect(() => {
initializeSomething();
}, []);
// ✅ Fix — module-level init (runs once on import)
if (typeof window !== 'undefined') {
initializeSomething();
}
This is a hooks library, not an app. Effects in this codebase are more likely to be legitimate (subscribing to pkc-js events, managing store listeners) than in a typical React app. Be extra careful before removing effects that manage subscriptions or event listeners with cleanup functions.
| Pattern | Likely legitimate |
|---|---|
| Store subscription with cleanup | Yes — keep |
| pkc-js event listener with cleanup | Yes — keep |
| Deriving state from other state | No — compute during render |
| Setting state from props | No — derive or use key |
| One-time initialization | Maybe — consider module scope |
Not every effect is wrong. Keep useEffect for: