agentleFS
DobroslavRadosavljevicDobroslavRadosavljevic/cabrakan/.agents/skills/deduplicate/SKILL.md

deduplicate

Skill1 starsChanged 3 months agoMITView on GitHub

Deduplicates code by finding one single source of truth and sharing it across call sites. Works on a named target or the full first-party codebase. Collapses duplicated logic, types, schemas, constants, UI, and tests that represent the same knowledge—without inventing false abstractions. Use when the user says "deduplicate", "dedupe", "DRY this up", "remove duplication", "single source of truth", "extract shared", or asks to consolidate repeated code into one place.

The file

Show its rules and text

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈14

    Distinctive · estimate

    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:

    Single goal: remove duplicated knowledge by placing one canonical implementation and having every consumer use it.

    line 8
  2. Distinctive:

    Do not broaden into general cleanup, renaming, layout rewrites, or smell hunting.

    line 10
  3. Distinctive:

    Prefer a little intentional duplication over a wrong abstraction.

    line 16
  4. Distinctive:

    Keep edits reviewable: one duplication cluster (or tightly related cluster) per pass when the scope is large.

    line 18
  5. Distinctive:

    Targeted: only the named file, directory, module, feature, or duplication cluster.

    line 23
  6. Distinctive:

    Full codebase: search first-party code for duplication hotspots.

    line 24
  7. Distinctive:

    If the boundary is ambiguous and would change what gets edited, ask one focused scope question.

    line 26
  8. Distinctive:

    Test setup that encodes the same domain fixture

    line 37
  9. Distinctive:

    Prefer one clear export over a grab-bag file.

    line 52
  10. Distinctive:

    Delete the now-dead copies.

    line 60
  11. Distinctive:

    Update tests: assert through the shared source.

    line 61
  12. Distinctive:

    Do not leave “thin wrappers” that only re-export without adding meaning—unless a public boundary requires a stable facade.

    line 62
  13. Distinctive:

    Run the narrowest existing format / lint / typecheck / tests for touched surfaces.

    line 66
  14. Distinctive:

    If checks cannot run, say what was skipped and why.

    line 68

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “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

Deduplicate

Single goal: remove duplicated knowledge by placing one canonical implementation and having every consumer use it.

Do not broaden into general cleanup, renaming, layout rewrites, or smell hunting. If something is not duplication (or forced by a correct dedupe), leave it alone.

Core Rules

  • Preserve behavior, public APIs, and data formats unless the user authorizes a change.
  • Deduplicate knowledge that will drift, not coincidental structural similarity.
  • Prefer a little intentional duplication over a wrong abstraction. Extract only when the copies share one stable concept, name, and change reason.
  • Reuse an existing home for the concept when one exists. Do not invent a competing utils / helpers / shared dump.
  • Keep edits reviewable: one duplication cluster (or tightly related cluster) per pass when the scope is large.
  • Preserve unrelated user changes.

Establish Scope

  • Targeted: only the named file, directory, module, feature, or duplication cluster. Follow references outside the target for understanding; change them only when required to wire the shared source.
  • Full codebase: search first-party code for duplication hotspots. Exclude generated files, vendored code, build output, caches, lockfiles, snapshots, and migrations unless they are the stated problem.

If the boundary is ambiguous and would change what gets edited, ask one focused scope question. Otherwise state the inferred boundary and proceed.

Workflow

1. Map candidates

Search for repeated:

  • Logic / algorithms / validation / mapping
  • Types, interfaces, schemas, constants, enums, config
  • UI fragments that express the same product concept
  • Test setup that encodes the same domain fixture

Record each cluster with: locations, what knowledge is duplicated, confidence, and proposed canonical home.

Skip clusters that are only similar shape with different meaning, or that will diverge for good reasons. Details: when-not-to.md.

2. Choose the single source of truth

For each accepted cluster, pick one home using ssot-placement.md.

Decision order:

  1. Does an existing module already own this concept? Prefer it.
  2. Else, place it at the narrowest owner that all consumers share (feature → package → workspace package).
  3. Name it for the concept, not for “shared helper.”
  4. Prefer one clear export over a grab-bag file.

State the chosen path and why before (or as you) extract.

3. Extract and rewire

  1. Move or create the canonical implementation in the chosen home.
  2. Replace every duplicate with an import / composition of that source.
  3. Delete the now-dead copies.
  4. Update tests: assert through the shared source; keep only consumer-specific coverage local.
  5. Do not leave “thin wrappers” that only re-export without adding meaning—unless a public boundary requires a stable facade.

4. Verify

Run the narrowest existing format / lint / typecheck / tests for touched surfaces. Expand only when the shared module sits on a cross-cutting boundary.

If checks cannot run, say what was skipped and why.

Completion Report

Keep it short:

  • Scope inspected
  • Clusters deduplicated: concept → canonical path → former locations
  • Clusters left alone (with reason: intentional divergence, false similarity, out of scope, low confidence)
  • Verification run and results

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.