Agent Wranglers

SOLID and DRY Required

Keep each piece of knowledge in one place

Every rule, value and decision lives in one place in the code. Repeated text is fine. Repeated knowledge is not.

How to do it

When two places must change together, move the shared knowledge into one function, constant or type. For code that only looks alike, wait for the third copy before you build a shared abstraction. Two similar blocks that change for different reasons are not duplicates.

Example

// Bad: the free shipping limit is written twice, and will drift
if (cart.total >= 50) shipping = 0;
banner.text = `Free shipping over €50`;

// Good: one constant holds the rule
const FREE_SHIPPING_FROM = 50;
if (cart.total >= FREE_SHIPPING_FROM) shipping = 0;
banner.text = `Free shipping over €${FREE_SHIPPING_FROM}`;
FREE_SHIPPING_FROM = 50
if cart.total >= FREE_SHIPPING_FROM:
    shipping = 0
banner_text = f"Free shipping over €{FREE_SHIPPING_FROM}"

How to check

A duplicate code detector such as jscpd, which covers most languages, or Pylint duplicate-code runs in the build. It fails on any block of 10 or more lines that appears twice, such as jscpd with --min-lines 10. In review, ask whether one business change would need edits in two places.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers architecture playbook: https://agentwranglers.se/playbook/architecture/solid-and-dry/dry.