Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Solid Principles

ASecurity

Write maintainable object-oriented code by following five design principles - Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion

22 stars
0 votes
0 copies
0 views
Added 9/20/2026
code-qualitygosqltestingrefactoringdatabase

Works with

cli

Security Analysis

A100/100

Scanned 9/20/2026

Install to Claude Code

$npx -y skills add lev-os/agents --skill solid-principles --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Solid Principles?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Solid Principles
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lev-os-solid-principles/badge)](https://www.skillsdirectory.com/skills/lev-os-solid-principles)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: solid-principles
description: Write maintainable object-oriented code by following five design principles - Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion
---

# SOLID Principles

## Overview

SOLID is a mnemonic for five foundational object-oriented design principles introduced by Robert C. Martin (Uncle Bob) in 2000, with the acronym coined by Michael Feathers. These principles make source code more understandable, flexible, and maintainable by reducing dependencies and coupling. Uncle Bob, author of Clean Code and Clean Architecture, emphasized that SOLID enables engineers to change one area of software without impacting others - the essence of modularity.

The five principles form a comprehensive framework: Single Responsibility (one reason to change), Open-Closed (extend without modifying), Liskov Substitution (subtype replaceability), Interface Segregation (no forced dependencies), and Dependency Inversion (depend on abstractions). Together, they guide developers toward designs that accommodate change gracefully rather than becoming brittle over time.

## When to Use

- Designing class structures and module boundaries in object-oriented systems
- Refactoring legacy code with tight coupling and unclear responsibilities
- Code reviews to evaluate design quality and maintainability
- Preventing "shotgun surgery" where one change requires modifying many classes
- Building systems expected to evolve over years with changing requirements
- Teaching object-oriented design principles to teams
- Diagnosing why code is difficult to test, extend, or understand

## The Process

### Step 1: Single Responsibility Principle (SRP) - One Reason to Change

Each class should have only one responsibility - one reason to change. If a class has multiple responsibilities, changes to one responsibility affect the others.

**Ask:** "What is this class's single job? Does it have more than one reason to change?"

**Example violation:** `UserManager` class that handles authentication, database persistence, email notifications, and logging - four reasons to change.

**Fix:** Split into `Authenticator`, `UserRepository`, `EmailNotifier`, `Logger` - each with one responsibility.

### Step 2: Open-Closed Principle (OCP) - Open for Extension, Closed for Modification

Software entities should be open for extension but closed for modification. Add new functionality by adding code, not changing existing code.

**Ask:** "Can I add new behavior without modifying existing classes?"

**Example violation:** Switch statement checking payment types (credit, debit, crypto) - adding new type requires modifying switch.

**Fix:** Use polymorphism - `PaymentProcessor` interface with `CreditCardProcessor`, `DebitCardProcessor`, `CryptoProcessor` implementations. New payment types extend without modifying existing code.

### Step 3: Liskov Substitution Principle (LSP) - Subtype Replaceability

Objects should be replaceable with instances of their subtypes without altering program correctness. Subtypes must honor the parent type's contract.

**Ask:** "Can I substitute a subclass anywhere the parent class is used without breaking behavior?"

**Example violation:** `Rectangle` class with `setWidth()` and `setHeight()`. `Square` subclass overrides both to maintain square constraint - violates substitution because `Rectangle` users expect independent width/height.

**Fix:** Don't make `Square` inherit from `Rectangle` - they have different invariants. Use composition or separate hierarchies.

### Step 4: Interface Segregation Principle (ISP) - No Forced Dependencies

Clients should not be forced to depend on interfaces they don't use. Large interfaces create unnecessary coupling.

**Ask:** "Does this interface force implementers to provide methods they don't need?"

**Example violation:** `Worker` interface with `work()`, `eat()`, `sleep()` - forces `RobotWorker` to implement `eat()` and `sleep()` with no-ops.

**Fix:** Split into `Workable`, `Eatable`, `Sleepable` interfaces. `HumanWorker` implements all three, `RobotWorker` implements only `Workable`.

### Step 5: Dependency Inversion Principle (DIP) - Depend on Abstractions

High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend on details.

**Ask:** "Do my high-level components depend on concrete low-level implementations?"

**Example violation:** `OrderProcessor` directly instantiates `MySQLDatabase` - tightly coupled to specific database.

**Fix:** `OrderProcessor` depends on `IDatabase` interface. `MySQLDatabase`, `PostgreSQLDatabase`, `MongoDatabase` all implement `IDatabase`. Inject the dependency.

## Example Application

**Situation:** E-commerce payment processing system becoming unmaintainable - every new payment method requires changing multiple files.

**Application of SOLID:**
- **SRP:** Separated `PaymentProcessor` (orchestration), `PaymentValidator` (validation logic), `PaymentLogger` (audit trail), `PaymentNotifier` (customer emails)
- **OCP:** Created `IPaymentMethod` interface - new payment types extend without modifying existing code
- **LSP:** All payment implementations (`CreditCard`, `PayPal`, `Crypto`) honor `IPaymentMethod` contract - can be substituted without breaking checkout flow
- **ISP:** Split fat `IPaymentMethod` interface into `IPayable`, `IRefundable`, `IRecurringBillable` - one-time payment methods don't implement recurring billing
- **DIP:** `PaymentProcessor` depends on `IPaymentMethod` abstraction, not concrete payment classes - injected via constructor

**Outcome:** Adding ApplePay required creating one new class implementing `IPaymentMethod` - zero changes to existing code. Testing improved (mock interfaces easily). Team velocity increased 3x for payment features.

## Anti-Patterns

- ❌ Applying SOLID dogmatically to simple code that doesn't need it (over-engineering)
- ❌ Creating unnecessary abstraction layers "just in case" (YAGNI violation)
- ❌ Splitting classes so granularly that understanding requires navigating 50 files
- ❌ Using SOLID as checklist without understanding the "why" behind each principle
- ❌ Ignoring SRP but over-applying OCP (common imbalance)
- ❌ Creating "do-nothing" interface implementations to satisfy ISP (indicates poor interface design)
- ❌ Treating SOLID as rules rather than guidelines for reducing coupling

## Related

- clean-architecture (architectural application of SOLID)
- dependency-injection (DIP implementation pattern)
- composition-over-inheritance (alternative to LSP violations)
- interface-design (foundation for ISP and DIP)
- refactoring-patterns (how to move toward SOLID from legacy code)

Attribution

lev-oslev-os
View sourceMore from lev-os →
SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Related Skills

Caveman Review

Ultra-compressed code review comments. Cuts noise from PR feedback while preserving the actionable signal. Each comment is one line: location, problem, fix. Use when user says "review this PR", "code review", "review the diff", "/review", or invokes /caveman-review. Auto-triggers when reviewing pull requests.

1023331 votes

Caveman Commit

Ultra-compressed commit message generator. Cuts noise from commit messages while preserving intent and reasoning. Conventional Commits format. Subject ≤50 chars, body only when "why" isn't obvious. Use when user says "write a commit", "commit message", "generate commit", "/commit", or invokes /caveman-commit. Auto-triggers when staging changes.

1023331 votes

Springboot Verification

Verification loop for Spring Boot projects: build, static analysis, tests with coverage, security scans, and diff review before release or PR.

2456590 votes

Verification Loop

一个全面的 Claude Code 会话验证系统。

2456590 votes

Django Verification

Verification loop for Django projects: migrations, linting, tests with coverage, security scans, and deployment readiness checks before release or PR.

2456590 votes
View all in code-quality →