dont-repeat-yourself

Identifies duplicated code, logic, and data, providing extraction and parameterization strategies for refactoring.

Updated Sep 9, 2024
One-click install
npx skills add https://github.com/anyulled/my-portfolio-website --skill dont-repeat-yourself-anyulled
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dont-repeat-yourself
Source: https://github.com/anyulled/my-portfolio-website/tree/main/.agent/skills/dont-repeat-yourself
Command: npx skills add https://github.com/anyulled/my-portfolio-website --skill dont-repeat-yourself-anyulled

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers avoid writing and maintaining the same code in multiple places, which is a common source of bugs and increased development time.

Core Features & Use Cases

  • Code Duplication Detection: Identifies instances where the same logic or code snippets are repeated.
  • Refactoring Guidance: Provides strategies and patterns for extracting and parameterizing duplicated code.
  • Use Case: When you find yourself copying and pasting a block of code to make a minor change in another file, this Skill guides you to extract that block into a reusable function.

Quick Start

Use the dont-repeat-yourself skill to refactor duplicated validation logic in the codebase.

Frequently Asked Questions about dont-repeat-yourself

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

FAQPage Schema
How do I identify and eliminate code duplication in my software?

Refactoring duplicated code involves extracting repeated blocks into parameterized, reusable functions. This centralizes logic, reduces maintenance overhead, and ensures changes only need to be made in a single location.

What is the DRY principle in software development?

The DRY principle in software development is the practice of centralizing knowledge to eliminate the repetition of code, logic, and data. It aims to reduce maintenance overhead and prevent bugs caused by updating duplicated logic in multiple places.

When do I need to refactor duplicated validation logic?

You need to refactor duplicated validation logic when you find yourself copying and pasting code blocks to make minor changes across files. Extracting this logic into a reusable function prevents inconsistencies and simplifies future updates.

What's the best way to handle developer rationalizations for keeping duplicated code?

The best way to handle developer rationalizations for keeping duplicated code is to apply a structured refactoring protocol. This provides pressure resistance during development by offering clear strategies to extract and parameterize repeated code blocks.

What types of duplication does the DRY principle address?

The DRY principle addresses code, logic, data, and structural duplication. Identifying these different forms of repetition allows developers to apply targeted refactoring patterns and fully centralize software knowledge.