Loading...
Loading...
Review changed code for reuse opportunities, quality issues, and inefficiencies using three parallel review agents, then fix any issues found. Triggers when the user says "simplify", "clean up the code", "review the changes", or after run-plan execution when code quality verification is needed.
npx skill4agent add tmdgusya/engineering-discipline simplifygit diffgit diff HEADreview-workgit diffgit diff HEADYou are reviewing a code diff for reuse opportunities. Your job is to find new code that duplicates functionality already in the codebase.For each change in the diff:
- Search for existing utilities and helpers that could replace newly written code. Search utility directories (
,utils/,helpers/,lib/,common/), files adjacent to the changed ones, and files imported by the changed files.shared/- Flag any new function that duplicates existing functionality. Report the new function, the existing function, and where the existing one lives.
- Flag inline logic that could use an existing utility. Common candidates: hand-rolled string manipulation, manual path handling, custom environment checks, ad-hoc type guards, manual array/object transformations, date/time formatting done inline.
- Flag reimplemented standard library features. Check if the change reimplements something available in the language's standard library or in already-installed dependencies.
For each finding, report:
- Reuse opportunity: [brief description]
- New code: [file:line] — [what was written]
- Existing: [file:line] — [what already exists]
- Suggestion: [how to replace]
If no reuse issues are found, report: "No reuse issues found."
You are reviewing a code diff for quality issues. Your job is to find hacky patterns, unnecessary complexity, and abstraction boundary violations.Check for these patterns:
- Redundant state: new variables that are always derived from another variable, caches that store what could be computed on access, event listeners or observers that could be direct function calls.
- Parameter sprawl: functions that gained a new boolean flag parameter, functions with more than 4 parameters after the change, multiple parameters that are always passed together and should be a single object.
- Copy-paste with slight variation: two or more blocks that differ by only 1-2 lines, repeated conditional structures with different field names, similar error handling blocks across multiple locations.
- Leaky abstractions: accessing private fields or internal state from outside the module, passing implementation details across module boundaries, changes that make one module depend on another's internal structure.
- Stringly-typed code: new string comparisons against values already defined as constants, new string literals matching existing enum or union type values, magic strings appearing in multiple places without a shared constant.
- Unnecessary comments: comments explaining WHAT the code does, narrating the change, or referencing a task. Delete these. Keep only comments that explain non-obvious WHY — hidden constraints, subtle invariants, workarounds. Example to delete:
above// increment counter. Example to keep:counter++.// Redis returns nil for both "key missing" and "value is empty" — we must distinguishFor each finding, report:
- Quality issue: [category]
- Location: [file:line]
- Problem: [what is wrong]
- Suggestion: [how to fix]
If no quality issues are found, report: "No quality issues found."
You are reviewing a code diff for efficiency issues. Your job is to find unnecessary work, missed concurrency, and resource management problems. Do not optimize prematurely — flag only what is clearly unnecessary or clearly mismanaged.Check for these patterns:
- Unnecessary work: the same value computed multiple times in a loop, the same file read more than once, the same API call made repeatedly when the result could be cached or batched, database queries inside loops that could be a single query with WHERE IN.
- Missed concurrency: multiple
calls in sequence where the operations are independent, sequential file reads that could be parallelized, independent API calls executed one after another.await- Hot-path bloat: synchronous file I/O added to a request handler, new computation in a render function that could be memoized, new initialization logic added to module load time.
- Recurring no-op updates: state setters called on every interval tick without checking if the value changed, store dispatches firing on every event without a change-detection guard, wrapper functions that take updater callbacks but do not honor "no change" returns — add a change-detection guard so downstream consumers are not notified when nothing changed.
- Unnecessary existence checks (TOCTOU):
— operate directly and handle the error instead.if (existsSync(path)) { readFileSync(path) }- Memory issues: collections that grow without bound, event listeners registered without corresponding removal, subscriptions without cleanup in dispose/destroy handlers, large objects held in closure scope longer than needed.
- Overly broad operations: reading entire files to extract a single value, fetching all records to find one by ID, loading an entire config when only one field is needed.
For each finding, report:
- Efficiency issue: [category]
- Location: [file:line]
- Problem: [what is wasteful]
- Suggestion: [how to fix]
If no efficiency issues are found, report: "No efficiency issues found."
systematic-debugging| Anti-Pattern | Why It Fails |
|---|---|
| Reviewing without running git diff first | Reviews code that may not have changed, wastes time on irrelevant findings |
| Running agents sequentially | Unnecessary delay; violates Hard Gate #2 |
| Giving each agent only part of the diff | Agent misses cross-cutting issues that span multiple files |
| Reporting findings without fixing them | Defeats the purpose of the skill; user must do manual work |
| Arguing with or explaining skipped findings | Wastes context and time; skip and move on |
| Reviewing unchanged code "while we're here" | Scope creep; violates Hard Gate #6 |
| Fixing issues without running tests afterward | May introduce regressions silently |
| Bundling "while I'm here" improvements into fixes | Mixes review fixes with unrelated changes; muddles the diff |
review-worksimplifysystematic-debugging