microservices-patterns

$npx mdskill add tranhieutt/software_development_department/microservices-patterns

Provides microservices design patterns for decomposition, communication, and resilience.

  • Designs service decomposition using domain-driven, data-ownership, or team-aligned patterns.
  • Depends on HTTP/gRPC for sync and message queues for async communication.
  • Recommends patterns based on business domain complexity and data isolation needs.
  • Delivers routing configs, circuit breaker code, and orchestration examples.

SKILL.md

.github/skills/microservices-patternsView on GitHub ↗
---
name: microservices-patterns
type: reference
description: "Provides microservices design patterns for service decomposition, API gateway, circuit breakers, saga orchestration, and inter-service communication. Use when designing or implementing microservices architecture."
paths: ["**/docker-compose*", "**/k8s/**", "**/services/**"]
effort: 4
allowed-tools: Read, Glob, Grep, Write, Edit, Bash
user-invocable: true
when_to_use: "When designing microservices architecture, implementing service communication, or decomposing monoliths"
---

# Microservices Patterns

Service decomposition, communication, resilience, and orchestration patterns.

## Service Decomposition

| Pattern | Description | Use When |
|---------|-------------|----------|
| Domain-Driven | Align services with bounded contexts | Complex business domains |
| Data-Ownership | Service owns its data store | Data isolation required |
| Team-Aligned | One service per team | Large organizations |

## Communication Patterns

### Sync: HTTP/gRPC
\`\`\`yaml
# API Gateway routing
routes:
  - match: { prefix: /orders }
    route: { cluster: order-service }
  - match: { prefix: /users }
    route: { cluster: user-service }
\`\`\`

### Async: Message Queue
\`\`\`
Producer → Exchange → Queue → Consumer
         (Topic)   (DLQ on failure)
\`\`\`

Use async for: event propagation, eventual consistency, load leveling.

## Resilience Patterns

### Circuit Breaker
\`\`\`typescript
// Example with opossum
const breaker = new CircuitBreaker(fetchUserProfile, {
  timeout: 3000,
  errorThresholdPercentage: 50,
  resetTimeout: 30000,
});
\`\`\`

### Retry with Backoff
\`\`\`typescript
async function retryWithBackoff(fn, maxRetries = 3) {
  for (let i = 0; i < maxRetries; i++) {
    try { return await fn(); }
    catch (e) { await sleep(Math.pow(2, i) * 1000); }
  }
  throw new Error('Max retries exceeded');
}
\`\`\`

## Data Patterns

| Pattern | Consistency | Complexity | Use When |
|---------|-------------|------------|----------|
| Saga (orchestration) | Eventual | High | Complex multi-service transactions |
| Saga (choreography) | Eventual | Medium | Simple event chains |
| Event sourcing | Eventual | High | Audit trail, time travel |
| Shared database | Strong | Low | Anti-pattern, avoid |

## API Gateway

Tools: Kong, AWS API Gateway, Envoy, NGINX.

Responsibilities: routing, auth, rate limiting, request transformation, load balancing.

## Observability Stack

- Distributed tracing: Jaeger / Tempo
- Metrics: Prometheus + Grafana
- Logs: ELK / Loki
- Service mesh: Istio / Linkerd (adds mTLS, traffic management)

## Related Skills

- `backend-architect` — single-service architecture
- `event-sourcing-architect` — event sourcing patterns
- `kubernetes-architect` — deployment patterns
- `deployment-engineer` — CI/CD for microservices

More from tranhieutt/software_development_department

SkillDescription
agent-healthReads production/traces/agent-metrics.jsonl and displays a per-agent performance summary table for the current or a specified session. Highlights agents with high error rates or OPEN circuit breaker state.
agent-styleProvides the vendored agent-style v0.3.5 prose rule pack as a portable Claude skill. Use when installing, syncing, applying, or auditing SDD Agent-Style support in another project, or when a style-review workflow needs the bundled rules.
angular-best-practicesProvides Angular best practices for components, modules, services, and reactive patterns. Use when working with Angular TypeScript files, component templates, NgModules, RxJS observables, or when the user mentions Angular, ng, or Angular CLI.
annotateRecords unexpected API behaviors, undocumented caveats, version bugs, or non-obvious workarounds into .claude/memory/annotations.md. Use immediately when an undocumented behavior or surprising caveat is discovered during development.
aws-serverlessProvides AWS serverless architecture patterns for Lambda, API Gateway, DynamoDB, SQS, and SAM/CDK. Use when working with AWS serverless files (serverless.yml, CDK stacks) or when the user mentions Lambda, API Gateway, serverless, or AWS SAM.
backend-architectDesigns scalable backend architectures covering microservices, event-driven systems, API gateways, and data stores. Use when designing a backend system or when the user mentions backend architecture, scalability, or distributed systems.
cloud-run-puppeteerDeploys Puppeteer browser automation on Google Cloud Run with Docker. Use when running headless browser tasks on Cloud Run, or when the user mentions Cloud Run, Puppeteer, headless Chrome, or serverless browser automation.
codex-sddAdapts SDD for Codex while preserving Claude Code behavior. Use when working in Codex, setting up Codex compatibility, mapping Claude tools to Codex tools, or explaining how SDD should run outside Claude Code.
database-architectDesigns relational and NoSQL database schemas, indexing strategies, migration plans, and data modeling patterns. Use when designing a database or when the user mentions database architecture, schema design, or data modeling.
db-reviewReviews database schemas, queries, and migrations for correctness, performance, security, and best practices. Use when reviewing SQL migration files or when the user mentions database review, schema review, or query audit.