code-architecture-wrong-abstraction

Identify premature abstractions and apply the Rule of Three to refactoring decisions.

8|Updated Sep 7, 2021
One-click install
npx skills add https://github.com/frap129/dotfiles --skill code-architecture-wrong-abstraction-frap129
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-architecture-wrong-abstraction
Source: https://github.com/frap129/dotfiles/tree/main/.config/opencode/skills/code-architecture-wrong-abstraction
Command: npx skills add https://github.com/frap129/dotfiles --skill code-architecture-wrong-abstraction-frap129

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Guides when to abstract vs duplicate code, helping teams avoid premature abstractions and confusing refactorings by waiting for genuine patterns to emerge.

Core Features & Use Cases

  • Rule of Three: Do not abstract until code appears in at least three places.
  • Context-aware refinement: Evaluate stability and identical behavior before extracting shared utilities.
  • Refactoring guidance: Reintroduce inline solutions when patterns are unclear to preserve clarity.
  • Real-world scenarios include library design, utility extraction, and architecture decisions.

Quick Start

Review a codebase segment and decide whether to abstract or keep duplicating based on the Rule of Three.

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?

Avoid premature abstraction by waiting until duplicated code appears in at least three places. Applying the Rule of Three ensures genuine patterns have emerged, preserving clarity and preventing confusing refactorings.

What is the Rule of Three in software design and refactoring?

The Rule of Three is a software design principle dictating that you should not abstract code until it appears in at least three places. This criteria ensures stability and identical behavior before extracting shared utilities.

How do I evaluate if a code pattern is stable enough for extracting shared utilities?

Evaluate stability and verify identical behavior across all similar code blocks before extracting shared utilities. If patterns remain unclear, reintroduce inline solutions to preserve clarity and avoid premature abstraction.

Why does premature abstraction cause problems in code architecture?

Premature abstraction causes problems by creating confusing refactorings based on assumed patterns rather than actual usage. Waiting for genuine patterns to emerge preserves clarity and guides safe, incremental abstraction decisions.

Should I follow DRY principles when I only have two similar code blocks?

Following DRY principles with only two similar code blocks risks premature abstraction. You should wait until three similar blocks exist and demonstrate stability and identical behavior before creating shared utilities.

How do I revert a confusing shared utility back to inline code?

Revert a confusing shared utility by reintroducing inline solutions when patterns are unclear. This refactoring guidance preserves clarity by eliminating premature abstractions that lack stable, identical behavior across contexts.