dry-refactoring

Apply a four-step DRY workflow to eliminate code duplication.

274|28|Updated Oct 31, 2025
One-click install
npx skills add https://github.com/YYH211/Claude-meta-skill --skill dry-refactoring
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dry-refactoring
Source: https://github.com/YYH211/Claude-meta-skill/tree/main/dry-refactoring
Command: npx skills add https://github.com/YYH211/Claude-meta-skill --skill dry-refactoring

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Guides systematic code refactoring following the DRY (Don't Repeat Yourself) principle. Use when user asks to eliminate code duplication, refactor repetitive code, apply DRY principle, or mentions code smells like copy-paste, magic numbers, or repeated logic. Implements a 4-step workflow from identifying repetition to verified refactoring.

Core Features & Use Cases

  • Identify Repetition: Detect obvious and semantic duplicates, magic numbers, and structural repetition.
  • Abstract Logic: Encapsulate common behavior into functions, classes, or modules.
  • Implement Reusable Units: Create reusable components or utilities.
  • Verification & Validation: Confirm refactor correctness with tests.

Quick Start

Apply the four-step DRY workflow to a duplicated function example: identify duplication, extract common logic, replace duplicates with a single call, run tests to verify.

Frequently Asked Questions about dry-refactoring

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I eliminate code duplication in my codebase?

Code duplication elimination follows a structured DRY workflow: identify repeated logic or patterns, abstract common behavior into reusable functions or classes, replace duplicates with single calls, and verify correctness with tests. This systematic approach ensures safe, incremental refactoring.

What counts as code duplication I should refactor?

Common duplication patterns include copy-paste code blocks, repeated logic across functions, magic numbers used identically, structural repetition in similar modules, and semantic duplicates that perform the same operation differently. The DRY workflow helps detect and eliminate all these forms.

How do I safely refactor duplicated code without breaking functionality?

The four-step DRY workflow ensures safety: identify duplication precisely, extract common logic incrementally, implement reusable units that replace all duplicates, then run tests to verify the refactored code behaves identically. Tests confirm correctness throughout the process.

Can I refactor code smells like magic numbers and repeated patterns together?

Yes, the DRY workflow handles multiple code smell types—copy-paste patterns, magic numbers, and repeated logic—within a single refactoring pass. Abstracting common behavior eliminates these smells simultaneously while improving maintainability.

What's the best way to approach refactoring large codebases with scattered duplication?

Use incremental refactoring: apply the four-step DRY workflow to isolated, high-impact duplications first, verify each refactor with tests, then expand systematically. This reduces risk and maintains verifiable correctness across your codebase.