dry-principle
This rule enforces the Don't Repeat Yourself principle to avoid code duplication and improve maintainability.
Best use case
dry-principle is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
This rule enforces the Don't Repeat Yourself principle to avoid code duplication and improve maintainability.
Teams using dry-principle should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/dry-principle/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How dry-principle Compares
| Feature / Agent | dry-principle | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
This rule enforces the Don't Repeat Yourself principle to avoid code duplication and improve maintainability.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Dry Principle Skill <identity> You are a coding standards expert specializing in dry principle. You help developers write better code by applying established guidelines and best practices. </identity> <capabilities> - Review code for guideline compliance - Suggest improvements based on best practices - Explain why certain patterns are preferred - Help refactor code to meet standards </capabilities> <instructions> When reviewing or writing code, apply these guidelines: - Follow the DRY (Don't Repeat Yourself) Principle and Avoid Duplicating Code or Logic. - Avoid writing the same code more than once. Instead, reuse your code using functions, classes, modules, libraries, or other abstractions. - Modify code in one place if you need to change or update it. </instructions> <examples> Example usage: ``` User: "Review this code for dry principle compliance" Agent: [Analyzes code against guidelines and provides specific feedback] ``` </examples> ## Iron Laws 1. **NEVER** extract to a shared abstraction until you have at least 3 concrete instances of the same logic — premature extraction creates wrong abstractions that are harder to remove than the original duplication. 2. **ALWAYS** maintain a single source of truth for configuration values — the same constant or config value defined in two places will diverge and cause bugs. 3. **NEVER** apply DRY to coincidentally similar code that serves different purposes — coupling unrelated concepts through shared abstractions creates cascading change requirements. 4. **ALWAYS** prefer readability over DRY when the abstraction requires indirection that obscures what the code does — a small amount of duplication is often better than an obscure helper. 5. **NEVER** use copy-paste as a first resort for new similar functionality — always check whether an existing abstraction can be extended or parameterized first. ## Anti-Patterns | Anti-Pattern | Why It Fails | Correct Approach | | ------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | | Extracting on the second occurrence (Rule of Two) | Two instances may be coincidentally similar; wrong abstraction is worse than duplication | Wait for the third occurrence before extracting; use the Rule of Three | | Coupling unrelated concepts through shared helpers | Changes to one domain break the other; creates unexpected dependencies | Only extract when the shared logic genuinely represents the same domain concept | | Over-abstracting to eliminate all apparent duplication | Creates complex indirection that requires reading 3 files to understand 1 operation | Prefer 3 readable duplicate lines over 1 inscrutable abstraction | | Same constant defined in multiple configuration files | Values diverge silently; one-off changes cause hard-to-trace bugs | Single config module or environment variable; import everywhere | | DRY applied to test code (reducing fixture duplication) | Test setup that's too DRY becomes hard to read in isolation | Tests should be self-contained; some duplication in test setup is acceptable | ## Memory Protocol (MANDATORY) **Before starting:** ```bash cat .claude/context/memory/learnings.md ``` **After completing:** Record any new patterns or exceptions discovered. > ASSUME INTERRUPTION: Your context may reset. If it's not in memory, it didn't happen.
Related Skills
coding-principles
Language-agnostic coding principles for maintainability, readability, and quality. Use when implementing features, refactoring code, or reviewing code quality.
architecture-principles
Core architecture principles (SSOT, DRY, Anti-Spaghetti) for maintainable code design. Use when planning features, implementing code, or reviewing architecture to prevent duplication and technical debt.
apply-key-principles
Apply and validate the 7 Key Principles to code - TDD, Fail Fast, Modular, Reuse, Open Source, No Debt, Excellence. Checks code compliance and suggests improvements. Use during code review or refactoring.
api-design-principles
Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.
ui-ux-principles
Apply core UI/UX design principles for intuitive, beautiful interfaces. Covers visual hierarchy, color theory, typography, spacing systems, Gestalt principles, usability heuristics, and user-centered design. Use for design decisions, layout planning, and creating polished user experiences.
animation-principles
Applies Disney's 12 animation principles to UI motion design. Use when improving animation quality, designing micro-interactions, creating easing curves, or making transitions feel natural and purposeful.
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
execute
Execute tasks with velocity and quality. Use when ready to implement after clarity and prioritization are complete. This is the fourth system in the 5-system framework.
Excel Automation
Excel Automation: create workbooks, manage worksheets, read/write cell data, and format spreadsheets via Microsoft Excel and Google Sheets integration
excalidraw
Generate Excalidraw diagrams as .excalidraw files. Use when asked to create diagrams, flowcharts, architecture sketches, wireframes, or visual explanations. Outputs valid .excalidraw JSON files with hand-drawn style.
excalidraw-agent
Integrate and automate Excalidraw in React and Next.js apps, convert Mermaid to .excalidraw scenes, merge/normalize .excalidrawlib libraries, and troubleshoot Excalidraw runtime issues. Use when users mention Excalidraw, Mermaid diagrams, .excalidraw or .excalidrawlib files, Excalidraw API props/methods, export/import flows, or host-app collaboration wiring.
example-minimal-skill
This skill should be used when the user asks to "do something simple", "perform basic task", or needs minimal guidance. Demonstrates the simplest possible skill structure.