gpaiva00

simplify

Review changed code for reuse, code quality, and efficiency, then fix the issues found. Use when the user asks to simplify, clean up, polish, refactor, or review a change set for duplication, hacky patterns, unnecessary complexity, or performance waste.

gpaiva00 0 Updated 2mo ago

Resources

1
GitHub

Install

npx skillscat add gpaiva00/simplify-skill

Install via the SkillsCat registry.

SKILL.md

Simplify: Code Review and Cleanup

Review all changed files for reuse, quality, and efficiency. Fix any issues found.

Phase 1: Identify Changes

Run git diff (or git diff HEAD if there are staged changes) to see what changed. If there are no git changes, review the most recently modified files that the user mentioned or that you edited earlier in this conversation.

Phase 2: Launch Three Review Agents in Parallel

Use the Task tool (with a general subagent) to launch all three review agents concurrently in a single message. Pass each agent the full diff and clear instructions so they have the complete context.

Agent 1: Code Reuse Review

For each change:

  1. Search for existing utilities and helpers that could replace newly written code. Look for similar patterns elsewhere in the codebase — common locations are utility directories, shared modules, and files adjacent to the changed ones.
  2. Flag any new function that duplicates existing functionality. Suggest the existing function to use instead.
  3. Flag any inline logic that could use an existing utility — hand-rolled string manipulation, manual path handling, custom environment checks, ad-hoc type guards, and similar patterns are common candidates.

Agent 2: Code Quality Review

Review the same changes for hacky patterns:

  1. Redundant state: State that duplicates existing state, cached values that could be derived, observers/effects that could be direct calls.
  2. Parameter sprawl: Adding new parameters to a function instead of generalizing or restructuring existing ones.
  3. Copy-paste with slight variation: Near-duplicate code blocks that should be unified with a shared abstraction.
  4. Leaky abstractions: Exposing internal details that should be encapsulated, or breaking existing abstraction boundaries.
  5. Stringly-typed code: Using raw strings where constants, enums (string unions), or branded types already exist in the codebase.
  6. Unnecessary JSX nesting: Wrapper elements (e.g., <Box>) that add no layout value — check if inner component props already provide the needed behavior.
  7. Unnecessary comments: Comments explaining what the code does (well-named identifiers already do that), narrating the change, or referencing the task/caller. Keep only non-obvious why (hidden constraints, workarounds).

Agent 3: Efficiency Review

Review the same changes for efficiency:

  1. Unnecessary work: Redundant computations, repeated file reads, duplicate network/API calls, N+1 patterns.
  2. Missed concurrency: Independent operations run sequentially when they could run in parallel.
  3. Hot-path bloat: New blocking work added to startup or per-request/per-render hot paths.
  4. Recurring no-op updates: State/store updates inside polling loops, intervals, or event handlers that fire unconditionally. Add a change-detection guard so downstream consumers aren't notified when nothing changed.
  5. Unnecessary existence checks: Pre-checking file/resource existence before operating (TOCTOU anti-pattern). Operate directly and handle the error.
  6. Memory: Unbounded data structures, missing cleanup, event listener leaks.
  7. Overly broad operations: Reading entire files when only a portion is needed, loading all items when filtering for one.

Phase 3: Fix Issues

Wait for all three agents to complete. Aggregate their findings and fix each issue directly. If a finding is a false positive or not worth addressing, note it and move on — do not argue with the finding, just skip it.

Phase 4: Verification (Optional but Recommended)

If the project has linters or tests, run them (e.g., npm run lint, pytest) to ensure the cleanup did not introduce regressions or style issues.

When done, briefly summarize what was fixed (or confirm the code was already clean).