Habilidades projection-patterns
📦

projection-patterns

Seguro

Build CQRS Projections and Read Models

Também disponível em: wshobson

Struggling with query performance in event-sourced systems? This skill provides proven patterns for building efficient read models and projections from event streams.

Suporta: Claude Codex Code(CC)
🥉 75 Bronze
1

Baixar o ZIP da skill

2

Upload no Claude

Vá em Configurações → Capacidades → Skills → Upload skill

3

Ative e comece a usar

Testar

A utilizar "projection-patterns". User asks for a basic projector template

Resultado esperado:

Provides a Python Projection base class with abstract methods for name, handles(), and apply(). Includes a Projector runner with checkpoint management and batch processing. Shows async/await patterns for database operations.

A utilizar "projection-patterns". User needs an order summary projection

Resultado esperado:

Delivers OrderSummaryProjection class handling OrderCreated, OrderItemAdded, OrderShipped events. Each handler updates specific columns. Demonstrates parameterized SQL queries and connection pooling.

A utilizar "projection-patterns". User wants to rebuild a corrupted projection

Resultado esperado:

Explains rebuild process: delete checkpoint, optionally clear read model tables, re-run projection from position 0. Emphasizes idempotency requirement for safe replay.

Auditoria de Segurança

Seguro
v1 • 2/24/2026

This skill contains documentation and Python code examples for CQRS projection patterns. Static analyzer flagged markdown code blocks as shell commands (false positive). URLs are documentation references, not network calls. No executable code, cryptographic operations, or system access detected. Safe for publication.

2
Arquivos analisados
538
Linhas analisadas
0
achados
1
Total de auditorias
Nenhum problema de segurança encontrado
Auditado por: claude

Pontuação de qualidade

38
Arquitetura
100
Manutenibilidade
87
Conteúdo
50
Comunidade
100
Segurança
100
Conformidade com especificações

O Que Você Pode Construir

E-commerce Order Projections

Build read models that aggregate order events into customer-facing summaries with real-time status updates.

Search Index from Events

Create Elasticsearch projections that keep product catalogs in sync with domain events for full-text search.

Analytics Dashboard Data

Implement aggregating projections that compute daily metrics like sales totals and user activity.

Tente Estes Prompts

Basic Projection Setup
I need to build a read model for order events. Show me how to create a basic projector that handles OrderCreated and OrderUpdated events, stores checkpoints, and updates a SQL table.
Elasticsearch Integration
Create a projection that syncs product domain events to Elasticsearch. Include handling for ProductCreated, ProductUpdated, and ProductDeleted events with proper error handling.
Aggregation Pattern
Show me how to build an aggregating projection that computes daily sales metrics from OrderCompleted events. Include UPSERT logic for efficient updates.
Multi-Table Transactional Projection
I need a projection that updates multiple tables atomically when processing CustomerOrderPlaced events. Show transaction handling and rollback patterns.

Melhores Práticas

  • Make projections idempotent - safe to replay events multiple times without side effects
  • Store checkpoints after each event to enable resume after failures
  • Use database transactions for multi-table updates to maintain consistency

Evitar

  • Coupling projections together - each projection should be independent and isolatable
  • Skipping error handling - unhandled exceptions stop projection and cause data lag
  • Processing events out of order - always respect global_position ordering

Perguntas Frequentes

What is the difference between a projection and a read model?
A projection is the process that transforms events into a read model. The read model is the resulting data structure (database tables, cache, search index) optimized for queries.
How do I handle events that arrive out of order?
Use global_position from the event store to ensure strict ordering. Reject or buffer events that arrive before their predecessors. The event store guarantees order, not the message bus.
Can I rebuild a projection if the read model gets corrupted?
Yes. Delete the projection checkpoint and clear the read model tables, then re-run from position 0. This requires projections to be idempotent.
Should projections be synchronous or asynchronous?
Use asynchronous processing for scalability. Projections typically run as background workers consuming from the event stream, not in the write transaction.
How do I handle projection failures?
Log errors with full event context, alert on repeated failures, and implement retry logic with exponential backoff. Consider a dead-letter queue for poison events.
What database should I use for read models?
Choose based on query patterns: PostgreSQL for relational queries, Elasticsearch for full-text search, Redis for caching, or column stores for analytics. Multiple projections can use different databases.

Detalhes do Desenvolvedor

Estrutura de arquivos