Skip to content
Back to skills

Refactoring Catalog

ASecurity

Select behavior-preserving refactorings for demonstrated code smells and give an ordered verification plan. Use when deciding how to improve existing code safely.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 19, 2026
ai-agentskotlinrefactoring

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned November 19, 2026

npx -y skills add ch4570/vulpora --skill refactoring-catalog --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Refactoring Catalog?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Refactoring Catalog
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ch4570-refactoring-catalog/badge)](https://www.skillsdirectory.com/skills/ch4570-refactoring-catalog)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: refactoring-catalog
description: Select behavior-preserving refactorings for demonstrated code smells and give an ordered verification plan. Use when deciding how to improve existing code safely.
---

# Refactoring Catalog

A skill that improves structure through **smell → prescription → small steps** by applying
Martin Fowler's *Refactoring* (2nd ed.) catalog + a code-smell taxonomy + Clean Code heuristics.
For grounding facts see this skill's `reference/kb/` (smell taxonomy, function/class refactorings,
conditionals/polymorphism, encapsulation moves, etc.); for higher-level principles see
`reference/principles.md`. The index is `reference/kb/INDEX.md`
(if you can't find the path, Glob for `principles.md`/`INDEX.md` from the bundle root).

## Application order (proceed exactly like this)

1. **Confirm the safety net** — grep for the target's regression tests. If absent, **write a characterization test first** (without one, cap a large change at MEDIUM).
2. **Smell scan** — identify smells with the review hooks in `reference/kb/code-smells.md` and route through `reference/kb/INDEX.md`.
3. **Catalog mapping** — prescribe a **named refactoring** for each smell (table below).
4. **Design small steps** — split the prescription into behavior-preserving units and compile/test after each step.
5. **Report** — Before/After + applied steps + verification commands. Prioritize by value÷risk.

## Smell → refactoring quick table

| Smell | Prescription (catalog) |
|---|---|
| Duplicated code | Extract Function / Pull Up Method |
| Long function | Extract Function, Replace Temp with Query, Decompose Conditional |
| Long parameter list | Introduce Parameter Object, Preserve Whole Object |
| Large class (multiple responsibilities) | Extract Class |
| Feature Envy | Move Function / Move Field |
| Primitive obsession / data clumps | Replace Primitive with Object (Value Object) |
| Repeated branching (`when`/`if` ladder) | Replace Conditional with Polymorphism (sealed/strategy) |
| Nested conditionals | Replace Nested Conditional with Guard Clauses (early return) |
| Shotgun surgery / divergent change | Cohere via Move, Extract Class per responsibility |

## Rules when prescribing
- Always cite the **source** (Fowler catalog name / Effective Kotlin item).
- **Do not change behavior** — if a feature change/bug fix is mixed in, separate it and report it apart.
- No over-engineering (KISS/YAGNI) — abstract only when duplication actually exists.

## Example (Replace Conditional with Polymorphism)
```kotlin
// Before — type branching repeated across multiple methods
fun fee(type: PaymentType): Int = when (type) {
    PaymentType.CARD -> 100; PaymentType.BANK -> 200
}
// After — sealed + polymorphism (adding a new type is the extension, OCP)
sealed interface Payment { fun fee(): Int }
data object Card : Payment { override fun fee() = 100 }
data object Bank : Payment { override fun fee() = 200 }
```
Application steps: ① model the sealed hierarchy → ② Move each branch body (test per case) → ③ replace call sites with the polymorphic call.

Files in this skill

  • SKILL.md3 KB
  • reference/kb/INDEX.md3.1 KB
  • reference/kb/code-smells.md4.7 KB
  • reference/kb/composing-methods.md4.7 KB
  • reference/kb/moving-features.md3.8 KB
  • reference/kb/organizing-data.md4.1 KB
  • reference/kb/refactoring-safety.md3.9 KB
  • reference/kb/simplifying-conditionals.md3.9 KB
  • reference/principles.md4.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.