← ClaudeAtlas

solid-principleslisted

Use when designing classes or APIs to evaluate SOLID compliance — SRP, OCP, LSP, ISP, DIP. Covers what each principle means, how to diagnose violations by symptom, and how to refactor.
andr-ca/agentharness · ★ 1 · Code & Development · score 70
Install: claude install-skill andr-ca/agentharness
# SOLID Principles Five principles for writing code that's easy to change. --- ## S — Single Responsibility Principle **A class should have one reason to change.** One class doing two unrelated things = two reasons to change it. ```python # Violation: UserService handles auth AND notifications class UserService: def login(self, email, password): ... def send_welcome_email(self, user): ... # belongs elsewhere # Better class AuthService: def login(self, email, password): ... class UserNotifier: def send_welcome(self, user): ... ``` **Signal**: method names have unrelated verbs; the class imports from many unrelated modules. --- ## O — Open/Closed Principle **Open for extension, closed for modification.** Add behavior by adding code, not by editing existing code. ```typescript // Violation: every new payment method requires editing function processPayment(type: string, amount: number) { if (type === 'card') { ... } if (type === 'crypto') { ... } // keep adding ifs } // Better: polymorphism or strategy interface PaymentProcessor { process(amount: number): Promise<void>; } class CardProcessor implements PaymentProcessor { ... } class CryptoProcessor implements PaymentProcessor { ... } ``` **Signal**: feature additions require editing a `switch`/`if-else` chain in a stable class. --- ## L — Liskov Substitution Principle **Subtypes must be substitutable for their supertypes.** If `B extends A`, code using `A` must work with `B` witho