home / skills / pluginagentmarketplace / custom-plugin-software-design / architecture-patterns

architecture-patterns skill

/skills/architecture-patterns

This skill helps you select and document architectural patterns, improving design decisions and consistency across projects.

npx playbooks add skill pluginagentmarketplace/custom-plugin-software-design --skill architecture-patterns

Review the files below or copy the command above to add this skill to your agents.

Files (6)
SKILL.md
5.7 KB
---
name: architecture-patterns
description: Design, evaluate, and document software architecture patterns
sasmp_version: "1.3.0"
bonded_agent: 07-architecture-patterns
bond_type: PRIMARY_BOND
version: "2.0.0"
updated: "2025-12-30"
---

# Architecture Patterns Skill

> Atomic skill for architecture design and evaluation

## Skill Definition

```yaml
skill_id: architecture-patterns
responsibility: Single - Architecture pattern recommendation and documentation
atomic: true
idempotent: true
```

## Parameter Schema

```typescript
interface SkillParams {
  // Required
  action: 'recommend' | 'evaluate' | 'document' | 'migrate';

  // Conditional
  requirements?: SystemRequirements;    // For recommend
  current_architecture?: string;        // For evaluate, migrate
  target_architecture?: string;         // For migrate

  // Optional
  constraints?: ArchitectureConstraints;
  team_size?: number;
  output_format?: 'text' | 'diagram' | 'adr';
}

interface SystemRequirements {
  functional: string[];
  non_functional: {
    scalability: 'low' | 'medium' | 'high';
    maintainability: 'low' | 'medium' | 'high';
    testability: 'low' | 'medium' | 'high';
    performance: 'low' | 'medium' | 'high';
  };
  domain_complexity: 'simple' | 'moderate' | 'complex';
}

interface SkillResult {
  recommendation?: ArchitectureRecommendation;
  evaluation?: ArchitectureEvaluation;
  documentation?: ArchitectureDocumentation;
  migration_plan?: MigrationPlan;
}
```

## Validation Rules

```yaml
input_validation:
  action:
    required: true
    enum: [recommend, evaluate, document, migrate]

  requirements:
    required_when: action == 'recommend'

  current_architecture:
    required_when: action in ['evaluate', 'migrate']
```

## Retry Logic

```yaml
retry_config:
  max_attempts: 3
  backoff:
    type: exponential
    initial_delay_ms: 2000
    max_delay_ms: 20000
    multiplier: 2

  retryable_errors:
    - TIMEOUT
    - RATE_LIMIT

  non_retryable_errors:
    - INVALID_REQUIREMENTS
    - UNKNOWN_PATTERN
```

## Architecture Patterns

### Pattern Catalog

```yaml
layered:
  complexity: low
  scalability: limited
  testability: medium
  best_for:
    - Simple CRUD applications
    - Small teams (1-5)

hexagonal:
  complexity: medium
  scalability: high
  testability: high
  best_for:
    - Complex business logic
    - High testability requirements

clean:
  complexity: high
  scalability: high
  testability: high
  best_for:
    - Enterprise applications
    - Long-lived systems

cqrs:
  complexity: high
  scalability: very_high
  best_for:
    - Read-heavy systems
    - Different scaling requirements

event_sourcing:
  complexity: very_high
  scalability: very_high
  best_for:
    - Audit requirements
    - Temporal queries
```

### Decision Matrix

```yaml
decision_matrix:
  simple_crud:
    recommended: layered
    avoid: [event_sourcing, cqrs]

  complex_domain:
    recommended: hexagonal
    avoid: [layered]

  high_scalability:
    recommended: cqrs
    avoid: [layered]

  audit_requirements:
    recommended: event_sourcing
```

## Usage Examples

### Recommendation
```typescript
// Input
{
  action: "recommend",
  requirements: {
    functional: ["User management", "Order processing"],
    non_functional: {
      scalability: "high",
      maintainability: "high",
      testability: "high"
    },
    domain_complexity: "complex"
  },
  team_size: 8
}

// Output
{
  recommendation: {
    primary_pattern: "Hexagonal Architecture",
    alternatives: [
      { pattern: "Clean Architecture", fit_score: 0.85 }
    ],
    rationale: "Complex domain with high testability needs",
    tradeoffs: [
      { benefit: "High testability", cost: "Initial learning curve" }
    ]
  }
}
```

### ADR Generation
```typescript
// Input
{
  action: "document",
  system_description: "E-commerce platform with complex pricing",
  output_format: "adr"
}

// Output
{
  documentation: {
    adr: `
# ADR-001: Adopt Hexagonal Architecture

## Status
Accepted

## Context
Building e-commerce platform with complex pricing rules.

## Decision
Adopt Hexagonal Architecture with domain-centric design.

## Consequences
### Positive
- Domain logic isolated and highly testable
- Easy to swap external providers

### Negative
- More initial setup required
    `
  }
}
```

## Unit Test Template

```typescript
describe('ArchitecturePatternsSkill', () => {
  describe('recommend', () => {
    it('should recommend Layered for simple CRUD', async () => {
      const result = await skill.execute({
        action: 'recommend',
        requirements: {
          non_functional: { scalability: 'low' },
          domain_complexity: 'simple'
        },
        team_size: 3
      });

      expect(result.recommendation.primary_pattern).toBe('Layered Architecture');
    });

    it('should recommend Hexagonal for complex domain', async () => {
      const result = await skill.execute({
        action: 'recommend',
        requirements: {
          non_functional: { testability: 'high' },
          domain_complexity: 'complex'
        },
        team_size: 8
      });

      expect(result.recommendation.primary_pattern).toBe('Hexagonal Architecture');
    });
  });
});
```

## Error Handling

```yaml
errors:
  INVALID_REQUIREMENTS:
    code: 400
    message: "Requirements incomplete or invalid"
    recovery: "Provide at least functional or non-functional requirements"

  UNKNOWN_PATTERN:
    code: 400
    message: "Architecture pattern not recognized"
    recovery: "Use supported pattern name"
```

## Integration

```yaml
requires:
  - pattern_matcher
  - adr_generator

emits:
  - architecture_recommended
  - architecture_evaluated
  - adr_generated

consumed_by:
  - 07-architecture-patterns (bonded agent)
  - 05-domain-driven (for DDD architecture mapping)
```

Overview

This skill recommends, evaluates, documents, and helps migrate software architecture patterns for systems of varying complexity. It focuses on matching requirements to established patterns (layered, hexagonal, clean, CQRS, event sourcing) and producing pragmatic outputs like ADRs, architecture evaluations, and migration plans. The skill is atomic, idempotent, and intended for integration into design pipelines or assistant workflows.

How this skill works

Provide an action (recommend, evaluate, document, migrate) and the relevant inputs: system requirements for recommendations, current and target architectures for evaluation or migration, and optional constraints or team size. The skill uses a decision matrix and pattern catalog to score fits, explains tradeoffs, generates concise rationale, and can emit ADR-style documentation or migration steps. Validation ensures required fields are present and errors guide corrective input.

When to use it

  • Selecting an architecture for a new project based on functional and non-functional requirements.
  • Evaluating an existing architecture against scalability, testability, and maintainability goals.
  • Documenting an architecture decision as an ADR for team alignment and audits.
  • Planning a migration from a legacy architecture to a modern pattern with minimized risk.
  • Choosing patterns for read-heavy, audit-heavy, or complex domain systems.

Best practices

  • Supply concrete functional requirements and explicit non-functional targets (scalability, testability, performance).
  • Include domain complexity and team size to balance pattern fit versus implementation cost.
  • Use generated ADRs as a baseline and iterate with stakeholders before final acceptance.
  • Prefer prototypes or pilot modules when adopting high-complexity patterns (CQRS, event sourcing).
  • Limit migration scope to bounded contexts and define rollback criteria for each step.

Example use cases

  • Recommend Hexagonal or Clean Architecture for a complex enterprise system with high testability needs.
  • Advise Layered Architecture for a small team building a simple CRUD application to reduce upfront complexity.
  • Generate an ADR documenting the decision to adopt event sourcing for audit and temporal query requirements.
  • Evaluate a monolith and produce a phased migration plan toward Microservices using CQRS where read scalability is critical.

FAQ

What inputs are required to get a recommendation?

Provide action: recommend and a requirements object including functional features, non-functional targets, and domain complexity; team size and constraints help refine the result.

Can the skill produce formal ADRs?

Yes. Set action to document and output_format to adr to receive a ready-to-use Architecture Decision Record with context, decision, and consequences.