dry_skill

This skill helps you identify and extract duplicate logic to enforce a single source of truth across codebases, reducing bugs and maintenance.
  • TypeScript

6

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill yanko-belov/code-craft --skill dry

  • SKILL.md5.3 KB

Overview

This skill helps developers eliminate duplicated logic across a TypeScript codebase by identifying repetition and guiding extraction into single, reusable units. It enforces the principle that each piece of knowledge or behavior should have one canonical representation. Use it to reduce maintenance cost, prevent divergence, and make fixes safer and faster.

How this skill works

The skill inspects code patterns that indicate copy-paste or repeated logic: identical functions, repeated regexes/validation, constants duplicated across files, and similar functions that differ only by small details. It recommends extracting shared functions, parameterizing differences, centralizing constants, or creating interfaces/base classes so the common behavior lives in one location and is reused everywhere.

When to use it

  • You catch yourself copying and pasting code to handle a similar case
  • Making the same bug fix or change in multiple files
  • You see the same validation, regex, or calculation repeated
  • Adding a new feature that duplicates existing logic
  • Multiple functions share most of their body but differ in small ways

Best practices

  • Extract the common behavior first, then reuse it in all callers
  • Parameterize differences rather than duplicating whole functions
  • Centralize constants and business rules in a single module
  • Name extracted functions or modules clearly to improve readability
  • Refactor small duplications immediately—tiny copies multiply

Example use cases

  • Replace two email validators with a single validateEmail(email: string) function and reuse it across forms
  • Move tax or pricing logic into calculateTax(price: number) and import it from cart, checkout, and invoice modules
  • Extract shared formatting logic into formatName(person, suffix?) instead of separate formatUserName and formatAdminName
  • Create a validators module when identical validation patterns appear across multiple components
  • Centralize shared constants (TAX_RATE, API_ENDPOINTS) to avoid inconsistent values

FAQ

Extract the shared part and add parameters or strategy callbacks for differences so one implementation covers all cases.

Is extracting always worth it for a few lines?

Yes. Small duplications often appear many times; extracting once prevents many future edits and reduces divergence.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational