AgentSkillsCN

architecture

在选择架构风格、评估系统分解策略,或分析系统的架构特征(质量属性)时使用。 适用场景:架构风格选择、比较单体架构 vs 微服务架构、架构特征分析、系统分解策略。 切勿用于:具体风格细节(使用子技能:微服务、单体架构、事件驱动等)、代码级模式(使用开发/设计模式)、集成消息传递(使用开发/集成模式)。

SKILL.md
--- frontmatter
name: architecture
description: |
    Use when selecting architecture styles, evaluating system decomposition strategies, or analyzing architecture characteristics (quality attributes) for a system.
    USE FOR: architecture style selection, comparing monolith vs microservices, architecture characteristics analysis, system decomposition strategy
    DO NOT USE FOR: specific style details (use sub-skills: microservices, monoliths, event-driven, etc.), code-level patterns (use dev/design-patterns), integration messaging (use dev/integration-patterns)
license: MIT
metadata:
  displayName: "Architecture"
  author: "Tyler-R-Kendrick"
compatibility: claude, copilot, cursor

Software Architecture

Overview

Software architecture is the set of significant decisions about the organization of a software system -- the selection of structural elements, their interfaces, composition, and the guiding principles that constrain design and evolution over time. Choosing the right architecture style is one of the highest-leverage decisions a team makes; it shapes every subsequent technical and organizational choice.

This skill covers how to reason about architecture styles, evaluate architecture characteristics (quality attributes), and make informed tradeoffs. For deep dives into specific styles, see the sub-skills below.

Canonical Works

BookAuthor(s)Focus
Fundamentals of Software ArchitectureMark Richards & Neal FordArchitecture styles, characteristics, decisions, metrics
Software Architecture: The Hard PartsNeal Ford, Mark Richards, Pramod Sadalage, Zhamak DehghaniTradeoff analysis, decomposition, data ownership, contracts
Building Evolutionary ArchitecturesFord, Parsons, KuaFitness functions, incremental change, governed evolution
Documenting Software ArchitecturesClements et al.Views, viewpoints, architecture documentation

The Monolith-to-Microservices Spectrum

Architecture is not a binary choice between monolith and microservices. It is a spectrum of modularity:

code
 Monolith                                                    Microservices
    |                                                             |
    |  Big Ball    Layered    Modular      Service-    Micro-     |
    |  of Mud      Monolith   Monolith     Based       services   |
    |                                                             |
    ◄─────────────────────────────────────────────────────────────►
    Less distributed                          More distributed
    Simpler operations                        Complex operations
    Easier consistency                        Eventual consistency
    Tighter coupling                          Loose coupling

Key insight (Richards & Ford): Move along the spectrum only when the pain of your current position exceeds the cost of the next step. Start simple; evolve when you have evidence.

Architecture Characteristics (Quality Attributes)

Architecture characteristics -- also called "-ilities" -- are the non-functional requirements that shape which style fits. They are inherently in tension; optimizing one often degrades another.

CharacteristicDescriptionTension With
ScalabilityAbility to handle growing loadSimplicity, Cost
ReliabilitySystem uptime and fault tolerancePerformance, Cost
PerformanceLatency and throughputScalability, Maintainability
SecurityProtection against threatsUsability, Performance
MaintainabilityEase of change and evolutionPerformance, Time-to-Market
DeployabilityEase and frequency of deploymentSimplicity, Reliability
TestabilityEase of verifying correctnessTime-to-Market
ElasticityAbility to scale up AND down dynamicallyCost, Simplicity
Fault ToleranceGraceful degradation under failurePerformance, Complexity
ModularityDegree of separation between componentsPerformance (indirection cost)

Identifying Driving Characteristics

Not every characteristic matters equally. Richards & Ford recommend identifying the top 3-5 driving characteristics for a system and using those to select an architecture style.

Architecture Style Comparison

StyleScalabilitySimplicityDeployabilityData ConsistencyCostBest For
Layered MonolithLowHighLowHighLowSmall teams, simple domains
Modular MonolithMediumMediumMediumHighLowMedium complexity, single team
Service-BasedMediumMediumMediumMediumMediumDomain-separated teams
MicroservicesHighLowHighLowHighLarge orgs, independent teams
Event-DrivenHighLowHighLowMediumAsync workflows, event streams
Space-BasedVery HighLowMediumLowHighExtreme elastic scalability
Orchestration-DrivenMediumMediumMediumMediumMediumComplex workflows
Pipeline (Pipes & Filters)MediumMediumMediumMediumLowData processing, ETL

Architecture Decision Records (ADRs)

Every significant architecture decision should be captured in an Architecture Decision Record. ADRs provide context for future developers about why a decision was made, what alternatives were considered, and what tradeoffs were accepted.

See: specs/documentation/adr for ADR templates and practices.

ADR structure (Michael Nygard format):

  • Title -- Short noun phrase (e.g., "Use PostgreSQL for order data")
  • Status -- Proposed, Accepted, Deprecated, Superseded
  • Context -- The forces at play, the problem, the constraints
  • Decision -- What was decided and why
  • Consequences -- What becomes easier, what becomes harder

Architecture Decision Process

  1. Identify the driving characteristics -- What are the top 3-5 quality attributes?
  2. Identify the domain partitioning -- How does the domain decompose? (see dev/architecture/domain-driven-design)
  3. Select a candidate style -- Use the comparison table above to narrow options.
  4. Evaluate tradeoffs -- Every style has strengths and weaknesses. Make tradeoffs explicit.
  5. Record the decision -- Write an ADR capturing context, decision, and consequences.
  6. Validate with fitness functions -- Define measurable criteria that the architecture must satisfy over time.

Common Anti-Patterns

  • Accidental architecture -- No deliberate style; the system evolves into a Big Ball of Mud.
  • Resume-driven architecture -- Choosing microservices (or any style) because it looks good on a resume, not because the problem demands it.
  • Architecture by analogy -- "Netflix uses microservices, so we should too." Your context is not Netflix's context.
  • Ignoring the First Law of Software Architecture -- "Everything in software architecture is a tradeoff" (Richards & Ford). If you think you found something that isn't a tradeoff, you haven't identified the tradeoff yet.

Best Practices

  • Start with the simplest architecture that meets your driving characteristics. Evolve when evidence demands it.
  • Make architecture decisions explicit and documented (ADRs).
  • Architecture is not a one-time activity -- it is continuous. Revisit decisions as the system and context evolve.
  • Align architecture boundaries with team boundaries (see Conway's Law and the Inverse Conway Maneuver).
  • Use fitness functions to objectively measure whether the architecture meets its goals over time.
  • Understand that the "best" architecture depends on your specific context: team size, domain complexity, scale requirements, and organizational structure.

Sub-Skills

  • dev/architecture/microservices -- Service decomposition, inter-service communication, saga patterns
  • dev/architecture/monoliths -- Modular monolith, monolith-first strategy, Strangler Fig migration
  • dev/architecture/well-architected -- AWS, Azure, and GCP well-architected frameworks
  • dev/architecture/event-driven -- Event-driven architecture, event sourcing, CQRS
  • dev/architecture/domain-driven-design -- Bounded contexts, aggregates, strategic and tactical DDD
  • dev/architecture/hexagonal -- Ports and adapters, onion architecture, dependency inversion