code-qualitylisted
Install: claude install-skill sequenzia/agent-alchemy
# 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