solid-principles
Skill0 starsChanged 29 days agoMITView on GitHub
Use when designing classes, modules, or functions — especially when code feels hard to extend, test, or change without breaking other parts.
11 other projects use a version of this.
Adopted by
Most recently taken up by
- decebals/claude-code-javatheir own version, first seen Nov 1, 2026
- TheBeardedBearSAS/claude-crafttheir own version, first seen Oct 29, 2026
- andr-ca/agentharnesstheir own version, first seen Oct 15, 2026
- nek1987/auto-agent-harnesstheir own version, first seen Oct 11, 2026
- robconery/koleatheir own version, first seen Aug 19, 2026
- KhaledSaeed18/dotclaudetheir own version, first seen Jul 4, 2026
Other versions11 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 11
- decebals/claude-code-java★ 763same name
- TheBeardedBearSAS/claude-craft★ 108same name
- JeremyMorgan/code-review-skills★ 15same name
- robconery/kolea★ 7same name
- KhaledSaeed18/dotclaude★ 5same name
- nek1987/auto-agent-harness★ 4same name
- kayaman/skills★ 3same name
- kimtth/agent-skill-100-lines-or-less★ 2same name
- lucsedirae/agent_skill_library★ 2same name
- andr-ca/agentharness★ 1same name
1 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/clean-principles.mdcCursor rule
- architecture-principlesSkill
- clarify-before-buildSkill
- clean-codeSkill
- design-patternsSkill
- dry-kiss-yagniSkill
- testing-principlesSkill
The file
Files
SOLID Principles
Five principles for writing maintainable, extensible object-oriented code.
Quick Reference
| Principle | Rule | Smell it fixes |
| S — Single Responsibility | One class = one reason to change | God classes, methods doing too much |
| O — Open/Closed | Open for extension, closed for modification | Switch/if-chains that grow with features |
| L — Liskov Substitution | Subtypes must be substitutable for base types | Subclass that breaks parent's contract |
| I — Interface Segregation | No client should depend on methods it doesn't use | Fat interfaces with unimplemented methods |
| D — Dependency Inversion | Depend on abstractions, not concretions | Hard-coded dependencies, untestable code |
S — Single Responsibility
One reason to change = one actor (user, admin, system) that can demand changes.
# ❌ BAD: User class handles data + persistence + email
class User:
def get_name(self): ...
def save_to_db(self): ... # DB concern
def send_welcome_email(self): ... # Email concern
# ✅ GOOD: Separate concerns
class User:
def get_name(self): ...
class UserRepository:
def save(self, user: User): ...
class UserMailer:
def send_welcome(self, user: User): ...O — Open/Closed
Extend behavior by adding new code, not modifying existing code.
# ❌ BAD: Add new shape? Edit this function.
def area(shape):
if shape.type == "circle": return π * shape.r**2
if shape.type == "rect": return shape.w * shape.h
# ✅ GOOD: Add new shape? Just add a new class.
class Circle:
def area(self): return π * self.r**2
class Rectangle:
def area(self): return self.w * self.hL — Liskov Substitution
If S extends T, you can use S wherever T is expected — same behavior, no surprises.
# ❌ BAD: Square breaks Rectangle's contract
class Rectangle:
def set_width(self, w): self.width = w
def set_height(self, h): self.height = h
class Square(Rectangle):
def set_width(self, w): self.width = self.height = w # Surprise!
# ✅ GOOD: Don't inherit Rectangle — use a shared abstraction
class Shape(ABC):
@abstractmethod
def area(self) -> float: ...
class Circle(Shape):
def area(self) -> float: return π * self.r ** 2 # No surprises
class Square(Shape):
def area(self) -> float: return self.side ** 2 # No surprises
# Any caller using Shape works with Circle, Square, or any future Shape
def print_area(shape: Shape):
print(shape.area()) # Substitution holds — no broken contractsI — Interface Segregation
Split fat interfaces into focused ones. Clients only depend on what they use.
// ❌ BAD: Printer forced to implement fax
interface Machine {
print(): void;
scan(): void;
fax(): void; // Not all machines have this
}
// ✅ GOOD: Focused interfaces
interface Printer { print(): void; }
interface Scanner { scan(): void; }
interface FaxMachine { fax(): void; }D — Dependency Inversion
High-level modules define the interface. Low-level modules implement it.
# ❌ BAD: OrderService directly depends on MySQLDatabase
class OrderService:
def __init__(self):
self.db = MySQLDatabase() # Hard dependency
# ✅ GOOD: Depend on abstraction, inject the implementation
class OrderService:
def __init__(self, db: DatabaseInterface):
self.db = db # Testable, swappableWhen NOT to Apply SOLID
SOLID adds structure — don't add structure before you need it.
| Situation | Guidance |
| Script or utility < ~200 lines | Skip it — SOLID adds boilerplate without benefit |
| Only one concrete implementation | Don't apply DIP/OCP yet (YAGNI wins) |
| Splitting a class makes it harder to read | SRP is served, but clarity isn't — reconsider |
| Prototype / proof of concept | Write it dirty first, refactor when it survives |
Rule: Apply SOLID when the codebase grows and pain appears — not from line 1.
Common Mistakes
| Mistake | Fix |
| Splitting by file, not by responsibility | Ask "who would request this change?" |
| Making everything extensible upfront | Apply OCP only when you see the need (YAGNI) |
| Deep inheritance hierarchies | Prefer composition over inheritance |
| One mega-interface | Split by client usage |
new ConcreteClass() inside business logic | Use constructor injection |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

