solid-principles
Enforce SOLID coding standards (SRP, OCP, LSP, ISP, DIP) in object-oriented projects to improve code design.
Install
mkdir -p .claude/skills/solid-principles && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/77" && unzip -o skill.zip -d .claude/skills/solid-principles && rm skill.zipInstalls to .claude/skills/solid-principles
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Enforce SOLID principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) in object-oriented design. Use when writing or reviewing classes and modules.Key capabilities
- →Identify SOLID principle violations in class structures
- →Suggest structural improvements for architectural compliance
- →Refactor code to implement Strategy or Template patterns
- →Apply dependency injection to decouple components
- →Enforce Interface Segregation using Python Protocols
How it works
The skill evaluates code against SRP, OCP, LSP, ISP, and DIP criteria, identifying architectural red flags and providing refactored alternatives.
Inputs & outputs
When to use solid-principles
- →Reviewing class structures for SRP violations
- →Implementing the Strategy pattern for OCP compliance
- →Refactoring deep inheritance hierarchies
- →Decoupling components via dependency injection
About this skill
SOLID Principles Skill
You are assisting with code that must follow SOLID principles strictly.
Principles to Enforce
1. Single Responsibility Principle (SRP)
- Each class should have ONE reason to change
- Each function should do ONE thing well
- Separate concerns: business logic, data access, presentation, validation
- If a class name contains "and" or "or", it likely violates SRP
Red flags:
- Classes with multiple unrelated methods
- Functions doing multiple operations
- Mixed concerns (e.g., validation + persistence in same method)
2. Open/Closed Principle (OCP)
- Open for extension, closed for modification
- Use abstract base classes and protocols for extensibility
- Prefer composition over inheritance
- New features should be added by extending, not modifying existing code
Patterns to use:
- Strategy pattern for varying algorithms
- Template method for varying steps
- Dependency injection for varying implementations
3. Liskov Substitution Principle (LSP)
- Subtypes must be substitutable for their base types
- Derived classes must not strengthen preconditions
- Derived classes must not weaken postconditions
- Avoid empty implementations or NotImplementedError in production code
Guidelines:
- Don't override methods to do nothing
- Maintain expected behavior contracts
- Use composition when inheritance doesn't fit naturally
4. Interface Segregation Principle (ISP)
- Clients should not depend on interfaces they don't use
- Create focused, cohesive protocols/abstract classes
- Many small interfaces > one large interface
- Use Python Protocols for implicit interfaces
Implementation:
- Split large interfaces into role-specific ones
- Use Protocol from typing module
- Avoid "fat" base classes with many optional methods
5. Dependency Inversion Principle (DIP)
- High-level modules should not depend on low-level modules
- Both should depend on abstractions (protocols, abstract classes)
- Abstractions should not depend on details
- Details should depend on abstractions
Patterns:
- Constructor injection for required dependencies
- Use abstract base classes or Protocols
- Depend on interfaces, not concrete implementations
Code Review Checklist
When reviewing or writing code, check:
- Does each class have a single, clear responsibility?
- Can new behavior be added without modifying existing code?
- Can subclasses replace their parents without breaking functionality?
- Are interfaces focused and cohesive?
- Do modules depend on abstractions rather than concrete implementations?
Practical Application for Admission Rules System
For the Norwegian admission rules system:
- SRP: Separate rule evaluation, grade calculation, quota management
- OCP: Make rules extensible (new admission rules without changing core engine)
- LSP: All rule types should be substitutable
- ISP: Separate interfaces for validators, calculators, reporters
- DIP: Depend on abstract rule interfaces, not concrete rule implementations
Response Format
When applying SOLID principles:
- Identify which principle(s) are relevant
- Explain the violation if any exists
- Provide refactored code following the principle(s)
- Explain the benefit of the refactoring
When not to use it
- →When performing fundamental code refactoring unrelated to architectural principles
- →When analyzing non-object-oriented codebases
Prerequisites
Limitations
- →Requires manual review of suggested refactors for production suitability
- →Focuses strictly on SOLID principles rather than general code quality or performance
How it compares
Unlike generic code review, this skill specifically maps structural issues to formal SOLID principles and provides concrete refactoring patterns.
Compared to similar skills
solid-principles side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| solid-principles (this skill) | 57 | 9mo | No flags | Intermediate |
| python-design-patterns | 19 | 2mo | No flags | Intermediate |
| modular-code | 4 | 7mo | No flags | Intermediate |
| component-common-domain-detection | 1 | 5mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
python-design-patterns
wshobson
Python design patterns including KISS, Separation of Concerns, Single Responsibility, and composition over inheritance. Use when making architecture decisions, refactoring code structure, or evaluating when abstractions are appropriate.
modular-code
parcadei
Modular Code Organization
component-common-domain-detection
tech-leads-club
Identifies duplicate domain functionality across components and suggests consolidation opportunities. Use when finding common domain logic, detecting duplicate functionality, analyzing shared classes, planning component consolidation, or when the user asks about common components, duplicate code, or domain consolidation.
framework-migration-code-migrate
sickn33
You are a code migration expert specializing in transitioning codebases between frameworks, languages, versions, and platforms. Generate comprehensive migration plans, automated migration scripts, and
framework-migration-legacy-modernize
sickn33
Orchestrate a comprehensive legacy system modernization using the strangler fig pattern, enabling gradual replacement of outdated components while maintaining continuous business operations through ex
project-principles
vm0-ai
Core architectural and code quality principles that guide all development decisions in the vm0 project