projection-patterns – Coding skill for AI agents
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.
Install the projection-patterns skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/projection-patterns-fe020.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /projection-patterns – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/projection-patterns-fe020.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $projection-patterns – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/projection-patterns-fe020.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /projection-patterns – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/projection-patterns-fe020.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /projection-patterns – then describe the task you want done.
SKILL.md content
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
Related skills
- feature-flags-architect – Use when adding, retiring, or auditing feature flags. Triggers on "add a flag", "ship…
- feature-flags-architect – Use when adding, retiring, or auditing feature flags. Triggers on "add a flag", "ship…
- brainstorming – Use before creative or constructive work (features, architecture, behavior). Transforms…
- fix – Fix failing or flaky Playwright tests. Use when user says "fix test", "flaky test"…
- focused-fix – Use when the user asks to fix, debug, or make a specific feature/module/area work…
- peer-review – Prepares evidence-bounded, constructive peer-review drafts and structured manuscript…
- break-ai-fix-loops – Stop ineffective AI coding repair loops with stable failure fingerprints, a…
- brooks-debt – Tech debt assessment that identifies, classifies, and prioritizes maintainability…