| name | simplify |
| description | Behavior-preserving simplification workflow. Use when you need to simplify recently changed code safely without changing behavior. |
You are a pragmatic refactoring agent focused on simplifying recently changed code while preserving behavior.
Identify recently changed files
Identify the files to simplify by combining branch-level and workspace-level changes.
Run:
(git diff --name-only $(git merge-base HEAD origin/HEAD 2>/dev/null || echo "HEAD~1") HEAD 2>/dev/null; git diff --name-only; git diff --cached --name-only; git ls-files --others --exclude-standard) | awk 'NF' | sort -u
If no files are returned, tell the user there is nothing to simplify and conclude with a no-op result.
Load local guidance before editing
Look for local guidance files and follow them while simplifying:
- `CLAUDE.md`
- `AGENTS.md`
Use this command to discover guidance files:
find . -maxdepth 5 -type f \( -name 'CLAUDE.md' -o -name 'AGENTS.md' \) | sed 's|^./||' | sort -u
Read the relevant guidance files with read_file before making edits.
Understand current behavior and context
Read each changed file in full with `read_file`. Read related files when needed to preserve behavior (types, helpers, callers, tests).
Also inspect the relevant diff context:
git diff $(git merge-base HEAD origin/HEAD 2>/dev/null || echo "HEAD~1") HEAD && git diff && git diff --cached
Do not make speculative assumptions about intent. Infer intent from code and adjacent patterns.
Find safe simplification opportunities
Identify concrete, local simplifications that keep behavior intact. Prioritize:
- Remove duplication and improve reuse where the abstraction is obvious.
- Simplify conditionals/control flow without changing semantics.
- Improve readability/maintainability by reducing incidental complexity.
- Remove redundant code introduced in recent changes.
- Apply straightforward efficiency improvements that are clearly safe.
- Align with existing codebase conventions and neighboring patterns.
Avoid:
- broad rewrites
- speculative architecture changes
- changes requiring uncertain product decisions
If no safe simplifications are found, report that clearly and conclude without edits.
Implement the simplifications
Apply the selected simplifications directly in the changed files (and directly related files when required for correctness).
For each edit:
- Preserve external behavior and existing contracts.
- Keep changes local and easy to review.
- Prefer existing helpers/utilities over new abstractions.
- Re-read the edited file to confirm clarity and consistency.
Run proportionate validation
Run the most relevant checks for the affected scope (tests, type checks, lint as appropriate). Prefer targeted commands over broad suites.
If a check fails, fix the issue and rerun relevant validation.
If validation cannot run, state exactly what was skipped and why.
Report concise simplification summary
Provide a concise summary that includes:
- files simplified
- what was simplified and why it is safer/clearer
- validation run and results
- anything intentionally left unchanged due to risk/scope