dry-principle

Detect duplicated logic across three or more code locations and propose extraction plans.

Updated Apr 14, 2026
One-click install
npx skills add https://github.com/BrunoAMSilva/my-config --skill dry-principle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dry-principle
Source: https://github.com/BrunoAMSilva/my-config/tree/main/coding/skills/dry-principle
Command: npx skills add https://github.com/BrunoAMSilva/my-config --skill dry-principle

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Reduce maintenance overhead and bugs caused by duplicated domain knowledge and scattered configuration by guiding when and how to extract shared code and data definitions into single sources of truth.

Core Features & Use Cases

  • Rule of Three trigger: extract logic after it appears in three or more places to avoid premature abstraction.
  • Centralize configuration: move endpoints, constants, and auth settings to a single config module.
  • Consolidate shared types: define TypeScript interfaces and domain types once and import them everywhere.
  • Extract repeated UI/fetch patterns: convert repeated component logic into custom hooks or utilities.
  • Decision tree & edge cases: includes guidance to avoid merging code that looks similar but represents different concepts, and when duplication is acceptable (tests, single-use cases).
  • Real-world example: extract a validateEmail utility used across registration, login, and profile forms into a shared utils/validation module.

Quick Start

Identify code or configuration repeated in three or more places and propose a safe extraction plan that centralizes the logic as a shared utility, type, or config module.

Frequently Asked Questions about dry-principle

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

FAQPage Schema
How do I eliminate duplicated logic and repeated configuration values in my TypeScript codebase?

You can centralize configuration by moving endpoints, constants, and auth settings into a single config module. This centralization eliminates scattered configuration values and reduces maintenance overhead across frontend and backend environments.

When should I extract duplicated code to avoid premature abstraction?

You should extract duplicated code when the same validation, fetch patterns, or configuration appear in three or more places. Following the Rule of Three trigger prevents premature abstraction by ensuring logic is only centralized after duplication is proven.

How do I consolidate shared TypeScript interfaces used across multiple forms?

You should avoid merging code that looks similar but represents different domain concepts. The decision tree provides guidance on when duplication is acceptable, such as for tests or single-use cases, preventing incorrect abstraction of divergent semantics.

Can I use this refactoring approach for both frontend and backend situations?

Yes, you can use this refactoring approach for both frontend and backend situations where the same validation, types, or state patterns appear repeatedly. It provides concrete extraction recommendations to centralize logic regardless of the specific environment.