Skip to content
Back to skills

Cqrs

ASecurity

Command Query Responsibility Segregation — separate write models (commands, invariants) from read models (projections, denormalized views), synchronization via events, eventual consistency handling in UI and APIs, when not to use it. Use when read and write needs diverge strongly (CQRS, read model, projection, command handler, eventual consistency).

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentsgoapidatabase

Works with

  • api

Security analysis

A100/100

Scanned December 3, 2026

npx -y skills add vectora-os/kit --skill cqrs --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cqrs?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cqrs
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectora-os-cqrs/badge)](https://www.skillsdirectory.com/skills/vectora-os-cqrs)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cqrs
description: Command Query Responsibility Segregation — separate write models (commands, invariants) from read models (projections, denormalized views), synchronization via events, eventual consistency handling in UI and APIs, when not to use it. Use when read and write needs diverge strongly (CQRS, read model, projection, command handler, eventual consistency).
metadata:
  category: design-patterns
---

# CQRS

## Purpose

Optimize writes for correctness and reads for query needs independently.

**Use when:** read patterns differ greatly from write structure, or read load dominates.

**Not for:** simple CRUD — CQRS adds moving parts.

## Inputs

- Command and query requirements, consistency needs.

## Outputs

- Command model, read model designs, sync mechanism, consistency strategy.

## Read first

- [Project Brain](../../../project-brain/README.md) — `npm run brain -- query "cqrs"` for prior decisions, patterns and anti-patterns.

## Steps

1. **Justify.** Show why one model fails (query complexity, load); else stop.
   Done when the need is evidenced.
2. **Commands.** Design command handlers enforcing invariants on the write model.
   Done when each command validates and emits events.
3. **Projections.** Design read models per query; update from events idempotently.
   Done when projections can be rebuilt.
4. **Consistency.** Decide UX for lag (read-your-writes, version tokens, optimistic UI).
   Done when lag is handled visibly.

## Best practices

- Make projections rebuildable from source.
- Idempotent projection handlers with checkpoints.
- Start with same database, separate models.

## Common mistakes

- Applying CQRS system-wide.
- Ignoring read-after-write expectations.
- Non-idempotent projections.

## Example

Order dashboard read model denormalizes customer and totals; updated from `OrderPlaced`/`OrderShipped`; UI shows "updating…" using a version token.

## Reusable prompt

```text
Apply the CQRS skill (.agents/skills/cqrs/SKILL.md).
Context: {{task card or question; links to PRD, ADRs, code paths}}
Constraints: {{approved thresholds, deadlines, allowed files}}
Decide whether CQRS is justified; if yes, design commands, projections, sync and the consistency strategy.
Return: Command model, read model designs, sync mechanism, consistency strategy..
Cite evidence (file:line, command output, source) for every claim; list open questions separately.
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.