{"id":"cqrs-implementation","name":"cqrs-implementation","summary":"スケーラブルなアーキテクチャ向けにコマンドクエリ責任分離を実装します。読み書きモデルの分離、クエリ性能の最適化、イベントソースシステムの構築に活用します。","body":"# CQRS Implementation\n\nComprehensive guide to implementing CQRS (Command Query Responsibility Segregation) patterns.\n\n## When to Use This Skill\n\n- Separating read and write concerns\n- Scaling reads independently from writes\n- Building event-sourced systems\n- Optimizing complex query scenarios\n- Different read/write data models needed\n- High-performance reporting requirements\n\n## Core Concepts\n\n### 1. CQRS Architecture\n\n```\n                    ┌─────────────┐\n                    │   Client    │\n                    └──────┬──────┘\n                           │\n              ┌────────────┴────────────┐\n              │                         │\n              ▼                         ▼\n       ┌─────────────┐          ┌─────────────┐\n       │  Commands   │          │   Queries   │\n       │    API      │          │    API      │\n       └──────┬──────┘          └──────┬──────┘\n              │                         │\n              ▼                         ▼\n       ┌─────────────┐          ┌─────────────┐\n       │  Command    │          │   Query     │\n       │  Handlers   │          │  Handlers   │\n       └──────┬──────┘          └──────┬──────┘\n              │                         │\n              ▼                         ▼\n       ┌─────────────┐          ┌─────────────┐\n       │   Write     │─────────►│    Read     │\n       │   Model     │  Events  │   Model     │\n       └─────────────┘          └─────────────┘\n```\n\n### 2. Key Components\n\n| Component           | Responsibility                  |\n| ------------------- | ------------------------------- |\n| **Command**         | Intent to change state          |\n| **Command Handler** | Validates and executes commands |\n| **Event**           | Record of state change          |\n| **Query**           | Request for data                |\n| **Query Handler**   | Retrieves data from read model  |\n| **Projector**       | Updates read model from events  |\n\n## Templates and detailed worked examples\n\nFull template library and detailed worked examples live in `references/details.md`. Read that file when you need the concrete templates.\n\n## Best Practices\n\n### Do's\n\n- **Separate command and query models** - Different needs\n- **Use eventual consistency** - Accept propagation delay\n- **Validate in command handlers** - Before state change\n- **Denormalize read models** - Optimize for queries\n- **Version your events** - For schema evolution\n\n### Don'ts\n\n- **Don't query in commands** - Use only for writes\n- **Don't couple read/write schemas** - Independent evolution\n- **Don't over-engineer** - Start simple\n- **Don't ignore consistency SLAs** - Define acceptable lag","author":"@wshobson","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/wshobson/agents/tree/main/plugins/backend-development/skills/cqrs-implementation","license":"MIT","category":"writing","lang":"en","tokens":610,"stars":0,"calls30d":1,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/details.md","size":12656,"sha256":"ecdf4fe73147a7b6cd0147dfec957f02afb9a7e04ead29534faebe92ddd7b6aa"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":false,"networkEndpoints":[]}}