domain-driven-design
Domain-Driven Design patterns for TypeScript. Use when implementing ubiquitous language, value objects, entities, aggregates, domain events, domain services…
от citypaul★ 764 звезды на GitHub
Установить domain-driven-design в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Domain-Driven Design (DDD)
This skill applies only to projects that have opted in to DDD. Do not apply these patterns to projects that use a different approach.
For hexagonal architecture (ports and adapters), load the hexagonal-architecture skill. DDD and hexagonal architecture are complementary but independent — a project may use one without the other.
Use the structure-codebase skill when designing or changing physical placement. It keeps bounded context, feature/use-case cohesion, package enforcement, and any opted-in hexagonal inside/outside boundary as separate structural axes. If physical restructuring is not requested, preserve the repo's existing layout while keeping domain logic isolated.
Deep-dive resources are in the resources/ directory. Load them on demand:
| Resource | Load when... |
|---|---|
aggregate-design.md |
Designing or splitting aggregates, sizing questions, optimistic locking |
domain-services.md |
Unsure if logic is a domain service vs use case, naming conventions |
domain-events.md |
Cross-aggregate coordination, Decider pattern, event dispatch (outbox), process managers |
bounded-contexts.md |
Drawing context boundaries, integrating with external systems (ACL), context mapping |
error-modeling.md |
Deciding between result types and exceptions, error propagation |
testing-by-layer.md |
Writing tests for DDD code, property-based testing for invariants |
references.md |
Checking focused source rationale for DDD, layer ownership, and testing |
For authoritative sources, see resources/references.md.
When to Use DDD
DDD adds value for complex domains with rich business rules. Not every project needs it.
Use DDD when:
- Domain has complex business rules and invariants
- Multiple stakeholders with domain expertise
- Business logic is the core differentiator
- Terms have specific, important meanings
Don't use DDD when:
- Simple CRUD with no business rules
- Technical/infrastructure-focused projects
- No domain expert to consult
Start simple and evolve: Begin with ubiquitous language (glossary) and value objects. Add aggregates, domain events, and bounded contexts only when the domain demands it. Your first model will be wrong — that's fine. The goal is to learn quickly and refactor toward deeper insight.
Core Principle
The code must speak the language of the domain. The repository's declared glossary is the naming authority for each bounded context. When naming a declared concept, use its canonical spelling and capitalization in types, functions, variables, and tests. A concept absent from the glossary is not automatically approved or forbidden; it is not yet agreed. Plans, research, comments, conversations, and existing code may reveal candidate vocabulary, but they cannot silently canonize it.
Domain models evolve. The first model is never the final model. As understanding deepens through conversations with domain experts and building working software, the model should change — types get renamed, aggregates get split or merged, new concepts emerge. This is expected and ideal. A model that never changes is either perfect (unlikely) or stagnant (the team stopped learning). TDD and behavioral tests make this evolution safe — rename a concept, update the glossary, and the tests tell you what needs to change.
Where Does This Code Belong?
This is the most common decision in DDD. When unsure, use this framework:
The roles below are logical placement guidance. Use structure-codebase to choose their physical folders and packages.
| Question | If yes → | If no ↓ |
|---|---|---|
| Does it enforce a business rule or compute a business value? | Domain policy (entity function, value object, or domain service) | ↓ |
| Does it orchestrate domain operations without owning the rules? | Application policy / use case | ↓ |
| Does it format, transform, or prepare data for display? | Presentation code; in hexagonal architecture, often at the driving edge | ↓ |
| Does it talk to an external system (DB, API, file system)? | Infrastructure/integration code; in hexagonal architecture, a driven adapter implements an inside-owned port | ↓ |
| Is it framework-specific glue (route handler, middleware)? | Framework entrypoint; in hexagonal architecture, a driving adapter | — |
The purity test is necessary but not sufficient. A pure function that formats a date for display does not belong in domain policy just because it's pure. The question is always: "Is this a business rule?"
// ❌ Pure but NOT domain — formats for human display
export const formatEventDate = (date: string | null) =>
date ? format(parseISO(date), "MMMM d, yyyy") : undefined;
// → Belongs in presentation code; a hexagonal app may place it at the driving edge
// ✅ Pure AND domain — business rule that affects behavior
// The application supplies current time as data; domain code does n
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- resources/aggregate-design.md
- resources/bounded-contexts.md
- resources/domain-events.md
- resources/domain-services.md
- resources/error-modeling.md
- resources/references.md
- resources/testing-by-layer.md
FAQ
Что делает скилл domain-driven-design?
Domain-Driven Design patterns for TypeScript. Use when implementing ubiquitous language, value objects, entities, aggregates, domain events, domain services, or bounded contexts. Only applies to projects that explicitly use DDD. Do NOT use for simple CRUD or projects without domain modeling.
Как установить скилл domain-driven-design?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл 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…