---
title: "イベントから読み取りモデルを作る（エージェント用スキル） | Orchestor"
description: "イベントストリームから読み取りモデルとプロジェクションを構築します。CQRS の読み取り側の実装、マテリアライズドビューの作成、イベントソーシングを使うシステムのクエリ性能改善に使います。wshobson/agents が公開している「イベントから読み取りモデルを作る」の使い方を確認できます。"
canonical_url: "https://www.orchestor.io/ja/skills/wshobson/agents/projection-patterns"
markdown_url: "https://www.orchestor.io/ja/skills/wshobson/agents/projection-patterns.md"
---

[c96b5f6](https://github.com/wshobson/agents/commit/c96b5f6552dba32e4492307493ee613581430715)[原文を開く](https://github.com/wshobson/agents/blob/c96b5f6552dba32e4492307493ee613581430715/plugins/backend-development/skills/projection-patterns/SKILL.md)

wshobson2026/11/24

原文 (選択中)

未翻訳

プレビュー (選択中)

62 行（空行を除く 46 行） · 2.60 KB原文

```yaml
name: projection-patterns
description: 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.
```

# 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 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

## Structured data

```json
[
  [
    {
      "@context": "https://schema.org",
      "@type": "Organization",
      "name": "Orchestor",
      "url": "https://www.orchestor.io",
      "sameAs": [
        "https://orchestor.io",
        "https://www.orchestor.io",
        "https://docs.orchestor.io"
      ],
      "@id": "https://www.orchestor.io/#organization",
      "alternateName": [
        "オーケスター"
      ],
      "logo": "https://www.orchestor.io/images/common/ogp/orchestor-ogp.png",
      "parentOrganization": {
        "@type": "Organization",
        "name": "ドットメディア株式会社",
        "url": "https://www.dotmedia.co.jp"
      }
    },
    {
      "@context": "https://schema.org",
      "@type": "WebSite",
      "url": "https://www.orchestor.io",
      "name": "Orchestor",
      "description": "Orchestor で画像・動画・音声を作り、参照素材を Remix できます。",
      "@id": "https://www.orchestor.io/#website",
      "alternateName": [
        "オーケスター"
      ],
      "inLanguage": "ja",
      "publisher": {
        "@id": "https://www.orchestor.io/#organization"
      }
    }
  ],
  {
    "@context": "https://schema.org",
    "@type": "BreadcrumbList",
    "@id": "https://www.orchestor.io/skills/wshobson/agents/projection-patterns#breadcrumb",
    "itemListElement": [
      {
        "@type": "ListItem",
        "position": 1,
        "name": "Orchestor",
        "item": "https://www.orchestor.io/"
      },
      {
        "@type": "ListItem",
        "position": 2,
        "name": "スキル",
        "item": "https://www.orchestor.io/skills"
      },
      {
        "@type": "ListItem",
        "position": 3,
        "name": "イベントから読み取りモデルを作る",
        "item": "https://www.orchestor.io/skills/wshobson/agents/projection-patterns"
      }
    ]
  }
]
```

---

[Documentation index](https://www.orchestor.io/llms.txt)
