When writing or reviewing code to eliminate duplicated knowledge and business logic. Use when the user says "this is duplicated," "we have this in two places," "single source of truth," "DRY this up," or "shotgun surgery." For premature abstraction concerns, see yagni.
If .agents/stack-context.md exists, read it first. Apply this principle using idiomatic patterns for the detected stack. For framework-specific details, use context7 MCP or web search — don't guess.
Every piece of knowledge in a system should have a single, authoritative representation. When that knowledge changes, you should only need to change it in one place.
Duplicated logic is a ticking time bomb. When a business rule changes and you update it in one place but miss the copy in another, you get inconsistent behavior that's hard to detect and harder to debug. The more copies exist, the more likely one diverges silently.
DRY is not about eliminating similar-looking code. It's about eliminating duplicated knowledge — the same business rule, the same decision, the same source of truth expressed in multiple places.
-- Code looks similar but represents different concepts — DO NOT unify
def calculate_shipping_cost(weight, distance):
return weight * 0.5 + distance * 0.1
def calculate_insurance_premium(value, risk_factor):
return value * 0.5 + risk_factor * 0.1
-- These are different business rules that happen to share a formula today.
-- They will diverge. Keep them separate.
-- Same validation rule duplicated — UNIFY
// in signup handler
if len(password) < 8 or not has_uppercase(password):
return error("Password too weak")
// in password-reset handler
if len(new_password) < 8 or not has_uppercase(new_password):
return error("Password too weak")
-- Fix: single source of truth
def validate_password(password):
if len(password) < 8:
return error("Password must be at least 8 characters")
if not has_uppercase(password):
return error("Password must contain an uppercase letter")
return ok()
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer