typescript-dry-principle

Analyze TypeScript codebases and refactor duplicated logic into shared utilities.

4|4|Updated Jan 15, 2026
One-click install
npx skills add https://github.com/darellchua2/opencode-config-template --skill typescript-dry-principle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-dry-principle
Source: https://github.com/darellchua2/opencode-config-template/tree/main/skills/typescript-dry-principle
Command: npx skills add https://github.com/darellchua2/opencode-config-template --skill typescript-dry-principle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill reduces the maintenance burden of TypeScript projects by applying the DRY principle to eliminate duplicated logic, types, and configuration across a codebase, improving consistency and long-term maintainability.

Core Features & Use Cases

  • Analyze Codebase: Detect duplication patterns across functions, types, and modules.
  • Refactor to Shared Utilities: Extract common logic into reusable utilities and modules.
  • Consolidate Types & Generics: Merge duplicate type definitions and promote generic components and APIs.
  • Organize Project Structure: Improve folder layout (types/, utils/, hooks/, services/) for long-term clarity.
  • Replace Duplicates with Imports: Update files to consume shared modules to reduce churn and bugs.

Quick Start

Start by scanning your TS project for repeated patterns, move common logic into a utilities module, and replace direct copies with imports.

Frequently Asked Questions about typescript-dry-principle

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

FAQPage Schema
How do I refactor TypeScript code to remove duplicated logic and types?

To apply the DRY principle in TypeScript, you identify duplicated logic and type definitions, then consolidate them into shared utilities, generic components, and a structured folder layout to reduce churn and bugs.

What is the best way to consolidate duplicate TypeScript type definitions?

The best way to consolidate duplicate TypeScript type definitions is to merge them into a centralized types directory and promote generic components and APIs, ensuring modularization and reducing maintenance burden across the project.

How do I organize my TypeScript project structure for better maintainability?

Organizing a TypeScript project structure for maintainability requires enforcing modularization by delivering a structured folder layout with dedicated directories like types/, utils/, hooks/, and services/ for reusable primitives.

When do I need to apply the DRY principle to a TypeScript codebase?

You need to apply the DRY principle to a TypeScript codebase when duplicated functions, types, and configurations increase the maintenance burden, causing code churn and consistency issues that degrade long-term maintainability.

Does refactoring TypeScript code with generics help reduce code duplication?

Refactoring TypeScript code with generics helps reduce duplication by promoting generic components and APIs, allowing you to replace direct copies with shared imports that enforce type safety and reusability.