Claude Skills
CollectionsCompareWorkflowsNominate
Sign inSign up
© 2026 Curated Agent Skills·Learn more about Agent Skills
Back to repository

refactoring-patterns

verified

This skill provides patterns for safe, systematic refactoring including extract, rename, move, and simplification operations with proper testing and rollback strategies.

View on GitHub

Marketplace

agent-skills-marketplace

jayteealao/agent-skills

Plugin

session-workflow

development

Repository

jayteealao/agent-skills

plugins/session-workflow/skills/refactoring-patterns/SKILL.md

Last Verified

February 1, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/jayteealao/agent-skills/blob/main/plugins/session-workflow/skills/refactoring-patterns/SKILL.md -a claude-code --skill refactoring-patterns

Installation paths:

Claude
.claude/skills/refactoring-patterns/
Powered by add-skill CLI

Instructions

# Refactoring Patterns Skill

Systematic refactoring with safety checks and verification.

## When to Use

- Extracting methods, classes, or modules
- Renaming identifiers safely across codebase
- Moving code between files or modules
- Simplifying complex code
- Modernizing legacy patterns

## Reference Documents

- [Extract Patterns](./references/extract-patterns.md) - Extract method/class/module patterns
- [Rename Patterns](./references/rename-patterns.md) - Safe renaming across codebase
- [Move Patterns](./references/move-patterns.md) - Moving code between files/modules
- [Simplify Patterns](./references/simplify-patterns.md) - Reducing complexity patterns

## Core Principles

### 1. Never Refactor Without Tests

```markdown
BEFORE refactoring:
1. Ensure tests exist for code being changed
2. Run tests to confirm they pass
3. Note coverage percentage

DURING refactoring:
4. Run tests after each small change
5. Keep changes atomic and reversible

AFTER refactoring:
6. Run full test suite
7. Verify coverage didn't decrease
```

### 2. Small, Incremental Changes

```
BAD:  One massive PR that changes everything
GOOD: Series of small PRs, each working state

Commit 1: Add new class
Commit 2: Add tests for new class
Commit 3: Migrate first usage
Commit 4: Migrate remaining usages
Commit 5: Remove old code
```

### 3. Preserve Behavior

Refactoring changes structure, not behavior.

```python
# BEFORE
def calculate_total(items):
    total = 0
    for item in items:
        total += item.price * item.quantity
    return total

# AFTER (same behavior, different structure)
def calculate_total(items):
    return sum(item.price * item.quantity for item in items)
```

## Refactoring Workflow

### Step 1: Identify the Smell

| Code Smell | Refactoring |
|------------|-------------|
| Long method | Extract Method |
| Large class | Extract Class |
| Duplicated code | Extract Method/Class |
| Long parameter list | Introduce Parameter Object |
| Data clumps | Extract Class |
| Prim

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
5462 chars