open-closed-principle

Installation
SKILL.md

Open/Closed Principle (OCP)

Overview

Software entities should be open for extension, but closed for modification.

When new functionality is needed, extend the system with new code rather than modifying existing code. If adding a feature requires changing existing if/else chains, you're violating OCP.

When to Use

  • Adding a new payment method, notification channel, export format, etc.
  • Tempted to add another if/else or switch case
  • Existing code works but needs new variants
  • Feature request: "add support for X"

The Iron Rule

NEVER add another branch to an existing if/else or switch statement.
Related skills
Installs
25
GitHub Stars
10
First Seen
Jan 22, 2026