---
title: "Keep each piece of knowledge in one place · Agent Wranglers"
url: https://agentwranglers.se/playbook/architecture/solid-and-dry/dry
updated: 2026-10-20
licence: "All rights reserved"
---

# Keep each piece of knowledge in one place

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [SOLID and DRY](https://agentwranglers.se/playbook/architecture/solid-and-dry)
- Rule: Every rule, value and decision lives in one place in the code. Repeated text is fine. Repeated knowledge is not.
- How: 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.
- 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.

Example:

```js
// 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}`;
```

```python
FREE_SHIPPING_FROM = 50
if cart.total >= FREE_SHIPPING_FROM:
    shipping = 0
banner_text = f"Free shipping over €{FREE_SHIPPING_FROM}"
```

**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`.

- Next: [Give each module one reason to change](https://agentwranglers.se/playbook/architecture/solid-and-dry/single-responsibility)
- [SOLID and DRY](https://agentwranglers.se/playbook/architecture/solid-and-dry)
