code-architecture-wrong-abstraction

Apply the rule of three to decide when to abstract or duplicate code.

Updated Apr 26, 2026
One-click install
npx skills add https://github.com/suwandre/my-opencode-config --skill code-architecture-wrong-abstraction-suwandre
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-architecture-wrong-abstraction
Source: https://github.com/suwandre/my-opencode-config/tree/main/skills/code-architecture-wrong-abstraction
Command: npx skills add https://github.com/suwandre/my-opencode-config --skill code-architecture-wrong-abstraction-suwandre

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Premature abstraction creates confusing, hard-to-maintain code. This skill guides when to abstract vs duplicate, reducing over-engineering and keeping code understandable.

Core Features & Use Cases

  • Provides the Rule of Three guideline to identify genuine patterns across at least three occurrences.
  • Reduces cognitive load by avoiding early abstractions and promoting simpler, maintainable code.
  • Supports safe refactoring workflows by inlining before extracting shared abstractions once patterns stabilize.

Quick Start

Identify repeated patterns across at least three places and only then consider extracting a shared abstraction once the pattern stabilizes.

Frequently Asked Questions about code-architecture-wrong-abstraction

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I abstract duplicated code instead of keeping it repeated?

Apply the rule of three for code abstraction: wait until a pattern appears at least three times across modules before extracting a shared abstraction, ensuring the pattern has stabilized to prevent over-engineering.

How do I stop premature abstraction from making my codebase hard to maintain?

Prevent premature abstraction by duplicating code initially and waiting for genuine patterns to emerge. Inline duplicated logic first, then extract shared abstractions only after the pattern stabilizes across multiple occurrences.

What is the rule of three in refactoring and design patterns?

The rule of three is a refactoring guideline dictating that you should only extract a shared abstraction after a code pattern repeats at least three times, reducing cognitive load and avoiding confusing, over-engineered code.

How do I safely refactor code to extract a shared abstraction?

Safely refactor by inlining the duplicated code first to observe the true pattern. Once the pattern stabilizes across at least three instances, extract the shared abstraction to ensure maintainable and understandable code.

Why does early code abstraction create maintenance problems?

Early code abstraction creates maintenance problems because it locks in assumptions before patterns stabilize, leading to confusing and hard-to-maintain code that requires complex changes when the duplicated logic diverges.

Should I use DRY principles for every duplicated code block I find?

Strictly applying DRY to every duplicated code block causes premature abstraction. Instead, tolerate duplication until the rule of three confirms a stable pattern, preventing over-engineering and reducing cognitive load.