DDD Tactical Patterns

VerifiedSafe

Use DDD tactical patterns to structure code with entities, value objects, aggregates, repositories, and domain events. Focuses on enforcing invariants and keeping domain logic within domain objects. Ideal for moving from anemic models to behavior-rich domain models.

Sby Skills Guide Bot
DevelopmentIntermediate
1106/2/2026
Claude CodeCursorCopilot
#ddd#tactical#aggregates#value-objects#domain-events

Recommended for

Our review

This skill applies Domain-Driven Design tactical patterns in code using entities, value objects, aggregates, repositories, and domain events with explicit invariants.

Strengths

  • Guides translating domain rules into robust code structures.
  • Promotes aggregate design with explicit invariants.
  • Encourages rich domain objects over anemic models.
  • Defines clear boundaries for repositories and domain events.

Limitations

  • Does not cover deployment architecture or database selection.
  • Does not address transport protocols or infrastructure choices.
  • Should be paired with testing patterns to ensure invariant coverage.
When to use it

Use this skill when translating domain rules into code structures, designing aggregate boundaries, or refactoring an anemic model into behavior-rich domain objects.

When not to use it

Do not use if you are still defining strategic boundaries, the task is only API documentation or UI layout, or full DDD complexity is not justified.

Security analysis

Safe
Quality score88/100

The skill contains only instructional text about DDD tactical patterns and a static TypeScript example. It does not instruct any file system operations, network calls, or execution of commands, and there is no declared tool usage.

No concerns found

Examples

Model an aggregate with invariants
Help me design an Order aggregate in TypeScript with invariants: order must have at least one item, can only be submitted once, and status transitions are validated.
Refactor anemic model to rich domain objects
Refactor this User class to follow DDD patterns: make it an entity with behavior, validate email as a value object, and emit a UserRegistered event.

name: ddd-tactical-patterns description: Apply DDD tactical patterns in code using entities, value objects, aggregates, repositories, and domain events with explicit invariants. risk: safe source: self tags: [ddd, tactical, aggregates, value-objects, domain-events]

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

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