# Refactoring

> Safe refactoring steps

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

---


# Safe Refactoring

Improve structure without changing behavior.

## Preconditions

- [ ] Tests exist and pass
- [ ] Coverage >= 80%
- [ ] Understand current behavior

## Step 1: Identify

- Find code smell
- Document why change needed
- Estimate impact

## Step 2: Test Coverage

- Add tests for behavior to preserve
- Run tests - must pass before refactor

## Step 3: Refactor

- Make smallest possible change
- Run tests after each change
- Commit when tests pass

## Step 4: Verify

- Full test suite passes
- No new lint errors
- Performance not degraded

## Common Refactors

- Extract function
- Rename for clarity
- Remove duplication
- Simplify conditionals
- Introduce abstraction

## Anti-Patterns

- Never refactor without tests
- Never mix refactor with feature
- Never skip running tests

