convention-solid-ocp

Enforce the Open/Closed Principle by adding new classes instead of modifying existing code.

Updated Mar 19, 2026
One-click install
npx skills add https://github.com/sunLeee/optimization --skill convention-solid-ocp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: convention-solid-ocp
Source: https://github.com/sunLeee/optimization/tree/main/.claude/skills/reference/philosophy/solid/ocp
Command: npx skills add https://github.com/sunLeee/optimization --skill convention-solid-ocp

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

The Open/Closed Principle (OCP) advocates designing software so that existing code remains stable while new features are added through extension rather than modification.

Core Features & Use Cases

  • Encourages designing abstractions and extension points to accommodate new requirements without touching existing code.
  • Applies to library APIs, plugins, and modular architectures to reduce regression risk and simplify testing.
  • Use Case: When adding a new feature, implement a new concrete class or strategy that conforms to an existing interface instead of altering existing implementations.

Quick Start

Introduce an abstract interface for a feature, create concrete extension classes, and wire them through a factory or dependency injection to enable new behavior without changing existing code.

Frequently Asked Questions about convention-solid-ocp

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the open closed principle in software architecture?

The open closed principle keeps software extensible by allowing new features to be added through new classes rather than modifying existing code. This approach reduces regression risk and simplifies testing across modular architectures.

How do I add new features to a library without modifying existing code?

To add new features without modifying existing code, introduce an abstract interface and create concrete extension classes. Wire them through a factory or dependency injection to enable new behavior while keeping existing implementations stable.

When do I need abstractions and extension points for software design?

You need abstractions and extension points when scaling software across teams and adding new features with minimal risk. This is essential for designing library APIs, plugins, and modular architectures to prevent regressions in existing behavior.

Does the open closed principle reduce regression risk for modular architectures?

Yes, the open closed principle reduces regression risk by enforcing that new functionality is added via new concrete implementations conforming to existing interfaces. This ensures existing code remains stable and untouched during feature expansion.

What is the best way to implement extensibility for library APIs and plugins?

The best way to implement extensibility is by defining abstract interfaces for features and creating concrete extension classes. This strategy allows plugins and library APIs to accommodate new requirements without altering existing implementations.

When should I not use the open closed principle for software design?

You should not use the open closed principle when adding simple features that do not require abstraction or when the overhead of introducing interfaces and concrete implementations outweighs the benefit of keeping existing code untouched.