Skills · Coding

Projection Patterns

Unverified30/40

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.

Originally by wshobson · MIT

Claude CodePartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
CursorPartialPlain prose you can paste in — but no Cursor rules file
CodexPartialPlain prose you can paste in — but no AGENTS.md
Gemini CLIPartialPlain prose you can paste in
CopilotPartialPlain prose you can paste in — but no Copilot instructions file
npx agentalley add projection-patterns

This command does not work yet — the CLI is still being built. Until then, use Raw in the reader below to take the file.

Who is stuck, and on what

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.

The whole source

No sign-in, no blur, nothing truncated
projection-patterns/SKILL.md63 lines2.6 KBRawView on GitHub
Frontmatter — 2 properties
nameprojection-patterns
descriptionBuild read models and projections from event streams. Use when implementing CQRS read sides, building materialized views, or optimizing query performance in event-sourced systems.
1---
2name: projection-patterns
3description: 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.
4---A5No allowed-tools declared — no way to tell what this skill may touch
5 
6# Projection Patterns
7 
8Comprehensive guide to building projections and read models for event-sourced systems.
9 
10## When to Use This Skill
11 
12- Building CQRS read models
13- Creating materialized views from events
14- Optimizing query performance
15- Implementing real-time dashboards
16- Building search indexes from events
17- Aggregating data across streams
18 
19## Core Concepts
20 
21### 1. Projection Architecture
22 
23```
24┌─────────────┐ ┌─────────────┐ ┌─────────────┐
25│ Event Store │────►│ Projector │────►│ Read Model │
26│ │ │ │ │ (Database) │
27│ ┌─────────┐ │ │ ┌─────────┐ │ │ ┌─────────┐ │
28│ │ Events │ │ │ │ Handler │ │ │ │ Tables │ │
29│ └─────────┘ │ │ │ Logic │ │ │ │ Views │ │
30│ │ │ └─────────┘ │ │ │ Cache │ │
31└─────────────┘ └─────────────┘ └─────────────┘
32```
33 
34### 2. Projection Types
35 
36| Type | Description | Use Case |
37| -------------- | --------------------------- | ---------------------- |
38| **Live** | Real-time from subscription | Current state queries |
39| **Catchup** | Process historical events | Rebuilding read models |
40| **Persistent** | Stores checkpoint | Resume after restart |
41| **Inline** | Same transaction as write | Strong consistency |
42 
43## Templates and detailed worked examples
44 
45Full template library and detailed worked examples live in `references/details.md`. Read that file when you need the concrete templates.
46 
47## Best Practices
48 
49### Do's
50 
51- **Make projections idempotent** - Safe to replay
52- **Use transactions** - For multi-table updates
53- **Store checkpoints** - Resume after failures
54- **Monitor lag** - Alert on projection delays
55- **Plan for rebuilds** - Design for reconstruction
56 
57### Don'ts
58 
59- **Don't couple projections** - Each is independent
60- **Don't skip error handling** - Log and alert on failures
61- **Don't ignore ordering** - Events must be processed in order
62- **Don't over-normalize** - Denormalize for query patterns
63 

Reviews

Installed this one?Write the first review and take the Trailblazer badge.

Reviews only open after a real install, so this is empty — and we leave it empty rather than invent one.

Alternatives

Also in Coding