Saltar al contenido
Skillpedia
Varios48 mil · #5233

patterns

Qué hace

Este documento es una guía de referencia sobre patrones de diseño usados en programación, como CQRS, Event Sourcing y Saga. Explica qué son, cuándo usarlos y cómo funcionan.

Cuándo usarla

  • ✓Cuando quieres aprender sobre patrones de diseño.
  • ✓Para entender cómo organizar sistemas complejos.
  • ✓Cuando buscas soluciones a problemas comunes de software.

Link de la skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/monopoly/patterns/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/monopoly/patterns/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Explícame el patrón Circuit Breaker.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

Este documento enumera y describe varios patrones de diseño de software. Para cada patrón, detalla qué es, cuándo es útil, cómo implementarlo y sus ventajas e inconvenientes.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de GitHub.

MONOPOLY — Design Patterns Deep Dive

When to Use

  • Use this skill when the task matches this description: Reference document for monopoly patterns.

Table of Contents

  1. CQRS
  2. Event Sourcing
  3. Saga Pattern
  4. Circuit Breaker
  5. Bulkhead
  6. Strangler Fig
  7. Sidecar / Service Mesh
  8. Outbox Pattern
  9. Consistent Hashing
  10. Backpressure
  11. Leader Election
  12. Two-Phase Commit

1. CQRS (Command Query Responsibility Segregation)

What it is: Separate the read model (Query) from the write model (Command) into distinct services, databases, or code paths.

When to use:

  • Read load is 10×+ write load (most web apps)
  • Read queries are complex aggregations over write data
  • Need to optimize read and write paths independently
  • Domain model is complex (DDD contexts)

Implementation:

Write Path:  Client → Command API → Write DB (normalized, PostgreSQL)
Read Path:   Client → Query API  → Read DB (denormalized, Redis / Elasticsearch)
Sync:        Write DB → CDC (Debezium) → Message Queue → Read DB updater

Trade-offs:

  • ✅ Independent scaling of read and write
  • ✅ Optimized schemas for each operation type
  • ❌ Eventual consistency between write and read models
  • ❌ Increased complexity; two models to maintain

Real-world users: Amazon (order service), LinkedIn (feed)


2. Event Sourcing

What it is: Store state as a sequence of immutable events rather than current state. Rebuild current state by replaying events.

When to use:

  • Full audit trail is a regulatory requirement (fintech, healthcare)
  • Need to replay history for debugging or analytics
  • Complex domain with many state transitions
  • Need to derive multiple read projections from same data

Implementation:

Event Store: append-only log (Kafka, EventStoreDB)
Snapshots:   periodic snapshots to speed up state rebuild
Projections: consumers build read models from events

Trade-offs:

  • ✅ Complete audit history; perfect for compliance
  • ✅ Replay and time-travel debugging
  • ❌ Querying current state requires projection maintenance
  • ❌ Event schema evolution is hard
  • ❌ High storage overhead over time

3. Saga Pattern

What it is: Manage distributed transactions across microservices via a sequence of local transactions, each publishing an event. If a step fails, compensating transactions undo previous steps.

Two variants:

  • Choreography: Services react to events autonomously (decentralized)
  • Orchestration: A central Saga Orchestrator coordinates steps (centralized)

When to use:

  • Multi-service workflows where ACID across services is impossible
  • Long-running business transactions (order → payment → inventory → shipping)
  • Need rollback across service boundaries

Choreography Example:

OrderService creates order →
  [event: OrderCreated] →
    PaymentService charges card →
      [event: PaymentProcessed] →
        InventoryService reserves stock →
          [event: StockReserved] →
            ShippingService books courier

Compensating Transactions (on failure):

ShippingService fails →
  [event: ShippingFailed] →
    InventoryService releases stock →
      PaymentService refunds card →
        OrderService marks order failed

Trade-offs:

  • ✅ No distributed locking; high availability
  • ✅ Scales well across services
  • ❌ Hard to debug; distributed trace required
  • ❌ Compensating transactions are complex to implement correctly

4. Circuit Breaker

What it is: A proxy that monitors calls to a service. If failure rate exceeds threshold, the circuit "opens" and calls fail fast instead of waiting for timeout.

States:

CLOSED  → calls pass through; monitor failure rate
OPEN    → calls fail immediately; no calls to downstream
HALF-OPEN → let a probe call through; if success, close; if fail, stay open

When to use:

  • Calling any external service (payment gateway, SMS, email)
  • Microservices calling each other
  • Preventing timeout cascade when downstream is slow

Implementation tools: Hystrix (deprecated), Resilience4j, Polly (.NET), Envoy proxy

Thresholds (starting point):

  • Open after 50% failure rate over 10 requests
  • Stay open for 30 seconds
  • Half-open: allow 1 probe request

Trade-offs:

  • ✅ Prevents cascade failures
  • ✅ Gives downstream time to recover
  • ❌ Adds latency overhead for monitoring
  • ❌ Requires fallback behavior when circuit is open

5. Bulkhead

…

Preguntas frecuentes

¿Qué son los 'patrones de diseño'?

Son soluciones reutilizables a problemas comunes que surgen en el desarrollo de software. Ayudan a crear código más organizado, eficiente y fácil de mantener.

¿Cuál es la diferencia entre CQRS y Event Sourcing?

CQRS separa las operaciones de lectura y escritura, mientras que Event Sourcing registra todos los cambios como una secuencia de eventos.

¿Qué es el 'patrón Saga'?

Es una forma de gestionar transacciones que involucran varios servicios, asegurando que todo se complete o se deshaga correctamente, incluso si una parte falla.

Detalles

Descripción original del autor

Reference document for monopoly patterns.

repo: sickn33/agentic-awesome-skills

Popularidad

Estrellas en GitHub
48 mil
Posición en el ranking
#5233
Licencia
MIT
Actualizada
15/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas