Code Simplifier
Overview
Simplify recently changed code while preserving exact external behavior. Favor explicit, readable, project-consistent code over clever or overly compact rewrites.
Scope
Default to code touched in the current session or the current diff. Expand only when the user explicitly asks for a broader pass.
Treat these as in scope:
- files changed in the current conversation
- staged or unstaged diff for the requested work
- small fallout fixes needed to keep the simplification coherent
Do not widen the pass to unrelated legacy code unless the user asks.
Project Rules
Read the nearest high-authority guidance before editing:
AGENTS.md
- a nearer path-local
AGENTS.md under the target subtree
CLAUDE.md or claude.md if present
- any explicit style guide or instructions named by the user
Apply those conventions literally when they affect naming, function style, imports, types, error handling, component patterns, or file organization.
Simplification Rules
Preserve exact functionality and public API.
- do not change outputs, side effects, data contracts, exported names, routes, env keys, persistence shape, or user-visible behavior unless the user asks
- keep logic equivalent; if equivalence is uncertain, stop and narrow the change
- preserve error semantics; do not add or remove
try/catch, retries, or fallback behavior casually
Prefer clarity over brevity.
- reduce unnecessary nesting
- inline pointless indirection
- remove redundant temporary variables when readability improves
- consolidate duplicated logic when behavior clearly stays the same
- keep helpful abstractions; do not collapse distinct concerns into one function
- avoid dense one-liners and clever tricks
- avoid nested ternaries; use
if/else or switch for multi-branch logic
Remove noise, not signal.
- remove comments that only narrate obvious code
- keep comments that explain intent, invariants, edge cases, or non-obvious tradeoffs
- remove defensive checks only when surrounding guarantees already make them redundant
- simplify casts or assertions only when they are clearly unnecessary
Workflow
- Identify the target scope from the current session or diff.
- Read applicable
AGENTS.md, CLAUDE.md, and nearby code patterns.
- Simplify the smallest useful unit first.
- Re-check for behavior, API, and naming regressions.
- Run the smallest relevant verification available when the change is non-trivial.
- Report the simplifications made and any intentionally skipped opportunities.
Good Targets
- redundant guards after prior validation
- obvious comments that restate code
- duplicate branches producing the same result
- helpers used once that hide simple logic
- noisy casts that restate known types
- conditionals that become clearer as early returns
Avoid
- cross-module rewrites without a request
- formatting-only churn mixed into logic edits
- refactors that require product judgment
- replacing readable code with clever compact code
- deleting useful abstractions, docs, or tests just to shrink line count
1---2name: code-simplifier3description: Use when the user wants a behavior-preserving simplification or cleanup of recently changed code, especially requests like simplify this code, clean this up, remove AI slop, reduce defensive noise, align with project conventions, or refactor without changing behavior. Best for tightening modified files, removing redundant comments/checks/abstractions, and applying repository guidance from AGENTS.md, CLAUDE.md, or similar instruction files.4---56# Code Simplifier78## Overview910Simplify recently changed code while preserving exact external behavior. Favor explicit, readable, project-consistent code over clever or overly compact rewrites.1112## Scope1314Default to code touched in the current session or the current diff. Expand only when the user explicitly asks for a broader pass.1516Treat these as in scope:1718- files changed in the current conversation19- staged or unstaged diff for the requested work20- small fallout fixes needed to keep the simplification coherent2122Do not widen the pass to unrelated legacy code unless the user asks.2324## Project Rules2526Read the nearest high-authority guidance before editing:27281. `AGENTS.md`292. a nearer path-local `AGENTS.md` under the target subtree303. `CLAUDE.md` or `claude.md` if present314. any explicit style guide or instructions named by the user3233Apply those conventions literally when they affect naming, function style, imports, types, error handling, component patterns, or file organization.3435## Simplification Rules3637Preserve exact functionality and public API.3839- do not change outputs, side effects, data contracts, exported names, routes, env keys, persistence shape, or user-visible behavior unless the user asks40- keep logic equivalent; if equivalence is uncertain, stop and narrow the change41- preserve error semantics; do not add or remove `try/catch`, retries, or fallback behavior casually4243Prefer clarity over brevity.4445- reduce unnecessary nesting46- inline pointless indirection47- remove redundant temporary variables when readability improves48- consolidate duplicated logic when behavior clearly stays the same49- keep helpful abstractions; do not collapse distinct concerns into one function50- avoid dense one-liners and clever tricks51- avoid nested ternaries; use `if/else` or `switch` for multi-branch logic5253Remove noise, not signal.5455- remove comments that only narrate obvious code56- keep comments that explain intent, invariants, edge cases, or non-obvious tradeoffs57- remove defensive checks only when surrounding guarantees already make them redundant58- simplify casts or assertions only when they are clearly unnecessary5960## Workflow61621. Identify the target scope from the current session or diff.632. Read applicable `AGENTS.md`, `CLAUDE.md`, and nearby code patterns.643. Simplify the smallest useful unit first.654. Re-check for behavior, API, and naming regressions.665. Run the smallest relevant verification available when the change is non-trivial.676. Report the simplifications made and any intentionally skipped opportunities.6869## Good Targets7071- redundant guards after prior validation72- obvious comments that restate code73- duplicate branches producing the same result74- helpers used once that hide simple logic75- noisy casts that restate known types76- conditionals that become clearer as early returns7778## Avoid7980- cross-module rewrites without a request81- formatting-only churn mixed into logic edits82- refactors that require product judgment83- replacing readable code with clever compact code84- deleting useful abstractions, docs, or tests just to shrink line count