# Projection Patterns > Build read models and projections from event streams. Use when implementing CQRS read sides, building materialized views, or optimizing query performance in event-sourced systems. Source: https://skillsagentes.com/skills/wshobson/agents/projection-patterns Repository: https://github.com/wshobson/agents Author: wshobson License: MIT Updated: hace 2 meses Context cost: 45 tok installed, 667 tok once triggered, 4.2k tok with every bundled file Bundle: 2 files, 17 KB Permissions requested: none declared ## Install ```bash npx -y skills add wshobson/agents --skill projection-patterns --agent claude-code ``` ## What it does - Enseña arquitectura de proyectores para transformar eventos en modelos de lectura - Define tipos de proyección: Live, Catchup, Persistent e Inline - Da buenas prácticas: idempotencia, transacciones, checkpoints, monitoreo de lag - Provee plantillas detalladas en references/details.md para casos concretos ## Use it when - Construir modelos de lectura CQRS - Crear vistas materializadas a partir de eventos - Optimizar rendimiento de consultas - Implementar dashboards en tiempo real o índices de búsqueda a partir de eventos ## What triggers it - "Ayúdame a diseñar un modelo de lectura CQRS a partir de mi event store" - "Necesito crear una vista materializada desde eventos" - "Cómo reconstruyo mis proyecciones tras un fallo" ## Before you install - Requiere un sistema con event sourcing y acceso a `references/details.md` para las plantillas completas. ## Files - SKILL.md — 3 KB - references/details.md — 14 KB ## SKILL.md Reproduced verbatim from wshobson/agents under MIT. This section is the upstream document and is in English. # Projection Patterns Comprehensive guide to building projections and read models for event-sourced systems. ## When to Use This Skill - Building CQRS read models - Creating materialized views from events - Optimizing query performance - Implementing real-time dashboards - Building search indexes from events - Aggregating data across streams ## Core Concepts ### 1. Projection Architecture ``` ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ Event Store │────►│ Projector │────►│ Read Model │ │ │ │ │ │ (Database) │ │ ┌─────────┐ │ │ ┌─────────┐ │ │ ┌─────────┐ │ │ │ Events │ │ │ │ Handler │ │ │ │ Tables │ │ │ └─────────┘ │ │ │ Logic │ │ │ │ Views │ │ │ │ │ └─────────┘ │ │ │ Cache │ │ └─────────────┘ └─────────────┘ └─────────────┘ ``` ### 2. Projection Types | Type | Description | Use Case | | -------------- | --------------------------- | ---------------------- | | **Live** | Real-time from subscription | Current state queries | | **Catchup** | Process historical events | Rebuilding read models | | **Persistent** | Stores checkpoint | Resume after restart | | **Inline** | Same transaction as write | Strong consistency | ## Templates and detailed worked examples Full template library and detailed worked examples live in `references/details.md`. Read that file when you need the concrete templates. ## Best Practices ### Do's - **Make projections idempotent** - Safe to replay - **Use transactions** - For multi-table updates - **Store checkpoints** - Resume after failures - **Monitor lag** - Alert on projection delays - **Plan for rebuilds** - Design for reconstruction ### Don'ts - **Don't couple projections** - Each is independent - **Don't skip error handling** - Log and alert on failures - **Don't ignore ordering** - Events must be processed in order - **Don't over-normalize** - Denormalize for query patterns --- Skills Agentes — https://skillsagentes.com/skills/wshobson/agents/projection-patterns