ddd-tactical-patterns

Apply DDD tactical patterns in code using entities, value objects, aggregates, repositories, and domain events with explicit invariants.

31,392 stars
Complexity: easy

About this skill

This skill empowers AI agents to assist developers in implementing robust and maintainable software using Domain-Driven Design (DDD) tactical patterns. It provides a structured approach to defining and applying core DDD concepts such as entities, value objects, aggregates, repositories, and domain events. By leveraging this skill, AI agents can help translate complex business rules into well-defined code structures, design clear aggregate boundaries, enforce explicit invariants, and guide the refactoring of anemic domain models into behavior-rich objects. It's designed to ensure code alignment with the business domain and promote better architectural practices.

Best use case

Guiding the implementation of complex business logic into well-structured, maintainable, and behavior-rich code based on Domain-Driven Design (DDD) principles, or assisting developers in understanding and applying these patterns.

Apply DDD tactical patterns in code using entities, value objects, aggregates, repositories, and domain events with explicit invariants.

The AI agent will provide structured guidance, explanations, or code suggestions that adhere to DDD tactical patterns. Users can expect to receive well-defined entities, value objects, aggregates, repositories, and domain events, designed with explicit invariants. This leads to improved code maintainability, testability, and a deeper alignment of the codebase with the business domain.

Practical example

Example input

Help me model a 'Booking' aggregate in C# for a hotel reservation system. It needs to include 'Reservation' entities, 'DateRange' value objects, and ensure no overlapping reservations. Also, suggest a basic 'BookingRepository' interface.

Example output

```csharp
// Value Object: DateRange
public record DateRange(DateTime StartDate, DateTime EndDate)
{
    public bool Overlaps(DateRange other) => StartDate < other.EndDate && EndDate > other.StartDate;
    // Invariants: Ensure StartDate <= EndDate
}

// Entity: Reservation (within Booking Aggregate)
public class Reservation
{
    public Guid Id { get; private set; }
    public DateRange Period { get; private set; }
    // ... other properties

    private Reservation() { /* For ORM */ }
    public Reservation(DateRange period) 
    {
        Id = Guid.NewGuid();
        Period = period;
        // Invariants: Specific to a single reservation, e.g., period must be in future
    }
}

// Aggregate Root: Booking
public class Booking
{
    public Guid Id { get; private set; }
    private List<Reservation> _reservations = new List<Reservation>();
    public IReadOnlyCollection<Reservation> Reservations => _reservations.AsReadOnly();

    private Booking() { /* For ORM */ }
    public Booking(Guid id)
    {
        Id = id;
    }

    public void AddReservation(Reservation newReservation)
    {
        // Aggregate Invariant: No overlapping reservations within this booking
        if (_reservations.Any(r => r.Period.Overlaps(newReservation.Period)))
        {
            throw new InvalidOperationException("New reservation overlaps with an existing reservation.");
        }
        _reservations.Add(newReservation);
        // Raise Domain Event: BookingReservationAdded
    }

    // Other methods that encapsulate business logic and maintain aggregate invariants
}

// Repository Interface: IBookingRepository
public interface IBookingRepository
{
    Task<Booking> GetByIdAsync(Guid id);
    Task AddAsync(Booking booking);
    Task UpdateAsync(Booking booking);
    Task DeleteAsync(Booking booking);
    // Consider methods for checking reservation availability across multiple bookings if needed outside the aggregate
}
```

This structure ensures `Booking` is the consistency boundary, handling invariants like overlapping reservations. `Reservation` is an entity owned by `Booking`, and `DateRange` is a simple, immutable value object.

When to use this skill

  • When translating complex domain rules into code structures.
  • When designing aggregate boundaries and defining their invariants.
  • When refactoring an anemic model into behavior-rich domain objects.
  • When defining repository contracts and establishing domain event boundaries.

When not to use this skill

  • When the strategic boundaries of the domain are still being defined.
  • When the task is solely related to API documentation or UI layout.
  • When the full complexity and overhead of DDD tactical patterns are not justified for the project scope.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/ddd-tactical-patterns/SKILL.md --create-dirs "https://raw.githubusercontent.com/sickn33/antigravity-awesome-skills/main/plugins/antigravity-awesome-skills-claude/skills/ddd-tactical-patterns/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/ddd-tactical-patterns/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How ddd-tactical-patterns Compares

Feature / Agentddd-tactical-patternsStandard Approach
Platform SupportClaudeLimited / Varies
Context Awareness High Baseline
Installation ComplexityeasyN/A

Frequently Asked Questions

What does this skill do?

Apply DDD tactical patterns in code using entities, value objects, aggregates, repositories, and domain events with explicit invariants.

Which AI agents support this skill?

This skill is designed for Claude.

How difficult is it to install?

The installation complexity is rated as easy. You can find the installation instructions above.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# DDD Tactical Patterns

## Use this skill when

- Translating domain rules into code structures.
- Designing aggregate boundaries and invariants.
- Refactoring an anemic model into behavior-rich domain objects.
- Defining repository contracts and domain event boundaries.

## Do not use this skill when

- You are still defining strategic boundaries.
- The task is only API documentation or UI layout.
- Full DDD complexity is not justified.

## Instructions

1. Identify invariants first and design aggregates around them.
2. Model immutable value objects for validated concepts.
3. Keep domain behavior in domain objects, not controllers.
4. Emit domain events for meaningful state transitions.
5. Keep repositories at aggregate root boundaries.

If detailed checklists are needed, open `references/tactical-checklist.md`.

## Example

```typescript
class Order {
  private status: "draft" | "submitted" = "draft";

  submit(itemsCount: number): void {
    if (itemsCount === 0) throw new Error("Order cannot be submitted empty");
    if (this.status !== "draft") throw new Error("Order already submitted");
    this.status = "submitted";
  }
}
```

## Limitations

- This skill does not define deployment architecture.
- It does not choose databases or transport protocols.
- It should be paired with testing patterns for invariant coverage.

Related Skills

memory-safety-patterns

31392
from sickn33/antigravity-awesome-skills

Cross-language patterns for memory-safe programming including RAII, ownership, smart pointers, and resource management.

Software DevelopmentClaude

dotnet-backend-patterns

31392
from sickn33/antigravity-awesome-skills

Master C#/.NET patterns for building production-grade APIs, MCP servers, and enterprise backends with modern best practices (2024/2025).

Software DevelopmentClaude

cc-skill-backend-patterns

31392
from sickn33/antigravity-awesome-skills

Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.

Software DevelopmentClaude

nerdzao-elite

31392
from sickn33/antigravity-awesome-skills

Senior Elite Software Engineer (15+) and Senior Product Designer. Full workflow with planning, architecture, TDD, clean code, and pixel-perfect UX validation.

Software DevelopmentClaude

nerdzao-elite-gemini-high

31392
from sickn33/antigravity-awesome-skills

Modo Elite Coder + UX Pixel-Perfect otimizado especificamente para Gemini 3.1 Pro High. Workflow completo com foco em qualidade máxima e eficiência de tokens.

Software DevelopmentClaudeGemini

multi-platform-apps-multi-platform

31392
from sickn33/antigravity-awesome-skills

Build and deploy the same feature consistently across web, mobile, and desktop platforms using API-first architecture and parallel implementation strategies.

Software DevelopmentClaude

monorepo-architect

31392
from sickn33/antigravity-awesome-skills

Expert in monorepo architecture, build systems, and dependency management at scale. Masters Nx, Turborepo, Bazel, and Lerna for efficient multi-project development. Use PROACTIVELY for monorepo setup,

Software DevelopmentClaude

minecraft-bukkit-pro

31392
from sickn33/antigravity-awesome-skills

Master Minecraft server plugin development with Bukkit, Spigot, and Paper APIs.

Software DevelopmentClaude

macos-spm-app-packaging

31392
from sickn33/antigravity-awesome-skills

Scaffold, build, sign, and package SwiftPM macOS apps without Xcode projects.

Software DevelopmentClaude

legacy-modernizer

31392
from sickn33/antigravity-awesome-skills

Refactor legacy codebases, migrate outdated frameworks, and implement gradual modernization. Handles technical debt, dependency updates, and backward compatibility.

Software DevelopmentClaude

i18n-localization

31392
from sickn33/antigravity-awesome-skills

Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.

Software DevelopmentClaude

framework-migration-deps-upgrade

31392
from sickn33/antigravity-awesome-skills

You are a dependency management expert specializing in safe, incremental upgrades of project dependencies. Plan and execute dependency updates with minimal risk, proper testing, and clear migration pa

Software DevelopmentClaude