SKILL.md
Refactor
Input
- A file, module, package, feature, diff, or project area to refactor.
- Use explicit input first; otherwise infer from context, recent edits, selected files, or branch.
- Safest default: ask before refactoring the whole project.
Workflow
- Confirm input. If no input is provided or implied, confirm before refactoring the entire project.
- Identify surface. Find files and direct dependencies that may need review or change.
- Run baseline checks. Use available tests, typecheck, lint, or build commands for the scope. Note missing or failing tooling.
- Identify refactors:
- Dead code: unused functions, branches, flags, adapters, and stale comments/docs. - Duplication: repeated logic, validation, mapping, and query patterns. - Unnecessary complexity: deep nesting, mixed responsibilities, ambiguous naming, and over-abstraction. - Evidence-backed optimization: hot loops, N+1 queries, repeated expensive work.
- Plan changes. Confirm when changes may affect behavior or remove intentional code.
- Apply safe changes incrementally. Prefer small, reviewable edits.
- Validate behavior:
- Re-run available baseline checks plus targeted tests for touched areas. - Ensure no accidental API, schema, or side-effect regressions.
Output
- Input reviewed
- Refactors applied
- Behavior preserved or intentionally changed
- Validation run
- Remaining risks or follow-up work
Guardrails
- Do not change behavior to satisfy style preferences alone.
- Do not remove intentional features without confirmation.
- Do not introduce broad rewrites when focused refactors solve the problem.
- Keep type boundaries strict; avoid loose typing unless narrowly justified.