New to Claude Skills? Learn how to install them →

Druvnet on GitHub

DDD Aggregate

Free

Efficiently scaffold aggregate roots for your domain model.

by ruvnet67.6k stars on ruvnet/ruflo
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What DDD Aggregate does

The DDD Aggregate skill provides a structured approach to scaffold aggregate roots within a bounded context in your application. By automating the creation of essential components such as entities, value objects, repository interfaces, and domain events, this skill helps streamline your development process when modeling new business concepts. This is particularly beneficial when you need to enforce invariants and maintain consistency across your domain model.

When you invoke this skill, it requires you to specify the context and aggregate name in kebab-case format. The skill first validates the existence of the specified context, ensuring that your domain structure is in place. It then proceeds to generate the necessary files, including a TypeScript class for the aggregate root that includes validation logic and business rules, as well as value objects that encapsulate specific domain characteristics.

Furthermore, the DDD Aggregate skill creates a repository interface that defines essential methods for interacting with the aggregate, alongside domain events that represent significant changes in state. To ensure quality, it also generates unit test stubs for the entity, allowing you to easily implement tests for invariants and behaviors. By updating barrel exports and storing the new aggregate in the domain model graph, this skill integrates seamlessly into your existing architecture.

This skill is ideal for developers working within a Domain-Driven Design (DDD) framework who are looking to efficiently scaffold new aggregates while maintaining best practices in their codebase. It reduces boilerplate code and accelerates the setup of new domain concepts, enabling you to focus on building features rather than managing repetitive tasks.

When to use it

Use this skill when you need to add a new aggregate to an existing bounded context or when modeling a new business concept that requires a structured approach.

When not to use it

This skill may not be suitable for projects that do not follow DDD principles or for simple applications that do not require complex domain modeling.

What you can build with it

Adding a New Aggregate

When introducing a new business concept, use this skill to scaffold the aggregate root and its components quickly.

Maintaining DDD Principles

Ensure that your application adheres to Domain-Driven Design principles by using this skill to generate consistent and structured code.

Speeding Up Development

Reduce the time spent on repetitive tasks by automating the scaffolding of aggregate roots and related components.

How to install DDD Aggregate

View source

1. Install with the skills CLI

npx skills add ruvnet/ruflo/ddd-aggregate --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by ruvnet

Scaffold a complete aggregate root inside a bounded context.

Parse $ARGUMENTS as <context-name> <aggregate-name> (both kebab-case). The context must already exist under src/.

Steps

  1. Validate: Confirm src/<context>/domain/ exists. If not, suggest running /ddd-context <context> first.

  2. Pre-task hook: npx @claude-flow/cli@latest hooks pre-task --description "DDD aggregate: <aggregate-name> in <context>"

  3. Create aggregate root entity:

    • File: src/<context>/domain/entities/<aggregate-name>.entity.ts
    • Include: unique ID field, constructor with invariant validation, domain methods that enforce business rules, equals() based on identity
    • Export a TypeScript class extending or implementing a base AggregateRoot interface
  4. Create value objects:

    • File: src/<context>/domain/value-objects/<aggregate-name>-id.value-object.ts
    • Include: immutable ID value object with factory method and validation
    • Add additional value objects as properties of the aggregate suggest them
  5. Create repository interface:

    • File: src/<context>/domain/repositories/<aggregate-name>.repository.ts
    • Include: findById, save, delete methods
    • Use the aggregate root and its ID value object as types
    • This is an interface only -- no implementation (infrastructure concern)
  6. Create domain events:

    • File: src/<context>/domain/events/<aggregate-name>-created.event.ts
    • File: src/<context>/domain/events/<aggregate-name>-updated.event.ts
    • Include: event name (past tense), timestamp, aggregate ID, payload
  7. Create unit test stubs:

    • File: src/<context>/domain/entities/<aggregate-name>.entity.test.ts
    • Include: test cases for construction invariants, domain methods, equality
    • Use describe/it with should [behavior] when [condition] names
  8. Update barrel exports: Add new files to the relevant index.ts barrel files.

  9. Store in domain model graph:

    mcp__plugin_ruflo-core_ruflo__agentdb_hierarchical-store --parent "context:<context>" --child "aggregate:<aggregate-name>" --relation "contains"
    mcp__plugin_ruflo-core_ruflo__memory_store --key "ddd-aggregate-<context>-<aggregate-name>" --value "AGGREGATE_SUMMARY" --namespace tasks
    
  10. Post-task hook: npx @claude-flow/cli@latest hooks post-task --task-id "ddd-aggregate-<aggregate-name>" --success true --train-neural true

Frequently asked questions about DDD Aggregate

Similar skills