skills/solid-principle/SKILL.md
SOLID — Enforces the SOLID principle of object-oriented design (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) for maintainable and scalable code.
npx skillsauth add ngmthaq/my-copilot solid-principleInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use when writing, reviewing, or refactoring code. Enforces SOLID principle: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion. Applies to classes, modules, functions, and architectural design in any language.
All generated, modified, or reviewed code must follow the SOLID principle. Apply these at the class, module, and function level regardless of programming language.
Every class, module, or function should have one and only one reason to change.
Bad:
class UserService {
createUser(data) {
/* validates, saves to DB, sends email, logs audit */
}
}
Good:
class UserValidator { validate(data) { ... } }
class UserRepository { save(user) { ... } }
class UserNotifier { sendWelcomeEmail(user) { ... } }
class UserService {
constructor(validator, repository, notifier) { ... }
createUser(data) { /* orchestrates the above */ }
}
Software entities should be open for extension but closed for modification.
if/else, switch) that grow with each new caseBad:
function calculateDiscount(type) {
if (type === "student") return 0.2;
if (type === "senior") return 0.3;
// Must edit this function for every new type
}
Good:
interface DiscountStrategy { calculate(): number }
class StudentDiscount implements DiscountStrategy { calculate() { return 0.2; } }
class SeniorDiscount implements DiscountStrategy { calculate() { return 0.3; } }
// New discount = new class, no existing code changes
Subtypes must be substitutable for their base types without altering program correctness.
Bad:
class Bird { fly() { ... } }
class Penguin extends Bird { fly() { throw new Error('Cannot fly'); } }
Good:
class Bird { move() { ... } }
class FlyingBird extends Bird { fly() { ... } }
class Penguin extends Bird { swim() { ... } }
Clients should not be forced to depend on interfaces they do not use.
Bad:
interface Worker {
work(): void;
eat(): void;
sleep(): void;
attendMeeting(): void;
}
// A Robot must implement eat() and sleep() even though they don't apply
Good:
interface Workable { work(): void; }
interface Feedable { eat(): void; }
interface Restable { sleep(): void; }
// Robot implements only Workable
High-level modules should not depend on low-level modules. Both should depend on abstractions.
Bad:
class OrderService {
private db = new MySQLDatabase(); // Tightly coupled to MySQL
private mailer = new SmtpMailer(); // Tightly coupled to SMTP
}
Good:
class OrderService {
constructor(
private db: Database, // Depends on abstraction
private mailer: Mailer // Depends on abstraction
) {}
}
documentation
Guidelines and protocols for Technical Leaders to manage and oversee technical projects effectively while adhering to the core mandate of being the central orchestration layer for all engineering work.
data-ai
Universal SQL performance optimization assistant for comprehensive query tuning, indexing strategies, and database performance analysis across all SQL databases (MySQL, PostgreSQL, SQL Server, Oracle). Provides execution plan analysis, pagination optimization, batch operations, and performance monitoring guidance.
development
SOLID — Enforces the SOLID principle of object-oriented design (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) for maintainable and scalable code.
development
Separation of Concerns (SoC) — Enforces the Separation of Concerns principle by ensuring each module, layer, and component addresses exactly one well-defined concern. Use when writing, reviewing, or refactoring code that mixes UI with business logic, business logic with data access, presentation with formatting, or cross-cutting concerns (auth, logging, validation) with core logic.