code-architecture-wrong-abstraction

Guide developers to apply the Rule of Three before creating shared abstractions.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides developers on when to create shared abstractions versus duplicating code, preventing premature refactoring and complex, hard-to-maintain abstractions.

Core Features & Use Cases

  • Rule of Three: wait for at least 3 similar occurrences before abstracting.
  • Guided decision-making: criteria to determine whether a pattern is stable enough to extract.
  • Refactoring playbook: steps to revert a bad abstraction and re-align with correct structure.
  • Use Case: during a refactor of utility functions, repository-wide code duplication is evaluated and either preserved or extracted as a shared utility.

Quick Start

Review your codebase for repeated logic, apply the Rule of Three, inline later when patterns stabilize, and extract a proper abstraction only when the behavior is consistent across places.

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 extract duplicated code into a shared abstraction during refactoring?

Apply the Rule of Three during refactoring: wait for at least three similar occurrences of duplicated logic before extracting a shared abstraction, ensuring the pattern is stable and preventing premature design complexity.

How do I revert a wrong abstraction in my codebase?

To revert a wrong abstraction, follow a remediation workflow that inlines the abstracted logic back into its original modules, allowing independent patterns to stabilize before attempting a correct refactoring extraction.

What criteria determine if a code pattern is stable enough for abstraction?

Criteria for abstraction require evaluating whether behavior is consistent across all occurrences, verifying pattern stability, and ensuring the shared utility will not create complex, hard-to-maintain dependencies across modules.

Why does premature refactoring create hard-to-maintain code?

Premature refactoring creates hard-to-maintain code by forcing wrong abstractions, coupling unrelated modules through shared utilities, and complicating future modifications when the duplicated logic inevitably diverges.

Is code duplication acceptable in API design and shared utilities?

Code duplication is acceptable in API design and shared utilities until the Rule of Three is met, because preserving duplication initially prevents wrong abstractions and allows proper design patterns to emerge naturally.

How do I evaluate repository-wide code duplication for utility function refactoring?

Evaluate repository-wide code duplication by applying the Rule of Three, assessing behavior consistency across modules, and deciding whether to preserve the duplicate logic or extract it as a proper shared utility.