src/skills/dry-principle/SKILL.md
DRY (Don't Repeat Yourself) — Enforces the DRY principle by eliminating code duplication through abstraction, shared utilities, and single sources of truth. Use when writing, reviewing, or refactoring code that contains repeated logic, duplicated constants, copy-pasted blocks, or redundant data definitions in any language.
npx skillsauth add ngmthaq/my-copilot dry-principleInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
"Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." — Andy Hunt & Dave Thomas, The Pragmatic Programmer
Duplication is the root of many bugs: when logic lives in two places, they inevitably drift apart. DRY is not just about avoiding copy-paste — it's about single sources of truth.
Bad:
// In checkout flow
const tax = price * 0.08;
// In order summary
const tax = subtotal * 0.08;
// In invoice generator
const tax = amount * 0.08;
Good:
const TAX_RATE = 0.08;
function calculateTax(amount) {
return amount * TAX_RATE;
}
Bad:
# In create_user()
if len(password) < 8 or not re.search(r'[A-Z]', password):
raise ValueError("Invalid password")
# In reset_password()
if len(password) < 8 or not re.search(r'[A-Z]', password):
raise ValueError("Invalid password")
Good:
def validate_password(password: str) -> None:
if len(password) < 8 or not re.search(r'[A-Z]', password):
raise ValueError("Invalid password")
# Both callers use validate_password()
Bad:
// In API handler
type User = { id: string; email: string; role: string };
// In database layer
type UserRecord = { id: string; email: string; role: string };
// In tests
const mockUser = { id: "1", email: "[email protected]", role: "admin" };
Good:
// types/user.ts — single source of truth
export type User = { id: string; email: string; role: string };
// All layers import from here
Bad:
if user.trial_days > 14:
expire_account(user)
if signup_date + timedelta(days=14) < today:
send_expiry_warning(user)
Good:
TRIAL_PERIOD_DAYS = 14
if user.trial_days > TRIAL_PERIOD_DAYS:
expire_account(user)
if signup_date + timedelta(days=TRIAL_PERIOD_DAYS) < today:
send_expiry_warning(user)
Bad:
it("creates order", () => {
const user = { id: 1, name: "Alice", role: "customer" };
// ...
});
it("cancels order", () => {
const user = { id: 1, name: "Alice", role: "customer" };
// ...
});
Good:
const makeUser = (overrides = {}) => ({
id: 1, name: 'Alice', role: 'customer', ...overrides
});
it('creates order', () => { const user = makeUser(); ... });
it('cancels order', () => { const user = makeUser(); ... });
DRY does not mean "merge anything that looks similar." Two pieces of code that look the same but represent different concepts should stay separate. Premature abstraction is its own problem (see YAGNI).
Ask: "Would these two pieces of code always need to change together?"
[location]."documentation
Guidelines and protocols for Technical Leaders to manage and oversee technical projects effectively while adhering to the core mandate of being the central orchestration layer for all engineering work.
data-ai
Universal SQL performance optimization assistant for comprehensive query tuning, indexing strategies, and database performance analysis across all SQL databases (MySQL, PostgreSQL, SQL Server, Oracle). Provides execution plan analysis, pagination optimization, batch operations, and performance monitoring guidance.
development
SOLID — Enforces the SOLID principle of object-oriented design (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) for maintainable and scalable code.
development
Separation of Concerns (SoC) — Enforces the Separation of Concerns principle by ensuring each module, layer, and component addresses exactly one well-defined concern. Use when writing, reviewing, or refactoring code that mixes UI with business logic, business logic with data access, presentation with formatting, or cross-cutting concerns (auth, logging, validation) with core logic.