code-architecture-wrong-abstraction

Guide software design decisions between code duplication and abstraction using the Rule of Three.

Updated Nov 28, 2025
One-click install
npx skills add https://github.com/davidsteinberger/dotfiles --skill code-architecture-wrong-abstraction-davidsteinberger
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: code-architecture-wrong-abstraction
Source: https://github.com/davidsteinberger/dotfiles/tree/main/opencode/.config/opencode/skills/code-architecture-wrong-abstraction
Command: npx skills add https://github.com/davidsteinberger/dotfiles --skill code-architecture-wrong-abstraction-davidsteinberger

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers make better decisions about when to abstract code versus when to duplicate it, preventing the creation of overly complex and hard-to-maintain codebases due to premature or incorrect abstractions.

Core Features & Use Cases

  • Guidance on Abstraction: Provides clear rules and principles for deciding when to abstract code, emphasizing the "Rule of Three" and the dangers of hasty abstractions.
  • Identifying Wrong Abstractions: Illustrates common patterns of how wrong abstractions evolve and offers strategies for fixing them by inlining and re-extracting.
  • Facade Pattern Analysis: Explains the appropriate use and pitfalls of the Facade pattern, particularly in UI components.
  • Use Case: When refactoring a codebase, you encounter a piece of logic that appears in two places. This Skill guides you to wait for a third occurrence before considering an abstraction, thus avoiding a potentially wrong abstraction.

Quick Start

Use the code-architecture-wrong-abstraction skill to understand when to abstract code versus when to duplicate it.

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 use DRY vs WET code duplication to avoid wrong abstractions?

To avoid wrong abstractions, prefer WET code duplication until the Rule of Three is met, waiting for a third occurrence before refactoring into a DRY abstraction to ensure structural alignment.

How do I refactor a wrong abstraction in my codebase?

Refactor a wrong abstraction by inlining the abstracted logic back into its callers and re-extracting it only when a clear, shared pattern emerges, optimizing for future changeability.

What is premature abstraction and why does it make software design harder?

Premature abstraction occurs when developers unify duplicated code too early, creating rigid structures that misalign with actual requirements and complicate future software design changes.

When should I use the Facade pattern for UI components?

Use the Facade pattern in UI components to simplify complex subsystems, but analyze its application carefully to avoid hiding essential logic and creating an unnecessary abstraction layer.

Does the Rule of Three apply to all software design refactoring?

The Rule of Three guides refactoring by suggesting you wait for three separate instances of code duplication before creating an abstraction, preventing complex and incorrect generalizations.