ddd-tactical-patterns
Apply DDD tactical patterns in code using entities, value objects, aggregates, repositories, and domain events with explicit invariants.
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
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/ddd-tactical-patterns/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How ddd-tactical-patterns Compares
| Feature / Agent | ddd-tactical-patterns | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | easy | N/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
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
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
Cross-language patterns for memory-safe programming including RAII, ownership, smart pointers, and resource management.
dotnet-backend-patterns
Master C#/.NET patterns for building production-grade APIs, MCP servers, and enterprise backends with modern best practices (2024/2025).
cc-skill-backend-patterns
Backend architecture patterns, API design, database optimization, and server-side best practices for Node.js, Express, and Next.js API routes.
nerdzao-elite
Senior Elite Software Engineer (15+) and Senior Product Designer. Full workflow with planning, architecture, TDD, clean code, and pixel-perfect UX validation.
nerdzao-elite-gemini-high
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.
multi-platform-apps-multi-platform
Build and deploy the same feature consistently across web, mobile, and desktop platforms using API-first architecture and parallel implementation strategies.
monorepo-architect
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,
minecraft-bukkit-pro
Master Minecraft server plugin development with Bukkit, Spigot, and Paper APIs.
macos-spm-app-packaging
Scaffold, build, sign, and package SwiftPM macOS apps without Xcode projects.
legacy-modernizer
Refactor legacy codebases, migrate outdated frameworks, and implement gradual modernization. Handles technical debt, dependency updates, and backward compatibility.
i18n-localization
Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.
framework-migration-deps-upgrade
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