Five principles for building software that is easy to understand, extend, and
maintain. They reduce coupling, increase cohesion, and make code testable.
When to Apply
Reference these principles when:
Designing new classes, modules, or interfaces
Refactoring code with too many responsibilities
Reviewing PRs for architectural concerns
Breaking apart god objects or fat interfaces
Deciding where to draw module boundaries
Making code more testable
Quick Reference
Principle
One-Liner
Red Flag
SRP
One reason to change
"This class handles X and Y and Z"
OCP
Add, don't modify
Growing if/else or switch chains for types
LSP
Subtypes are substitutable
Type-checking or special-casing in calling code
ISP
Small, focused interfaces
Empty method implementations or throw new Error("Not implemented")
DIP
Depend on abstractions
new ConcreteClass() inside business logic
See references/PRINCIPLES.md for detailed explanations and TypeScript examples.
Detection Checklist
Ask these questions for every class and module:
Question
Violated Principle
Does this class have multiple reasons to change?
SRP
Do I need to modify existing code to add a new variant?
OCP
Does calling code need type-checks or special cases for subtypes?
LSP
Are implementors forced to stub out unused methods?
ISP
Does high-level logic directly instantiate infrastructure?
DIP
Applying SOLID at Different Scales
Scale
SRP
OCP
LSP
ISP
DIP
Function
Does one thing
—
—
—
Takes abstractions as params
Class
One reason to change
Extend via composition
Subtypes honor contracts
Implements only what it uses
Constructor injection
Module
One bounded context
Plugin architecture
Interchangeable implementations
Thin public API
Depends inward
Service
Single domain
New features = new services
API contract stability
Minimal API surface
Abstractions at boundaries
Relationships Between Principles
SRP + ISP: Splitting responsibilities often means splitting interfaces too
OCP + DIP: Depending on abstractions is what makes extension without modification possible
LSP + OCP: If subtypes are substitutable, you can extend behavior by adding new subtypes
DIP + ISP: Small focused interfaces make dependency inversion practical
Common Anti-Patterns
Anti-Pattern
Violated Principles
Fix
God class doing everything
SRP
Extract focused classes
switch on type across codebase
OCP, LSP
Replace with polymorphism
Subclass that throws "not supported"
LSP, ISP
Redesign hierarchy, split interface
Fat interface with 20 methods
ISP
Split into role-based interfaces
Business logic importing DB driver
DIP
Inject repository interface
Service creating its own dependencies
DIP
Constructor injection
Best Practices
DO
Start with SRP — it's the foundation for all others
Use interfaces to define boundaries between components
Let violations emerge from real problems, then fix them
Prefer composition over inheritance for extending behavior
Keep interfaces small and role-specific
Inject dependencies through constructors
DON'T
Apply SOLID dogmatically to trivial code (a 5-line utility doesn't need an interface)
Create abstractions before you have at least two implementations
Confuse SRP with "single method" — it's about reasons to change, not size
Force Liskov compliance on classes that shouldn't be in the same hierarchy
Over-segregate interfaces into single-method fragments when a cohesive group makes sense
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: fellipeutaka-leon-solid3description: SOLID Principles4---56# SOLID Principles78Five principles for building software that is easy to understand, extend, and9maintain. They reduce coupling, increase cohesion, and make code testable.1011## When to Apply1213Reference these principles when:1415- Designing new classes, modules, or interfaces16- Refactoring code with too many responsibilities17- Reviewing PRs for architectural concerns18- Breaking apart god objects or fat interfaces19- Deciding where to draw module boundaries20- Making code more testable2122## Quick Reference2324| Principle | One-Liner | Red Flag |25| --------- | --------- | -------- |26| **S**RP | One reason to change | "This class handles X *and* Y *and* Z" |27| **O**CP | Add, don't modify | Growing `if/else` or `switch` chains for types |28| **L**SP | Subtypes are substitutable | Type-checking or special-casing in calling code |29| **I**SP | Small, focused interfaces | Empty method implementations or `throw new Error("Not implemented")` |30| **D**IP | Depend on abstractions | `new ConcreteClass()` inside business logic |3132See `references/PRINCIPLES.md` for detailed explanations and TypeScript examples.3334## Detection Checklist3536Ask these questions for every class and module:3738| Question | Violated Principle |39| -------- | ------------------ |40| Does this class have multiple reasons to change? | SRP |41| Do I need to modify existing code to add a new variant? | OCP |42| Does calling code need type-checks or special cases for subtypes? | LSP |43| Are implementors forced to stub out unused methods? | ISP |44| Does high-level logic directly instantiate infrastructure? | DIP |4546## Applying SOLID at Different Scales4748| Scale | SRP | OCP | LSP | ISP | DIP |49| ----- | --- | --- | --- | --- | --- |50| **Function** | Does one thing | — | — | — | Takes abstractions as params |51| **Class** | One reason to change | Extend via composition | Subtypes honor contracts | Implements only what it uses | Constructor injection |52| **Module** | One bounded context | Plugin architecture | Interchangeable implementations | Thin public API | Depends inward |53| **Service** | Single domain | New features = new services | API contract stability | Minimal API surface | Abstractions at boundaries |5455## Relationships Between Principles5657- **SRP + ISP**: Splitting responsibilities often means splitting interfaces too58- **OCP + DIP**: Depending on abstractions is what makes extension without modification possible59- **LSP + OCP**: If subtypes are substitutable, you can extend behavior by adding new subtypes60- **DIP + ISP**: Small focused interfaces make dependency inversion practical6162## Common Anti-Patterns6364| Anti-Pattern | Violated Principles | Fix |65| ------------ | ------------------- | --- |66| God class doing everything | SRP | Extract focused classes |67| `switch` on type across codebase | OCP, LSP | Replace with polymorphism |68| Subclass that throws "not supported" | LSP, ISP | Redesign hierarchy, split interface |69| Fat interface with 20 methods | ISP | Split into role-based interfaces |70| Business logic importing DB driver | DIP | Inject repository interface |71| Service creating its own dependencies | DIP | Constructor injection |7273## Best Practices7475### DO7677- Start with SRP — it's the foundation for all others78- Use interfaces to define boundaries between components79- Let violations emerge from real problems, then fix them80- Prefer composition over inheritance for extending behavior81- Keep interfaces small and role-specific82- Inject dependencies through constructors8384### DON'T8586- Apply SOLID dogmatically to trivial code (a 5-line utility doesn't need an interface)87- Create abstractions before you have at least two implementations88- Confuse SRP with "single method" — it's about reasons to change, not size89- Force Liskov compliance on classes that shouldn't be in the same hierarchy90- Over-segregate interfaces into single-method fragments when a cohesive group makes sense9192---93> Converted and distributed by [TomeVault](https://tomevault.io/claim/fellipeutaka) — claim your Tome and manage your conversions.94<!-- tomevault:4.0:skill_md:2026-04-13 -->
Run npx skillmds@latest add tomevault-io/fellipeutaka-leon-solid in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
SOLID Principles It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.