{"id":"projection-patterns","name":"projection-patterns","summary":"イベントストリームからリードモデルや予測を構築します。CQRSリードサイドの実装、マテライズドビューの構築、イベントソースシステムでのクエリ性能最適化などに使用されます。","body":"# Projection Patterns\n\nComprehensive guide to building projections and read models for event-sourced systems.\n\n## When to Use This Skill\n\n- Building CQRS read models\n- Creating materialized views from events\n- Optimizing query performance\n- Implementing real-time dashboards\n- Building search indexes from events\n- Aggregating data across streams\n\n## Core Concepts\n\n### 1. Projection Architecture\n\n```\n┌─────────────┐     ┌─────────────┐     ┌─────────────┐\n│ Event Store │────►│ Projector   │────►│ Read Model  │\n│             │     │             │     │ (Database)  │\n│ ┌─────────┐ │     │ ┌─────────┐ │     │ ┌─────────┐ │\n│ │ Events  │ │     │ │ Handler │ │     │ │ Tables  │ │\n│ └─────────┘ │     │ │ Logic   │ │     │ │ Views   │ │\n│             │     │ └─────────┘ │     │ │ Cache   │ │\n└─────────────┘     └─────────────┘     └─────────────┘\n```\n\n### 2. Projection Types\n\n| Type           | Description                 | Use Case               |\n| -------------- | --------------------------- | ---------------------- |\n| **Live**       | Real-time from subscription | Current state queries  |\n| **Catchup**    | Process historical events   | Rebuilding read models |\n| **Persistent** | Stores checkpoint           | Resume after restart   |\n| **Inline**     | Same transaction as write   | Strong consistency     |\n\n## Templates and detailed worked examples\n\nFull template library and detailed worked examples live in `references/details.md`. Read that file when you need the concrete templates.\n\n## Best Practices\n\n### Do's\n\n- **Make projections idempotent** - Safe to replay\n- **Use transactions** - For multi-table updates\n- **Store checkpoints** - Resume after failures\n- **Monitor lag** - Alert on projection delays\n- **Plan for rebuilds** - Design for reconstruction\n\n### Don'ts\n\n- **Don't couple projections** - Each is independent\n- **Don't skip error handling** - Log and alert on failures\n- **Don't ignore ordering** - Events must be processed in order\n- **Don't over-normalize** - Denormalize for query patterns","author":"@wshobson","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/wshobson/agents/tree/main/plugins/backend-development/skills/projection-patterns","license":"MIT","category":"writing","lang":"en","tokens":504,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/details.md","size":14266,"sha256":"d69c4e5a1f3643d6e603601f84a949d3f724837e358d2310e06e5c846e405d30"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":[]}}