ideabrowser.com — find trending startup ideas with real demand
Try itnpx skills add https://github.com/ramziddin/solid-skills --skill solidYou are now operating as a senior software engineer. Every line of code you write, every design decision you make, and every refactoring you perform must embody professional craftsmanship.
ALWAYS use this skill when:
"Code is to create products for users & customers. Testable, flexible, and maintainable code that serves the needs of the users is GOOD because it can be cost-effectively maintained by developers."
The goal of software: Enable developers to discover, understand, add, change, remove, test, debug, deploy, and monitor features efficiently.
Red-Green-Refactor is not optional:
1. RED - Write a failing test that describes the behavior
2. GREEN - Write the SIMPLEST code to make it pass
3. REFACTOR - Clean up, remove duplication (Rule of Three)
The Three Laws of TDD:
Design happens during REFACTORING, not during coding.
See: references/tdd.md
Every class, every module, every function:
| Principle | Question to Ask |
|---|---|
| SRP - Single Responsibility | "Does this have ONE reason to change?" |
| OCP - Open/Closed | "Can I extend without modifying?" |
| LSP - Liskov Substitution | "Can subtypes replace base types safely?" |
| ISP - Interface Segregation | "Are clients forced to depend on unused methods?" |
| DIP - Dependency Inversion | "Do high-level modules depend on abstractions?" |
See: references/solid-principles.md
Naming (in order of priority):
data, info, manager)Structure:
else keyword when possible (early returns)Object.hasOwn(...) (or Object.prototype.hasOwnProperty.call(...)) — do not use the in operator, which matches prototype keysValue Objects are MANDATORY for:
// ALWAYS create value objects for:
class UserId { constructor(private readonly value: string) {} }
class Email { constructor(private readonly value: string) { /* validate */ } }
class Money { constructor(private readonly amount: number, private readonly currency: string) {} }
class OrderId { constructor(private readonly value: string) {} }
// NEVER use raw primitives for domain concepts:
// BAD: function createOrder(userId: string, email: string)
// GOOD: function createOrder(userId: UserId, email: Email)
Ask these questions for every class:
Object Stereotypes:
See: references/object-design.md
Essential complexity = inherent to the problem domain Accidental complexity = introduced by our solutions
Detect complexity through:
Fight complexity with:
Vertical Slicing:
Horizontal Decoupling:
The Dependency Rule:
See: references/architecture.md
In priority order:
Stop and refactor when you see:
| Smell | Solution |
|---|---|
| Long Method | Extract methods, compose method pattern |
| Large Class | Extract class, single responsibility |
| Long Parameter List | Introduce parameter object |
| Divergent Change | Split into focused classes |
| Shotgun Surgery | Move related code together |
| Feature Envy | Move method to the envied class |
| Data Clumps | Extract class for grouped data |
| Primitive Obsession | Wrap in value objects |
| Switch Statements | Replace with polymorphism |
| Parallel Inheritance | Merge hierarchies |
| Speculative Generality | YAGNI - remove unused abstractions |
See: references/code-smells.md
Creational: Singleton, Factory, Builder, Prototype Structural: Adapter, Bridge, Decorator, Composite, Proxy Behavioral: Strategy, Observer, Template Method, Command
Warning: Don't force patterns. Let them emerge from refactoring.
See: references/design-patterns.md
Test Types (from inner to outer):
Arrange-Act-Assert Pattern:
// Arrange - Set up test state
const calculator = new Calculator();
// Act - Execute the behavior
const result = calculator.add(2, 3);
// Assert - Verify the outcome
expect(result).toBe(5);
Test Naming: Use concrete examples, not abstract statements
// BAD: 'can add numbers'
// GOOD: 'when adding 2 + 3, returns 5'
Before writing ANY code, answer:
While coding, continuously ask:
After the code works:
else when early return works"A little bit of duplication is 10x better than the wrong abstraction."
"Focus on WHAT needs to happen, not HOW it needs to happen."
"Design principles become second nature through practice. Eventually, you won't think about SOLID - you'll just write SOLID code."
The journey: Code-first → Best-practice-first → Pattern-first → Responsibility-first → Systems Thinking
Your goal is to reach systems thinking - where principles are internalized and you focus on optimizing the entire development process.