# Refactor

> Improve structure and clarity without changing externally visible behavior.

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

---


# Refactor

## Objective
- Simplify and clarify code while keeping behavior identical.
- Reduce technical debt in-scope without altering APIs or outputs.

## When to use
- Behavior is correct but code quality is poor.
- There is approval to clean up without feature changes.

## Inputs
- User intent and acceptance for refactor scope.
- AGENTS.md, rules, and relevant code/tests.
- Existing tests to confirm behavior stability.

## Process
1) Identify pain points (duplication, naming, structure).
2) Plan minimal, safe refactors; avoid tangents.
3) Apply changes incrementally, keeping tests passing.
4) Verify behavior parity via tests or reasoning.
5) Note any residual debt deferred.

## Outputs
- Files changed and rationale.
- Confirmation of unchanged behavior.
- Tests run (or why not) to prove parity.

## Edge cases
- If behavior must change, switch to implement/optimize.
- Avoid large extractions without clear gain and approval.

