PR

projection-patterns

Offers architectural templates for building materialized views from event streams to improve query speed.

Install

mkdir -p .claude/skills/projection-patterns && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3714" && unzip -o skill.zip -d .claude/skills/projection-patterns && rm skill.zip

Installs to .claude/skills/projection-patterns

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

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.
179 chars✓ has a “when” trigger
Advanced

Key capabilities

  • Defines projection architecture models
  • Maps event streams to materialized view tables
  • Sets up idempotent event handlers
  • Implements checkpointing for recovery
  • Optimizes read-side query performance

How it works

Applies established architectural patterns for event processing to separate write/read logic, ensuring consistent event data projection.

Inputs & outputs

You give it
Event stream definition, read model requirements
You get back
Projection schema and implementation pattern

When to use projection-patterns

  • Implement CQRS read sides
  • Build materialized views from events
  • Optimize event-sourced query performance

About this skill

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

TypeDescriptionUse Case
LiveReal-time from subscriptionCurrent state queries
CatchupProcess historical eventsRebuilding read models
PersistentStores checkpointResume after restart
InlineSame transaction as writeStrong 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

When not to use it

  • When simple CRUD database operations suffice
  • When the system does not use event sourcing

Prerequisites

Event store/database systemAccess to event stream documentation

Limitations

  • Requires careful synchronization between write and read sides
  • Rebuilding projections can be resource-intensive

How it compares

It treats read models as distinct, independent derivatives of an event log rather than direct database table mappings.

Compared to similar skills

projection-patterns side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
projection-patterns (this skill)12moNo flagsAdvanced
postgresql-table-design304moNo flagsIntermediate
agentdb-advanced-features79moReviewAdvanced
event-store-design52moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

More by wshobson

View all by wshobson

Search skills

Search the agent skills registry