# Refactoring Patterns

> Measurement-driven code refactoring — profile before changing, measure after, keep only if metrics improve. Covers complexity reduction, extraction patterns, and bulk refactoring for mechanical changes across many files.

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

---


# Refactoring Patterns

Measure before. Refactor. Measure after. Keep only if it improved.

## When to Activate

- When the user says "refactor", "clean up", "simplify", "this code is messy"
- When code has high complexity, deep nesting, or large functions
- When extracting, renaming, or restructuring across multiple files
- When consolidating duplicated code

## Process

Read `skills/refactoring-process.md` for the measure-refactor-measure workflow, extraction patterns, and bulk refactoring mode.

## Behavioral Rules

Read `guidelines.md` for measurement requirements, revert criteria, and scope limits.

