Simplify
Refine code for clarity, consistency, and maintainability without changing what it does. Prefer boring, explicit code that fits the project over clever or compact rewrites.
Scope
- Default to code changed in the current task, current branch, or explicitly requested files.
- If the target is unclear, inspect the working tree diff first and focus on changed files.
- Do not perform broad refactors unless the user explicitly asks for a wider cleanup.
- Preserve public APIs, data formats, side effects, error behavior, and user-visible output unless the user requested a behavior change.
Workflow
- Understand the current behavior from code, tests, usage sites, and the user's request.
- Identify simplification opportunities:
- unnecessary abstraction or indirection
- duplicated logic
- avoidable nesting or branching
- overly generic helpers used only once
- unclear names or control flow
- comments that merely restate obvious code
- inconsistent style compared with nearby code
- Apply small, reviewable edits that make the code easier to reason about.
- Prefer existing project conventions and utilities over introducing new patterns.
- Run the most relevant available checks: tests, typecheck, lint, format, or a focused command. If checks cannot be run, explain why.
- Report what changed, what behavior was preserved, and what verification was performed.
Simplification principles
- Clarity beats fewer lines. Do not collapse logic into dense one-liners just to make code shorter.
- Avoid nested ternaries for multi-branch logic; use
if/else, early returns, lookup tables, or switch/pattern matching when clearer.
- Prefer local reasoning. Keep related logic close together unless extraction clearly improves readability or reuse.
- Remove abstractions that hide simple behavior, but keep abstractions that encode real domain concepts or are used consistently across the project.
- Choose names that explain intent rather than mechanics.
- Keep error handling explicit enough that failure modes remain understandable.
- Avoid mixing unrelated concerns in the same function while simplifying.
Safety checks
Before finalizing, confirm:
- No intentional behavior changed.
- Existing tests still pass, or the reason they were not run is documented.
- The diff is smaller or easier to review than the original approach.
- New helpers, if any, have at least a clear reason to exist.
- The style matches nearby code and repository guidance files when present.
Response format
When done, summarize briefly:
- Simplified: key cleanup points
- Preserved: behavior/API assumptions kept unchanged
- Verified: commands run and results, or why verification was skipped
1---2name: simplify3description: Simplify recently written or modified code while preserving behavior. Use this skill whenever the user asks to simplify, clean up, reduce complexity, remove over-engineering, make code easier to read, or run a simplify pass after implementation or bug fixing.4---56# Simplify78Refine code for clarity, consistency, and maintainability without changing what it does. Prefer boring, explicit code that fits the project over clever or compact rewrites.910## Scope1112- Default to code changed in the current task, current branch, or explicitly requested files.13- If the target is unclear, inspect the working tree diff first and focus on changed files.14- Do not perform broad refactors unless the user explicitly asks for a wider cleanup.15- Preserve public APIs, data formats, side effects, error behavior, and user-visible output unless the user requested a behavior change.1617## Workflow18191. Understand the current behavior from code, tests, usage sites, and the user's request.202. Identify simplification opportunities:21 - unnecessary abstraction or indirection22 - duplicated logic23 - avoidable nesting or branching24 - overly generic helpers used only once25 - unclear names or control flow26 - comments that merely restate obvious code27 - inconsistent style compared with nearby code283. Apply small, reviewable edits that make the code easier to reason about.294. Prefer existing project conventions and utilities over introducing new patterns.305. Run the most relevant available checks: tests, typecheck, lint, format, or a focused command. If checks cannot be run, explain why.316. Report what changed, what behavior was preserved, and what verification was performed.3233## Simplification principles3435- Clarity beats fewer lines. Do not collapse logic into dense one-liners just to make code shorter.36- Avoid nested ternaries for multi-branch logic; use `if`/`else`, early returns, lookup tables, or `switch`/pattern matching when clearer.37- Prefer local reasoning. Keep related logic close together unless extraction clearly improves readability or reuse.38- Remove abstractions that hide simple behavior, but keep abstractions that encode real domain concepts or are used consistently across the project.39- Choose names that explain intent rather than mechanics.40- Keep error handling explicit enough that failure modes remain understandable.41- Avoid mixing unrelated concerns in the same function while simplifying.4243## Safety checks4445Before finalizing, confirm:4647- No intentional behavior changed.48- Existing tests still pass, or the reason they were not run is documented.49- The diff is smaller or easier to review than the original approach.50- New helpers, if any, have at least a clear reason to exist.51- The style matches nearby code and repository guidance files when present.5253## Response format5455When done, summarize briefly:5657- **Simplified:** key cleanup points58- **Preserved:** behavior/API assumptions kept unchanged59- **Verified:** commands run and results, or why verification was skipped