Domain driven design

From bdfinst/agentic-dev-team · View interactive version

Domain driven design is an AI agent skill from the GitHub repository bdfinst/agentic-dev-team. Model software around the business domain. Use when designing bounded contexts, defining aggregates and value objects, mapping context relationships, or working with complex business logic. Apply before implementation to prevent model drift.

How to use this skill

Skill file

Domain-Driven Design (DDD)

Overview

Model software around the business domain. Collaborate with domain experts to build a shared understanding expressed in code through ubiquitous language, bounded contexts, and tactical patterns.

Strategic Patterns

Ubiquitous Language

Bounded Contexts

Context Mapping

Define explicit relationships between bounded contexts:

| Pattern | When to Use |

| --- | --- |

| Shared Kernel | Two contexts co-own a small, stable subset of the model |

| Anti-Corruption Layer | Protect your model from a messy or legacy external model |

| Customer/Supplier | Upstream context serves downstream; downstream can negotiate |

| Conformist | Downstream adopts upstream's model as-is (no negotiation power) |

| Open Host Service | Context exposes a well-defined protocol for many consumers |

| Published Language | Shared interchange format (e.g., industry standard schemas) |

| Separate Ways | No integration at all — the cheaper, more honest choice when the cost of integrating two contexts outweighs the benefit |

Distillation — Find the Core Domain

Not all of the model is equally valuable. Spend your best modeling effort where it earns the most.

Misallocation is the smell: elaborate custom code in a generic subdomain, or an anemic, neglected Core.

Tactical Patterns

Aggregates

Entities

Value Objects

Domain Events

Domain Services

Repositories

Factories

Specifications

Making Implicit Concepts Explicit

When a constraint, process, or policy is buried in conditionals and scattered across methods, the model is hiding a concept the domain expert already has a word for. Surface it:

| Hidden as | Surface it as |

| --- | --- |

| A repeated multi-clause if | A Specification or Policy object |

| A constraint enforced ad hoc in setters | An invariant the entity/aggregate guards |

| A multi-step business process in a service method | A named domain process or sequence of domain events |

| A primitive that always travels with rules (int balanceCents) | A Value Object (Money) that owns those rules |

Supple Design

The craft of refactoring toward deeper insight — design that is safe to change because it reveals intent and contains side effects. Apply to the Core Domain especially.

Knowledge Crunching & Model-Driven Design

When to Apply

| Situation | Approach |

| --- | --- |

| Complex, evolving business logic | Full tactical DDD (aggregates, events, services) |

| Simple CRUD with minimal logic | Skip tactical patterns; use DDD strategically (bounded contexts, ubiquitous language) |

| Legacy integration | Anti-Corruption Layer to protect new model |

| Multiple teams / services | Context mapping is essential |

Steps

1. Establish Ubiquitous Language

2. Define Bounded Contexts

3. Distill the Core

4. Select Tactical Patterns

5. Validate Model

Output

Report modeling decisions: bounded contexts identified, aggregate boundaries, context map relationships, and any violations of DDD constraints found in existing code. Be concise — use tables for context maps and violation lists; skip concept narration.

Constraints

Guidelines

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.