projection-patterns
What it does
This tool helps organize past event information so you can query it quickly. It creates optimized 'views' of your data.
When to use it
- βWhen you need to see the current state of things in real-time.
- βWhen rebuilding information from an event history.
- βTo make data queries faster and more efficient.
Skill link
https://github.com/wshobson/agents/blob/main/plugins/backend-development/skills/projection-patterns/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βHow can I create an optimized view of my sales data from transaction events?β
5 new skills a week. 1 minute to read.
How it works
It works by taking a sequence of events (like records of actions) and processing them to create a simpler, more direct data model. This model is then used to answer questions quickly.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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
FAQ
What are 'events'?
Events are records of something that happened in the past, like 'user signed up' or 'order was placed'.
What is a 'read model'?
It's an organized way of viewing data, made specifically for answering questions, different from how the data was originally recorded.
Why 'optimize performance'?
So the system responds faster to your queries, even with a lot of data, avoiding slowdowns.
Details
Original description by the author
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.
repo: wshobson/agents
Popularity
- GitHub stars
- 41k
- Ranking position
- #6640
- License
- MIT
- Updated
- 10/15/2026
Comments
- β¦
More skills from this repository
screen-reader-testing
41kHas your agent test websites using screen readers to ensure they are accessible.
wcag-audit-patterns
41kHelps your agent audit websites for accessibility and fix issues according to WCAG guidelines.
multi-reviewer-patterns
41kEnables your agent to coordinate parallel code reviews, deduplicating findings and consolidating reports.
parallel-debugging
41kAllows the agent to debug complex issues with parallel investigations and root cause analysis.
Similar skills
api-connector-builder
280kHas your agent build new API connections following the existing pattern. Use when you need to add one more integration without creating a new way of doing things.
api-design
280kHelps your agent design REST APIs following best practices. It's useful for defining how APIs communicate, how errors are shown, and how to organize data.
backend-patterns
280kHelps your agent with server-side architecture patterns and database optimization. It's useful for building or reviewing code that runs on the server.