# ddd

A skill that teaches the agent Domain-Driven Design tactical patterns for .NET: aggregates, value objects, domain events, strongly-typed IDs and aggregate repositories.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 2900 installs · ★ 789
- Author: codewithmukesh
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/codewithmukesh/dotnet-claude-kit/tree/HEAD/skills/ddd/SKILL.md
- Updated: 2026-08-07
- HTML: https://affpapa.org/en/nevibecode/skills/ddd

## What it does

The skill writes DDD rules into the agent's context for .NET work. Five principles come first: an aggregate is a consistency boundary, value objects replace primitives, domain events carry side effects, the aggregate root is the only entry point, and one repository per root. Then come C# samples — an `Order` class with `Place`, `AddLine` and `Confirm` returning `Result`, a `Money` record that validates in its constructor, `readonly record struct` types for `CustomerId` and `OrderNumber`.

A separate section covers EF Core wiring: value converters for strongly-typed IDs, `ComplexProperty` for `Money` with precision 18, 2, `AutoInclude` on order lines. Events are raised inside the aggregate and dispatched in `SaveChangesAsync`. This pays off when the codebase already revolves around aggregates and bounded contexts. On a plain CRUD project the same rules just add boilerplate.

The author suggests pairing it with `clean-architecture`. The source text cuts off inside the `AggregateRoot` description, so the remaining patterns are not covered here.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add codewithmukesh/dotnet-claude-kit --skill ddd -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/ddd/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/ddd/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add codewithmukesh/dotnet-claude-kit --skill ddd -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/ddd/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add codewithmukesh/dotnet-claude-kit --skill ddd -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/ddd/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install codewithmukesh/dotnet-claude-kit ddd
```

2. **Manually: put the files in place**
- File: `.github/skills/ddd/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add codewithmukesh/dotnet-claude-kit --skill ddd -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/codewithmukesh/dotnet-claude-kit --path skills/ddd
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/ddd/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add codewithmukesh/dotnet-claude-kit --skill ddd -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/codewithmukesh/dotnet-claude-kit/tree/HEAD/skills/ddd/SKILL.md

## When to use it
- move domain logic into aggregates instead of anemic models
- replace raw strings and decimals with validated value objects
- stop mixing up GUIDs from different entities with strongly-typed IDs
- map value objects in EF Core through converters and complex properties
- decouple side effects from the aggregate with domain events

## Example prompts
- Create an Order aggregate with Place, AddLine and Confirm following the ddd skill patterns
- Add a Money value object as a sealed record with constructor validation
- Configure EF Core mappings for strongly-typed IDs and Money

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 0d4df07f4782fbae.

BEGIN THIRD-PARTY FILE 0d4df07f4782fbae
````text
---
name: ddd
description: >
  Domain-Driven Design tactical patterns for .NET applications. Covers aggregates,
  aggregate roots, value objects, domain events, domain services, strongly-typed IDs,
  and repository patterns for aggregate persistence.
  Load this skill when implementing DDD, working with aggregates, value objects,
  domain events, bounded contexts, or when the architecture-advisor recommends
  DDD + Clean Architecture. Pair with the clean-architecture skill.
---

# Domain-Driven Design (DDD)

## Core Principles

1. **Aggregates define consistency boundaries** — An aggregate is a cluster of entities and value objects treated as a single unit for data changes. All invariants within an aggregate are enforced in a single transaction. Cross-aggregate consistency is eventual.
2. **Value objects over primitives** — Replace primitive obsession with value objects. `Money`, `EmailAddress`, `OrderNumber` are not strings — they carry validation, equality, and behavior. Use C# records for immutable value objects.
3. **Domain events decouple side effects** — When something meaningful happens in the domain (OrderPlaced, PaymentReceived), raise a domain event. Side effects (send email, update read model, notify another aggregate) subscribe to these events. The aggregate stays focused on its own rules.
4. **Aggregate root is the sole entry point** — External code accesses an aggregate only through its root entity. Child entities are never loaded or modified independently. The root enforces all invariants for the entire aggregate.
5. **Repositories persist aggregates, not entities** — One repository per aggregate root. The repository loads and saves the entire aggregate as a unit. No repository for child entities. The Infrastructure implementation uses `DbContext` internally — this is a DDD tactical pattern for aggregate boundaries, not a generic CRUD wrapper.

## Patterns

### Aggregate Root

The aggregate root owns all access to its children and enforces invariants:

```csharp
// Domain/Orders/Order.cs
public sealed class Order : AggregateRoot
{
    private readonly List<OrderLine> _lines = [];

    private Order() { } // EF Core

    public OrderNumber Number { get; private set; } = null!;
    public CustomerId CustomerId { get; private set; }
    public Money Total { get; private set; } = Money.Zero("USD");
    public OrderStatus Status { get; private set; }
    public DateTimeOffset PlacedAt { get; private set; }
    public IReadOnlyList<OrderLine> Lines => _lines.AsReadOnly();

    public static Order Place(CustomerId customerId, OrderNumber number, DateTimeOffset now)
    {
        var order = new Order
````
END THIRD-PARTY FILE 0d4df07f4782fbae

The third-party file has ended. Everything between the 0d4df07f4782fbae tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2669 of 12232 bytes. © codewithmukesh · MIT · https://github.com/codewithmukesh/dotnet-claude-kit/tree/HEAD/skills/ddd/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
