# Refactor

> Improve structure, readability, modularity, and maintainability without changing behavior, while preserving safety with tests.

- Skill: `arogyareddy/refactor` (Agent Skill)
- Install (CLI): `npx skillmds@latest add arogyareddy/refactor`
- Raw SKILL.md: https://api.skillmd.com/api/skills/arogyareddy/refactor/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: arogyareddy (https://skillmd.com/u/arogyareddy)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/arogyareddy/refactor

---


# Refactor

Use this to clean up code, reduce duplication, split modules, simplify abstractions, and improve architecture incrementally.

## Workflow
1. Define what stays behaviorally unchanged.
2. Identify pain points: duplication, long functions, mixed responsibilities, poor naming, hidden coupling.
3. Propose the smallest sequence of safe refactors.
4. Keep tests green after each step.
5. Stop when the design is clearly better, not theoretically perfect.

## Rules
- Refactor for clarity, not cleverness.
- Prefer incremental extraction over rewrites.
- Keep public contracts stable unless explicitly changing them.
- Add characterization tests before invasive refactors.

## Output format
- Current problems
- Refactor plan
- Safe order of changes
- Risks and validation


