code-architecture-wrong-abstraction

Identify when to abstract versus duplicate code across multi-file codebases.

1|Updated Mar 20, 2026
One-click install
npx skills add https://github.com/Thomashighbaugh/opencode --skill code-architecture-wrong-abstraction-thomashighbaugh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-architecture-wrong-abstraction
Source: https://github.com/Thomashighbaugh/opencode/tree/main/skills/code-architecture-wrong-abstraction
Command: npx skills add https://github.com/Thomashighbaugh/opencode --skill code-architecture-wrong-abstraction-thomashighbaugh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Premature or wrong abstractions clutter codebases, create maintenance headaches, and slow teams. This skill guides when duplication is preferable to abstraction until patterns emerge, reducing confusion and rework.

Core Features & Use Cases

  • Rule of Three: Wait for 3+ occurrences before abstracting.
  • Pattern stabilization: Ensure requirements are clear and stable before generalizing.
  • Refactoring guidance: Inline or extract abstractions safely when warranted.

Use Case: When you see the same logic in three places across modules, determine whether to refactor or postpone abstraction.

Quick Start

Identify three similar code blocks across different files and determine whether abstraction improves clarity after confirming stable, identical behavior.

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 inline?

Apply the rule-of-three to abstract duplicated code only after three or more occurrences appear and pattern stability is confirmed. This prevents premature abstractions that clutter codebases and create maintenance headaches.

How does the rule of three work for code refactoring?

The rule of three for code refactoring means waiting until identical logic appears in at least three separate locations before extracting a shared abstraction. This validates pattern stability and prevents wrong generalizations across modules.

What is the best way to refactor duplicated logic across multiple files?

The best way to refactor duplicated logic across multiple files is to verify three similar code blocks share stable, identical behavior, then safely extract the abstraction using clear inline-to-extract guidance to prevent over-generalization.

Why does following DRY principles sometimes cause maintenance headaches?

Following DRY principles causes maintenance headaches when it forces premature abstractions before patterns stabilize. Wrong generalizations couple unrelated modules, making future changes significantly harder than allowing controlled duplication.

When should I not use abstraction in my codebase?

You should not use abstraction in your codebase when similar code appears fewer than three times or when the pattern's requirements are still changing. Postponing abstraction avoids over-generalization and reduces confusing rework.