agentleFS
5uck1ess5uck1ess/devkit/skills/dry/SKILL.md

dry

Skill4 starsChanged 4 months agoMITView on GitHub

Don't Repeat Yourself — Rule of Three, when duplication is fine, extracting the right abstraction.

5 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 7

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Don't abstract on the first duplication.

    line 10
  2. Distinctive:

    Not all duplication is bad.

    line 20
  3. Distinctive:

    The duplicated code serves different concerns: Test setup that looks similar to production code isn't "duplication" — they change for …

    line 22
  4. Distinctive:

    The cost of coupling exceeds the cost of duplication: If extracting a shared function means two unrelated modules now depend on each other, …

    line 23
  5. Distinctive:

    When you do extract, get the abstraction right:

    line 30
  6. Distinctive:

    Don't over-parameterize: If the shared function needs 8 config options to handle all cases, the cases are probably too different to share.

    line 34
  7. Distinctive:

    Keep it simple: If the abstraction is harder to understand than the duplication, the duplication was better.

    line 35

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

DRY (Don't Repeat Yourself)

The Rule of Three

Don't abstract on the first duplication. Wait for three instances.

  1. First time — Just write it.
  2. Second time — Notice the duplication, wince, keep going.
  3. Third time — Now extract. You have enough examples to see the real pattern.

Premature abstraction is worse than duplication. Wrong abstractions are expensive to undo.

When Duplication Is Fine

Not all duplication is bad. Duplication is acceptable when:

  • The duplicated code serves different concerns. Test setup that looks similar to production code isn't "duplication" — they change for different reasons.
  • The cost of coupling exceeds the cost of duplication. If extracting a shared function means two unrelated modules now depend on each other, keep them separate.
  • The "duplication" is coincidental. Two things look the same today but will evolve independently. Forcing them to share code creates a false coupling.

The test: if one copy changes, must the other change too? If yes, extract. If maybe not, leave it.

Extracting the Right Abstraction

When you do extract, get the abstraction right:

  • Name it for what it does, not where it came from. formatCurrency not extractedFromOrderPage.
  • Parameterize the differences. The parts that vary between call sites become parameters.
  • Don't over-parameterize. If the shared function needs 8 config options to handle all cases, the cases are probably too different to share.
  • Keep it simple. If the abstraction is harder to understand than the duplication, the duplication was better.

The Real DRY Principle

DRY is about knowledge, not code. The principle says every piece of knowledge should have a single authoritative source. Two functions with identical code but representing different business rules are not a DRY violation.

"Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." — Andy Hunt & Dave Thomas

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.