Simplify
Review the current code changes for reuse, quality, and efficiency. Fix worthwhile issues directly.
Scope the review
First determine what changed:
- If there are staged changes, review the full working change with
git diff HEAD.
- Otherwise review unstaged changes with
git diff.
- If there are no git changes, review the most recently modified files that:
- the user mentioned, or
- you edited earlier in this conversation.
Use the resulting diff or file set as the review scope.
If the user gave an extra focus area, apply it in every pass without narrowing the base review scope unless they explicitly asked for a narrower review.
Run three review passes
Prefer using subagents if the environment supports them. Launch all three in parallel and give each one the full diff or full file context.
If no subagent tool is available, perform the same three passes yourself, one after another.
Pass 1: Reuse review
For each change:
- Search for existing helpers, utilities, shared modules, and nearby abstractions that could replace newly written code.
- Flag new functions that duplicate existing behavior.
- Flag inline logic that should use an existing utility.
Common candidates:
- string manipulation
- path handling
- environment checks
- type guards
- parsing / formatting helpers
- repeated mapping / filtering logic
- shared UI primitives or wrappers
Prefer reusing an existing abstraction over adding a second version of the same idea.
Pass 2: Code quality review
Look for:
Redundant state
- duplicated state
- cached values that should be derived
- effects/observers that should be direct calls
Parameter sprawl
- new parameters added where restructuring or a shared options object would be cleaner
- functions becoming harder to understand because of branching arguments
Copy-paste with slight variation
- near-duplicate blocks that should become one abstraction
Leaky abstractions
- exposing internal details across module boundaries
- bypassing an existing abstraction instead of extending it cleanly
Stringly-typed code
- raw strings where constants, enums, unions, or existing types should be used
Unnecessary UI nesting
- wrapper elements/components that add no layout or semantic value
- nesting that could be replaced by existing props or composition
Unnecessary comments
- remove comments that only narrate what the code already says
- remove comments about the task, caller, or obvious implementation steps
- keep only non-obvious why/constraint/invariant comments
Pass 3: Efficiency review
Look for:
Unnecessary work
- repeated computation
- duplicate reads
- repeated API/network/file operations
- N+1 patterns
Missed concurrency
- independent work done sequentially that could run in parallel
Hot-path bloat
- new blocking work in startup, render, request, or polling paths
Recurring no-op updates
- state/store updates fired unconditionally inside loops, intervals, subscriptions, or handlers
- wrappers that ignore “no change” signals such as same-reference returns
Unnecessary existence checks
- pre-checking resource existence before acting on it when direct operation plus error handling is cleaner
Memory and lifecycle issues
- missing cleanup
- listener leaks
- unbounded caches/collections
Overly broad operations
- reading/loading whole datasets or files when only part is needed
Fix issues
After all three passes finish:
- Aggregate the findings.
- Fix each worthwhile issue directly.
- If a finding is a false positive or not worth addressing, skip it without debating it.
- Preserve behavior unless the cleanup itself is the intended behavior change.
- Prefer the smallest clear fix that improves the codebase.
Final check
Before finishing:
- Re-read the updated code.
- Confirm the change is simpler, more reusable, and no less correct.
- Make sure you did not introduce abstraction churn for tiny gains.
- Ensure naming still matches the surrounding codebase style.
Output
Briefly summarize:
- what you fixed, or
- that the reviewed code was already clean
If you skipped any findings, mention them briefly without long justification.
1---2name: simplify3description: Review changed code and clean it up. Use when asked to simplify, clean up, refactor, polish, de-duplicate, or review recent code changes for reuse, code quality, maintainability, or efficiency. Inspect the current diff, run reuse/quality/efficiency review passes, and fix worthwhile issues directly.4---56# Simplify78Review the current code changes for reuse, quality, and efficiency. Fix worthwhile issues directly.910## Scope the review1112First determine what changed:13141. If there are staged changes, review the full working change with `git diff HEAD`.152. Otherwise review unstaged changes with `git diff`.163. If there are no git changes, review the most recently modified files that:17 - the user mentioned, or18 - you edited earlier in this conversation.1920Use the resulting diff or file set as the review scope.2122If the user gave an extra focus area, apply it in every pass without narrowing the base review scope unless they explicitly asked for a narrower review.2324## Run three review passes2526Prefer using subagents if the environment supports them. Launch all three in parallel and give each one the full diff or full file context.2728If no subagent tool is available, perform the same three passes yourself, one after another.2930### Pass 1: Reuse review3132For each change:33341. Search for existing helpers, utilities, shared modules, and nearby abstractions that could replace newly written code.352. Flag new functions that duplicate existing behavior.363. Flag inline logic that should use an existing utility.3738Common candidates:39- string manipulation40- path handling41- environment checks42- type guards43- parsing / formatting helpers44- repeated mapping / filtering logic45- shared UI primitives or wrappers4647Prefer reusing an existing abstraction over adding a second version of the same idea.4849### Pass 2: Code quality review5051Look for:52531. Redundant state54 - duplicated state55 - cached values that should be derived56 - effects/observers that should be direct calls57582. Parameter sprawl59 - new parameters added where restructuring or a shared options object would be cleaner60 - functions becoming harder to understand because of branching arguments61623. Copy-paste with slight variation63 - near-duplicate blocks that should become one abstraction64654. Leaky abstractions66 - exposing internal details across module boundaries67 - bypassing an existing abstraction instead of extending it cleanly68695. Stringly-typed code70 - raw strings where constants, enums, unions, or existing types should be used71726. Unnecessary UI nesting73 - wrapper elements/components that add no layout or semantic value74 - nesting that could be replaced by existing props or composition75767. Unnecessary comments77 - remove comments that only narrate what the code already says78 - remove comments about the task, caller, or obvious implementation steps79 - keep only non-obvious why/constraint/invariant comments8081### Pass 3: Efficiency review8283Look for:84851. Unnecessary work86 - repeated computation87 - duplicate reads88 - repeated API/network/file operations89 - N+1 patterns90912. Missed concurrency92 - independent work done sequentially that could run in parallel93943. Hot-path bloat95 - new blocking work in startup, render, request, or polling paths96974. Recurring no-op updates98 - state/store updates fired unconditionally inside loops, intervals, subscriptions, or handlers99 - wrappers that ignore “no change” signals such as same-reference returns1001015. Unnecessary existence checks102 - pre-checking resource existence before acting on it when direct operation plus error handling is cleaner1031046. Memory and lifecycle issues105 - missing cleanup106 - listener leaks107 - unbounded caches/collections1081097. Overly broad operations110 - reading/loading whole datasets or files when only part is needed111112## Fix issues113114After all three passes finish:1151161. Aggregate the findings.1172. Fix each worthwhile issue directly.1183. If a finding is a false positive or not worth addressing, skip it without debating it.1194. Preserve behavior unless the cleanup itself is the intended behavior change.1205. Prefer the smallest clear fix that improves the codebase.121122## Final check123124Before finishing:1251261. Re-read the updated code.1272. Confirm the change is simpler, more reusable, and no less correct.1283. Make sure you did not introduce abstraction churn for tiny gains.1294. Ensure naming still matches the surrounding codebase style.130131## Output132133Briefly summarize:134- what you fixed, or135- that the reviewed code was already clean136137If you skipped any findings, mention them briefly without long justification.