# Microservices

> Service boundaries, communication patterns, event sourcing, CQRS, and distributed tracing

- **Type:** Skill
- **Install:** `agentstack add skill-cosmicstack-labs-mercury-agent-skills-microservices`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [cosmicstack-labs](https://agentstack.voostack.com/s/cosmicstack-labs)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [cosmicstack-labs](https://github.com/cosmicstack-labs)
- **Source:** https://github.com/cosmicstack-labs/mercury-agent-skills/tree/main/categories/backend/microservices
- **Website:** https://skills.mercuryagent.sh

## Install

```sh
agentstack add skill-cosmicstack-labs-mercury-agent-skills-microservices
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Microservices

Design and operate microservice architectures.

## Service Boundaries

### Bounded Context (DDD)
- Each service owns a domain concept
- Service has its own database (no DB sharing)
- Communication via API or events
- Avoid "shared" services (leads to tight coupling)

### Service Sizing
- **Too small**: Nano-services — high overhead, hard to debug
- **Too large**: Distributed monolith — worst of both worlds
- **Right size**: Team can build, test, deploy independently

## Communication Patterns

| Pattern | Type | When |
|---------|------|------|
| REST | Sync | Request-response, CRUD |
| gRPC | Sync (fast) | Internal, high throughput |
| Event | Async | Decoupled workflows |
| Message Queue | Async | Buffered, reliable delivery |

### Event-Driven Communication
```
Service A → Event Bus → Service B
                       → Service C
                       → Service D
```
Benefits: eventual consistency, loose coupling, replayability.

## CQRS (Command Query Responsibility Segregation)
- Separate read and write models
- Queries go to optimized read stores (materialized views)
- Commands go to write stores (normalized)
- Eventually consistent between them

## Distributed Tracing
- Correlation ID passed across all services
- Use OpenTelemetry for instrumentation
- Trace each request: Service → Queue → DB → External API
- Visualize in Jaeger or Zipkin
- Alert on traces that exceed latency SLOs

## Anti-Patterns to Avoid
❌ Shared database between services
❌ Sync chains (A → B → C → D blocking)
❌ Distributed monolith (microservices but deployed together)
❌ Absent monitoring ("it works in dev")
❌ Premature decomposition (start monolith, extract carefully)

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [cosmicstack-labs](https://github.com/cosmicstack-labs)
- **Source:** [cosmicstack-labs/mercury-agent-skills](https://github.com/cosmicstack-labs/mercury-agent-skills)
- **License:** MIT
- **Homepage:** https://skills.mercuryagent.sh

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-cosmicstack-labs-mercury-agent-skills-microservices
- Seller: https://agentstack.voostack.com/s/cosmicstack-labs
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
