{"success":true,"name":"wait-for-the-third-repeat-before-building-an-abstraction","description":"Seeing two similar pieces of code and itching to unify them","category":"ai-brimind","path":"ai-brimind/wait-for-the-third-repeat-before-building-an-abstraction/SKILL.md","file":"SKILL.md","content":"---\nname: wait-for-the-third-repeat-before-building-an-abstraction\ndescription: \"Seeing two similar pieces of code and itching to unify them\"\n---\n\n# Wait for the Third Repeat Before Building an Abstraction\n\n## When to use\nYou noticed duplication or similarity and are about to build a shared helper, base class, or generic solution for it.\n\n## Example request\nTwo similar forms merged into one 'flexible' component → the third form doesn't fit and the component becomes an if-jungle; the abstraction was drawn too early. Copy-pasting twice, then the third case reveals the true pattern → now the shared piece is shaped by evidence; that is the Rule of Three. A generic 'handler for everything' built from one example → nobody understands it; wrong abstraction costs more than duplication.\n\n## Instructions\nAdopt the mindset of a mapmaker who waits to see where people actually walk before paving the path. When you spot duplication: (1) Count the real cases: with only two, you're guessing which parts are truly common and which are coincidence — similar-looking code with different reasons to change should NOT be merged. (2) Tolerate a little duplication until a third case appears; three points show the actual pattern, and the abstraction practically designs itself. (3) When you do unify, extract only what all cases genuinely share; if the shared piece needs flags and special-case ifs to serve its users, it's the wrong cut — back off. (4) Remember the asymmetry: duplication is annoying but cheap to fix later; a wrong abstraction spreads and is expensive to unwind. If unsure whether two things are 'the same', ask: would a change in one ALWAYS require the same change in the other? Only abstract once that's confirmed, and explain what the cases truly share and why this boundary will hold.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #277\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}