| name | refine-last-changes |
|---|---|
| description | Review and improve the most recent code changes using parallel read-only agents focused on simplicity, architecture, cognitive load, performance, and reuse. Use when refining staged, unstaged, untracked, committed, or explicitly scoped changes while preserving behavior and avoiding broad refactors. |
Simplify the scoped code while preserving behavior. Use parallel read-only reviewers to identify focused improvements, then apply the smallest coherent set of fixes yourself.
Optimize for:
- correctness;
- low cognitive load;
- clear architecture and ownership;
- reuse;
- performance.
Prefer code that is easy to understand locally. Do not introduce abstractions, indirection, or architectural layers unless they remove more complexity than they add.
Select the scope in this order:
- Explicit paths, symbols, diff, commit, or area provided after
/simplify. - Otherwise, inspect all local changes:
git diff --no-color
git diff --cached --no-color
git ls-files --others --exclude-standard- Otherwise, use concrete files or changes mentioned in the conversation.
- Otherwise, inspect the current commit:
git show --stat --patch --no-color HEADRead nearby code when needed to understand callers, boundaries, or existing patterns. Do not edit unrelated code.
Preserve all unrelated user changes.
Launch the following reviewers in parallel. They must use the same model as the parent agent and only report findings.
Reviewers must not edit files, run formatters, create branches or worktrees, or commit changes.
Pass the complete diff when practical. Otherwise, pass the scoped files, relevant hunks, changed symbols, and a concise scope summary.
Each finding must include:
- location;
- concrete problem;
- proposed change;
- expected benefit;
- confidence.
Do not report style preferences without a clear effect on comprehension, correctness, architecture, or performance.
Look for:
- comments that merely restate the code;
- one-use helpers that obscure the flow;
- unnecessary wrappers, configuration objects, or generic abstractions;
- excessive nesting or fragmented control flow;
- redundant defensive checks;
- unnecessary nullable states;
- broad error handling;
- duplicated or derived state;
- avoidable casts, assertions, or broad types;
- dead, compatibility, or fallback code without evidence of need.
Preserve helpers that express domain concepts, isolate side effects, enforce invariants, or provide meaningful reuse.
Evaluate whether the changed code is easy to reason about and fits the existing architecture.
Look for:
- unclear module or function responsibilities;
- business rules placed in transport, UI, persistence, or infrastructure layers;
- dependencies pointing in the wrong direction;
- hidden coupling through globals, shared mutable state, callbacks, or side effects;
- duplicated policy across modules;
- abstractions that leak implementation details;
- functions that require too much context to understand;
- temporal coupling or order-dependent behavior;
- state with unclear ownership;
- names that conceal domain intent;
- changes that require editing many unrelated locations.
Prefer:
- explicit ownership;
- cohesive modules;
- narrow interfaces;
- linear control flow;
- visible invariants;
- domain-oriented names;
- dependencies on stable abstractions already used by the repository.
Recommend broad architectural changes only as skipped findings. Applied fixes must remain proportional to the original scope.
Look for plausible issues in real execution paths:
- blocking operations in hot paths;
- repeated expensive computation, parsing, or allocation;
- N+1 I/O;
- independent operations executed sequentially;
- repeated collection traversal;
- quadratic string or collection construction;
- busy polling;
- unbounded concurrency;
- excessive logging in loops or hot paths.
Do not recommend caching or concurrency without considering invalidation, ordering, error handling, and resource limits.
Search the scoped code and relevant nearby modules for existing:
- helpers;
- types;
- validators;
- formatters;
- components;
- services;
- error-handling patterns;
- domain abstractions.
Reuse existing code only when its behavior, ownership, and dependency direction match the current need. Do not force reuse merely because similar code exists.
Aggregate and deduplicate the findings. Verify each one directly against the code.
Apply a finding only when it:
- preserves observable behavior;
- has clear evidence;
- lowers cognitive load or net complexity;
- respects existing architectural boundaries;
- fits the selected scope;
- can be implemented safely as a focused change.
Skip findings that are speculative, stylistic, low-confidence, behavior-changing, or require a substantially broader refactor.
When two solutions are valid, prefer the one with:
- fewer concepts;
- fewer states;
- fewer dependencies;
- less indirection;
- clearer ownership;
- easier local reasoning.
Make the smallest coherent set of improvements.
Prefer:
- deleting unnecessary code;
- simplifying control flow;
- making invariants explicit;
- consolidating duplicated policy;
- using established repository patterns;
- narrowing types and interfaces;
- moving logic to the layer that owns it;
- reducing repeated work.
Avoid:
- unrelated renaming or formatting;
- speculative abstractions;
- new dependencies without strong justification;
- generic utilities created for one caller;
- public API changes;
- broad architectural rewrites;
- replacing familiar code with clever code.
After editing:
- Inspect the final diff for unrelated or accidental changes.
- Confirm architectural boundaries and dependency direction did not worsen.
- Run the narrowest relevant formatter check, lint, type check, and targeted tests.
- Fix failures introduced by your changes.
- Report checks that were unavailable and unrelated pre-existing failures.
Summarize the changes actually applied and how they reduced complexity, cognitive load, architectural friction, or runtime cost.
List the checks run and their results.
List valuable findings not applied because they required more context, changed behavior, increased risk, or exceeded the selected scope.
Omit empty sections. Never present an unimplemented recommendation as completed work.