architecture-domain-driven-design
Use when the user asks about DDD, domain-driven design, bounded contexts, aggregates and aggregate roots, ubiquitous language, context maps, anti-corruption…
от j4flmao★ 47 звёзд на GitHub
Установить architecture-domain-driven-design в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Domain-Driven Design
Purpose
DDD aligns software structure with the business: a shared language inside explicit boundaries, models that enforce business invariants, and deliberate translation where contexts meet. Use it where domain complexity is the main risk (pricing, underwriting, logistics, billing). For simple CRUD, plain layered code is cheaper.
Agent Protocol
Trigger
"DDD", "bounded context", "aggregate", "aggregate root", "entity vs value object", "domain event", "context map", "anti-corruption layer", "ubiquitous language", "event storming".
Input Context
- Business capabilities and processes; domain experts' vocabulary.
- Current pain: tangled models, inconsistent rules, overloaded terms.
- Team structure (contexts usually map to team ownership).
- Persistence and integration constraints.
Output Artifact
Strategic map (subdomains, contexts, relationships) and/or tactical model (aggregates with invariants, value objects, events, repository interfaces).
Response Format
Subdomains: {core|supporting|generic}: {name}
Contexts: {name} owns {terms}; team {x}
Context map: {upstream} -> {downstream} [{pattern}]
Aggregate: {Root} invariants: {list}; references others by id
Events: {PastTenseName}(fields)
Completion Criteria
- Each term defined per context (no global "User"/"Product" model).
- Every aggregate lists the invariants it protects.
- One aggregate modified per transaction; others updated via events.
- Context relationships named with a context-map pattern.
Strategic Design
Subdomains: core (competitive advantage: invest, custom build), supporting (needed, specific: build simply), generic (commodity: buy/SaaS, e.g. auth, payments).
Bounded context: a boundary within which a model and its language are consistent. "Product" in Catalog (description, images), Inventory (SKU, quantity, location), and Pricing (price lists, discounts) are different models that share an identifier.
Context map patterns
| Pattern | Relationship |
|---|---|
| Partnership | Two teams coordinate releases jointly |
| Shared Kernel | Small shared model owned by both (keep tiny) |
| Customer/Supplier | Downstream needs influence upstream's roadmap |
| Conformist | Downstream adopts upstream model as-is |
| Anti-Corruption Layer (ACL) | Downstream translates upstream model into its own terms |
| Open Host Service + Published Language | Upstream offers a stable, documented API/schema for many consumers |
| Separate Ways | No integration; duplicate where cheaper |
Event Storming (Brandolini): domain experts and engineers place domain events (orange) on a timeline, then commands, actors, policies, and aggregates; clusters suggest context boundaries.
Tactical Design
| Building block | Identity | Mutability | Example |
|---|---|---|---|
| Entity | Has id; equality by id | Mutable via methods | Order |
| Value object | No id; equality by value | Immutable | Money, Address, DateRange |
| Aggregate | Cluster with one root; consistency boundary | Changed only through root | Order + OrderLine |
| Domain event | Immutable fact | Immutable | OrderPlaced |
| Repository | Loads/saves whole aggregates | n/a | OrderRepository |
| Domain service | Logic not belonging to one entity | Stateless | PricingService |
Aggregate rules (Vernon)
- Protect true invariants inside the boundary.
- Design small aggregates.
- Reference other aggregates by identity only.
- Use eventual consistency (domain events) outside the boundary; modify one aggregate per transaction.
Example (TypeScript)
export class Money {
private constructor(readonly cents: number, readonly currency: string) {}
static of(cents: number, currency: string): Money {
if (!Number.isInteger(cents) || cents < 0) throw new RangeError(`invalid amount: ${cents}`);
return new Money(cents, currency);
}
add(other: Money): Money {
if (other.currency !== this.currency) {
throw new Error(`currency mismatch: ${this.currency} vs ${other.currency}`);
}
return new Money(this.cents + other.cents, this.currency);
}
}
type OrderStatus = "draft" | "placed" | "cancelled";
export type OrderEvent =
| { type: "OrderPlaced"; orderId: string; customerId: string; totalCents: number; at: Date };
interface OrderLine { readonly sku: string; readonly qty: number; readonly unitPrice: Money }
export class Order {
private lines: OrderLine[] = [];
private status: OrderStatus = "draft";
private pending: OrderEvent[] = [];
constructor(readonly id: string, readonly customerId: string, private readonly currency: string) {}
addLine(sku: string, qty: number, unitPrice: Money): void {
if (this.status !== "draft") throw new Error(`order ${this.id} is ${this.status}; cannot add lines`);
if (qty <= 0) throw new RangeError(`qty must be positive, got ${qty}`);
if (unitPrice.currency !== this.currency) throw new Error("line currency differs from o
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл architecture-domain-driven-design?
Use when the user asks about DDD, domain-driven design, bounded contexts, aggregates and aggregate roots, ubiquitous language, context maps, anti-corruption layers, event storming or value objects. Produces strategic and tactical domain models. Not for simple CRUD apps or folder layering (use backend-clean-architecture) or service decomposition (use microservices).
Как установить скилл architecture-domain-driven-design?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл architecture-domain-driven-design запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
AnthropicGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
webapp-testing
AnthropicToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
brand-guidelines
AnthropicApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
web-artifacts-builder
AnthropicSuite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…