Provides code quality principles including SOLID, DRY, testing strategies, and best practices for implementation review. Use when reviewing code or applying quality standards.
View on GitHubsequenzia/claude-alchemy
dev-tools
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/sequenzia/claude-alchemy/blob/main/claude-tools/dev-tools/skills/code-quality/SKILL.md -a claude-code --skill code-qualityInstallation paths:
.claude/skills/code-quality/# Code Quality
This skill provides code quality principles and best practices for reviewing and improving implementations.
---
## SOLID Principles
### Single Responsibility Principle (SRP)
A class/function should have one reason to change.
**Bad:**
```typescript
class UserService {
createUser(data) { /* creates user */ }
sendEmail(user) { /* sends email */ }
generateReport(users) { /* generates report */ }
}
```
**Good:**
```typescript
class UserService {
createUser(data) { /* creates user */ }
}
class EmailService {
sendEmail(user) { /* sends email */ }
}
class ReportService {
generateReport(users) { /* generates report */ }
}
```
### Open/Closed Principle (OCP)
Open for extension, closed for modification.
**Bad:** Adding new payment types requires modifying existing code
```typescript
function processPayment(type, amount) {
if (type === 'credit') { /* ... */ }
else if (type === 'debit') { /* ... */ }
// Must modify to add new types
}
```
**Good:** New payment types can be added without modification
```typescript
interface PaymentProcessor {
process(amount: number): Promise<void>;
}
class CreditProcessor implements PaymentProcessor { /* ... */ }
class DebitProcessor implements PaymentProcessor { /* ... */ }
```
### Liskov Substitution Principle (LSP)
Subtypes must be substitutable for their base types.
**Bad:**
```typescript
class Bird {
fly() { /* ... */ }
}
class Penguin extends Bird {
fly() { throw new Error("Can't fly!"); } // Violates LSP
}
```
**Good:**
```typescript
class Bird { /* ... */ }
class FlyingBird extends Bird {
fly() { /* ... */ }
}
class Penguin extends Bird { /* no fly method */ }
```
### Interface Segregation Principle (ISP)
Clients shouldn't depend on interfaces they don't use.
**Bad:**
```typescript
interface Worker {
work(): void;
eat(): void;
sleep(): void;
}
```
**Good:**
```typescript
interface Workable { work(): void; }
interface Eatable { eat(): void; }
interface Sleepable { sleep(): void;