AgentSkillsCN

architecture-patterns

此技能适用于系统设计、设计模式、架构决策、SOLID 原则、代码结构的整洁性、代码组织方式、重构策略以及软件架构的优化。

SKILL.md
--- frontmatter
name: architecture-patterns
description: This skill should be used for system design, design patterns, architectural decisions, SOLID principles, clean code structure, code organization, refactoring strategy, software architecture
whenToUse: Architecture design, design patterns, system structure, code organization, refactoring, clean code, SOLID, dependency injection, layered architecture
whenNotToUse: Simple implementations, established patterns, trivial changes
seeAlso:
  - skill: api-design
    when: designing service APIs
  - skill: database-patterns
    when: data layer architecture
  - skill: testing-strategies
    when: test architecture decisions
  - skill: superpowers:systematic-debugging
    when: debugging complex architectural issues, tracing behavior

Architecture Patterns

Common architectural patterns and design decisions.

Layered Architecture

code
Presentation → Business Logic → Data Access → Database

Clean Architecture

code
        Controllers
             ↓
        Use Cases
             ↓
         Entities

Common Patterns

Repository

code
interface UserRepository {
    findById(id): User
    save(user): void
}

Service Layer

code
class UserService {
    constructor(repo: UserRepository)
    createUser(data): User
}

Dependency Injection

  • Pass dependencies via constructor
  • Program to interfaces, not implementations
  • Enables testing with mocks

Design Principles

  • SOLID: Single responsibility, Open/closed, Liskov, Interface segregation, Dependency inversion
  • DRY: Don't repeat yourself
  • KISS: Keep it simple
  • YAGNI: You aren't gonna need it