Skip to content
Back to skills

Code Refactoring Dry

ASecurity

Remove code duplication by extracting shared logic into reusable components. Use when the same logic appears in multiple places.

  • 666 stars
  • 0 votes
  • 3 copies
  • 10 views
  • Added February 8, 2026
developmentgotestingrefactoring

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill code-refactoring-dry --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Code Refactoring Dry?

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

Security grade badge for Code Refactoring Dry
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-code-refactoring-dry/badge)](https://www.skillsdirectory.com/skills/majiayu000-code-refactoring-dry)

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: code-refactoring-dry
description: Remove code duplication by extracting shared logic into reusable components. Use when the same logic appears in multiple places.
---

# Code Refactoring: Don't Repeat Yourself

Remove code duplication you just introduced by refactoring duplicated code to follow the DRY principle.

## When to Use This Skill

Use this skill when:
- You notice the same logic appearing in multiple places
- Code has been copied and pasted with minor variations
- A change needs to be made in multiple locations
- Following the "NO DUPLICATED CODE!" rule from code review

## Instructions

### Step 1: Identify the Duplication

Review your recent changes (committed or uncommitted) to find:
- Duplicated code patterns
- Duplicated logic or structures
- Copied and pasted blocks with minor variations

### Step 2: Clarify Scope (If Needed)

If the duplication is not obvious, ask the user to clarify which specific
duplication they want addressed before proceeding.

### Step 3: Refactor

Once the duplication is identified:
- Extract shared logic into reusable functions, classes, or modules
- Replace duplicated code with calls to the shared implementation
- Ensure the refactoring maintains the same functionality
- Update all call sites to use the new shared implementation

### Step 4: Verify

After refactoring:
- Run tests if available
- Verify the code still works as expected
- Check that the solution is cleaner and more maintainable

## Goal

Eliminate unnecessary duplication while maintaining code clarity and
functionality. The refactored code should be easier to maintain and modify
in the future.

## Benefits of DRY

- **Single source of truth**: Changes only need to be made in one place
- **Easier maintenance**: Bug fixes propagate automatically
- **Reduced risk**: Consistency is enforced
- **Better testing**: Test shared logic once

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.

Comments

Loading comments…

Newsletter

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