joabgonzalez/ai-agents-skills/domain-driven-design
Claude Code and agent skill by joabgonzalez/ai-agents-skills
- community
Checking that the SKILL.md file is still in the repository.
Domain-Driven Design for complex business domains. Trigger: When modeling business rules, defining bounded contexts, or building ubiquitous language.
Install
npx vskill@latest install joabgonzalez/ai-agents-skills/domain-driven-designSKILL.md
The same SKILL.md was published earlier as joabgonzalez/ai-agents-skills/domain-driven-design.
Domain-Driven Design (DDD)
Builds software that closely models complex business domains through shared language between developers and domain experts. Apply to complex business logic; overkill for simple CRUD.
When to Use
- Complex business rules with many domain interactions
- Multiple teams working on different business areas
- Codebase has concepts that mean different things in different contexts
- Long-lived projects where domain knowledge is central
Don't use for:
- Simple CRUD without real business logic
- Small services (<200 LOC)
- Tight deadlines with no team DDD experience
Critical Patterns
✅ REQUIRED: Ubiquitous Language
Use domain terms in code, docs, and conversations. Eliminate technical jargon from domain model.
✅ REQUIRED: Bounded Context
Explicit boundary within which a model is valid. Same word can mean different things in different contexts.
Don't force a single Product model across all contexts. Each context has its own model.
✅ REQUIRED: Entity
Object with identity that persists over time. Two entities with the same attributes are NOT the same entity if their IDs differ.
- Has a unique, stable identity (never changes)
- Mutable — attributes can change across its lifecycle
- Equality is identity-based, not attribute-based
Entity vs Value Object: Entity = has lifecycle and identity (User, Order, Product). Value Object = defined entirely by its attributes (Money, Email, Address).
✅ REQUIRED: Aggregate + Aggregate Root
Cluster of objects treated as a unit. Only access internals through the Aggregate Root.
✅ REQUIRED: Value Objects
Objects defined entirely by their attributes. No identity, no mutable state. Two Value Objects with the same attributes are always equal and interchangeable.
Key characteristics: immutable (return new instance to "change"), self-validating (throw in constructor), side-effect-free operations, conceptual whole (Money = amount + currency, never just a number).
✅ REQUIRED: Domain Events
Capture significant domain occurrences. Decouple side effects from domain logic.
✅ REQUIRED: Repository — Abstract Persistence
Interface that hides database details from the domain. Domain only knows about the interface; infrastructure implements it.
✅ REQUIRED: Domain Service — Cross-Aggregate Logic
Stateless service for business logic that doesn't naturally belong to a single entity or value object.
❌ NEVER: Anemic Domain Model
Objects that are only data containers with no behavior. Moves business logic to services, destroying the domain model.
Decision Tree
Example
Order aggregate with value objects, a domain event, and a repository interface.
Patterns applied: value object (Money), aggregate root (Order) protecting invariants, domain event (OrderConfirmedEvent), repository interface (infrastructure implements it).
Edge Cases
Aggregate size: Too-large aggregates cause contention (everything locks on Order). Too-small aggregates lose invariant protection. Design around business transactions, not data.
Context boundaries vs microservices: Bounded Contexts are logical, not necessarily microservice boundaries. One service can contain multiple contexts; one context can span services.
DDD without OOP: DDD applies to functional code too. Bounded contexts = modules; aggregates = immutable records with pure functions; domain events = typed messages.
Ubiquitous Language drift: Language agreed at project start diverges over time as business evolves. Regularly revisit with domain experts and update code to match.
Resources
Tactical pattern references:
- entity.md — Identity-based equality, lifecycle, Entity vs Value Object
- value-objects.md — Immutability, self-validation, equality contract, conceptual whole
- aggregate.md — Consistency boundaries, invariant enforcement, root access rules
- domain-events.md — Facts, naming conventions, event bus, eventual consistency
- repository.md — Persistence abstraction, interface vs implementation, unit of work
- domain-service.md — Cross-aggregate logic, stateless services, when to extract
- advanced-patterns.md — Anti-Corruption Layer, Sagas, Context Mapping
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/domain-driven-design/SKILL.md
Popularity
- Repository stars
- 9
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/joabgonzalez/ai-agents-skills/domain-driven-design)