一键导入
domain-driven-design
Event sourcing, aggregate patterns, bounded contexts, CQRS implementation, and distributed systems patterns
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Event sourcing, aggregate patterns, bounded contexts, CQRS implementation, and distributed systems patterns
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when designing Copilot agents, authoring agent definitions, creating skill folders, or scaffolding instruction files. Provides templates and conventions for the agent ecosystem.
Use when designing, reviewing, or evolving API contracts. Provides OpenAPI templates, breaking-change checklists, versioning decision trees, and governance checklists.
API authentication, authorization, input validation, rate limiting, and protection patterns
Scan legacy applications to discover project structure, NuGet/npm dependencies, database connection strings, external service bindings, framework versions, and migration complexity scores. Produces structured JSON, YAML, or Markdown inventory reports.
Use when designing systems, recording architecture decisions, evaluating technologies, or assessing architectural risks. Provides C4 diagram templates, ADR format, technology selection matrices, and risk registers.
Deploy, scale, and manage containerized applications on Azure Container Apps with Dapr, revision management, and advanced networking
| name | domain-driven-design |
| title | Domain-Driven Design & CQRS Patterns |
| description | Event sourcing, aggregate patterns, bounded contexts, CQRS implementation, and distributed systems patterns |
| compatibility | ["agent:architecture"] |
| metadata | {"domain":"architecture","maturity":"production","audience":["architect","backend-engineer"]} |
| allowed-tools | ["python","javascript","java"] |
Production patterns for DDD and CQRS implementation.
from dataclasses import dataclass
from enum import Enum
class OrderStatus(Enum):
PENDING = "pending"
CONFIRMED = "confirmed"
SHIPPED = "shipped"
@dataclass
class Money:
"""Value object - immutable."""
amount: float
currency: str
@dataclass
class Order:
"""Aggregate root - owns order lines."""
order_id: str
customer_id: str
status: OrderStatus
total_price: Money
items: list
def add_item(self, item):
"""Enforce invariant: Cannot modify shipped order."""
if self.status == OrderStatus.SHIPPED:
raise ValueError("Cannot modify shipped order")
self.items.append(item)
@dataclass
class DomainEvent:
aggregate_id: str
@dataclass
class OrderCreated(DomainEvent):
customer_id: str
total_price: float
class EventStore:
def append(self, event: DomainEvent):
"""Append event to immutable log."""
self.events.append(event)
def rebuild_aggregate(self, aggregate_id: str) -> Order:
"""Reconstruct state from events."""
events = [e for e in self.events if e.aggregate_id == aggregate_id]
# Replay events to rebuild state
return None
# Commands - modify state
class CreateOrderCommand:
pass
# Queries - read state
class GetOrderQuery:
pass
class OrderCommandHandler:
def handle_create_order(self, cmd: CreateOrderCommand):
# Modify state
pass
class OrderQueryHandler:
def handle_get_order(self, query: GetOrderQuery):
# Query read model
pass
class OrderSaga:
def start(self, order):
# Step 1: Reserve payment
payment_result = self.payment_service.reserve(order)
if not payment_result.success:
self.compensate_payment()
return
# Step 2: Reserve inventory
inventory_result = self.inventory_service.reserve(order)
if not inventory_result.success:
self.compensate_payment()
self.compensate_inventory()
return