All skills
wshobson avatar

/projection-patterns

@be57c0b
by Seth Hobsonwshobson/agents40k stars
4,281

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.

Use this Skill: https://skilld.dev/gh/wshobson/agents/projection-patterns

This session only. Nothing lands on disk.

SKILL.md

โ‰ˆ50 tokens always: the name and description. โ‰ˆ610 when used: this file. โ‰ˆ3.6k more on demand in 1 file.

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

Source: SKILL.md on GitHub

No alerts16d5 checks ยท Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides safe and well-implemented code templates and guides for implementing the CQRS pattern and event-driven projections.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW ยท No issues

  • Runlayer6mo

    1/1 file flagged

  • ZeroLeaks5mo

    Score: 93/100 ยท 2 sections analyzed

Signed by skilld at be57c0b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 4 months ago
  • cqrs
  • event-sourcing
  • projections
  • read-models
  • materialized-views
  • event-streams
  • query-optimization

README badge

README badge for wshobson/agents/projection-patterns

Provides patterns and templates for building projections and read models in event-sourced systems, covering live, catchup, persistent, and inline projection types. Targets CQRS architectures, materialized views, and query optimization through event stream processing.

Generated from the current SKILL.md.

Does this skill cover both live and catchup projections?
Yes. The skill describes four projection types: live (real-time from subscription), catchup (historical events), persistent (with checkpoints), and inline (same transaction as write).
What event store or database does this target?
The skill does not mandate a specific event store or database. It provides patterns and architecture guidance applicable to any event-sourced system.
Does this include code templates or just theory?
The skill includes a template library and worked examples in a references/details.md file that contains concrete templates for implementation.
Does this address handling projection failures and replay?
Yes. The skill emphasizes making projections idempotent, storing checkpoints for resume capability, and designing for reconstruction and rebuilds.

Generated from the current SKILL.md. These answers refresh after source changes.