Help us improve
Share bugs, ideas, or general feedback.
From ai-dlc-skills
Apply software architecture best practices and design patterns. Use when designing systems, refactoring code, making architectural decisions, or reviewing code structure.
npx claudepluginhub queen-of-code/ai-dlc --plugin ai-dlc-skillsHow this skill is triggered — by the user, by Claude, or both
Slash command
/ai-dlc-skills:architectureThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- Designing new systems or features
Guides technical evaluation of code review feedback: read fully, restate for understanding, verify against codebase, respond with reasoning or pushback before implementing.
Share bugs, ideas, or general feedback.
| Principle | Description | Violation Sign |
|---|---|---|
| Single Responsibility | A class should have one reason to change | Class doing too many things |
| Open/Closed | Open for extension, closed for modification | Frequent edits to existing classes |
| Liskov Substitution | Subtypes must be substitutable for base types | Checks for specific types in code |
| Interface Segregation | Many specific interfaces over one general | Clients implementing unused methods |
| Dependency Inversion | Depend on abstractions, not concretions | Hard-coded dependencies |
Organize code into distinct layers:
┌─────────────────────────────┐
│ Presentation Layer │ UI, API endpoints, CLI
├─────────────────────────────┤
│ Application Layer │ Use cases, orchestration
├─────────────────────────────┤
│ Domain Layer │ Business logic, entities
├─────────────────────────────┤
│ Infrastructure Layer │ Database, external services
└─────────────────────────────┘
Key rules:
Prefer constructor injection for required dependencies:
# Good: Dependencies are explicit and testable
class OrderService:
def __init__(self, repository: OrderRepository, notifier: Notifier):
self.repository = repository
self.notifier = notifier
# Bad: Hidden dependencies, hard to test
class OrderService:
def __init__(self):
self.repository = PostgresOrderRepository()
self.notifier = EmailNotifier()
Abstract data access behind a clean interface:
class UserRepository(Protocol):
def get_by_id(self, user_id: str) -> User | None: ...
def save(self, user: User) -> None: ...
def find_by_email(self, email: str) -> User | None: ...
Encapsulate business operations:
class UserService:
def register(self, email: str, password: str) -> User:
# Validation
# Business logic
# Persistence
# Side effects (email, events)
Start with a monolith when:
Consider microservices when:
REST conventions:
/users, /ordersGraphQL considerations:
Normalization:
Indexing strategy:
| Strategy | Use Case | Invalidation |
|---|---|---|
| Cache-aside | Read-heavy, tolerates stale data | TTL or explicit invalidation |
| Write-through | Consistency important | On write |
| Write-behind | Write-heavy, eventual consistency | Async batch writes |
Cache placement:
Use events for:
Event patterns:
| Anti-Pattern | Problem | Solution |
|---|---|---|
| God class | One class does everything | Split by responsibility |
| Spaghetti code | Tangled dependencies | Clear layering |
| Golden hammer | Same solution for everything | Choose appropriate tools |
| Premature optimization | Optimizing before needed | Measure first |
| Copy-paste programming | Duplicated code | Extract and reuse |
When facing an architectural decision:
For detailed pattern examples, see patterns/ directory.