From claude-commands
Enforces SOLID principles, TDD (red-green-refactor), and clean code practices to elevate code quality. Activates during coding, refactoring, architecture, code review, and debugging.
How this skill is triggered — by the user, by Claude, or both
Slash command
/claude-commands:solidThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You 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.
You 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 in JS/TS, isinstance in Python)Value Objects are MANDATORY for:
// ALWAYS create value objects for:
class UserId { constructor(private readonly value: string) { /* validate UUID */ } }
class Email { constructor(private readonly value: string) { /* validate format */ } }
class Money { constructor(private readonly amount: number, private readonly currency: string) { /* validate amount >= 0 */ } }
class OrderId { constructor(private readonly value: string) { /* validate UUID */ } }
// 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.
npx claudepluginhub jleechanorg/claude-commands --plugin claude-commandsApplies Uncle Bob's Clean Code, Clean Architecture, Clean Coder, Clean Agile principles for code review, refactoring, writing code, and architecture discussions.
Applies SRP, DRY, YAGNI, naming, error handling, dependency direction, and Kent Beck's four rules of simple design when writing, reviewing, or refactoring code.
Reviews code for smells, complexity, and design issues; applies SOLID principles and clean code heuristics during refactoring. Language-agnostic.