Help us improve
Share bugs, ideas, or general feedback.
How this skill is triggered — by the user, by Claude, or both
Slash command
/acc:create-aggregateThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generate DDD-compliant Aggregates with root, domain events, and tests.
Generates DDD-compliant Repository interfaces in Domain layer and Doctrine implementations in Infrastructure for PHP 8.4. Includes optional in-memory repos and integration tests.
Implements Domain-Driven Design tactical patterns for .NET: aggregates, roots, value objects, domain events, services, typed IDs, repositories. For DDD aggregates, events, bounded contexts.
Generates .NET domain entities following DDD principles with factory methods, private setters, domain events, and proper encapsulation. Supports aggregate roots, child entities, and value objects.
Share bugs, ideas, or general feedback.
Generate DDD-compliant Aggregates with root, domain events, and tests.
Path: src/Domain/Shared/Aggregate/
AggregateRoot.php — Base class with event recordingPath: src/Domain/{BoundedContext}/Entity/
{Name}.php — Main aggregate rootPath: src/Domain/{BoundedContext}/Entity/
{ChildName}.php — Child entity inside aggregatePath: src/Domain/{BoundedContext}/Event/
{Name}CreatedEvent.php{Name}{Action}Event.php for each behaviorPath: tests/Unit/Domain/{BoundedContext}/Entity/
| Component | Path |
|---|---|
| Base AggregateRoot | src/Domain/Shared/Aggregate/ |
| Aggregate Entity | src/Domain/{BoundedContext}/Entity/ |
| Child Entities | src/Domain/{BoundedContext}/Entity/ |
| Domain Events | src/Domain/{BoundedContext}/Event/ |
| Unit Tests | tests/Unit/Domain/{BoundedContext}/Entity/ |
| Component | Pattern | Example |
|---|---|---|
| Aggregate Root | {Name} | Order |
| Child Entity | {Parent}{Name} | OrderLine |
| Created Event | {Name}CreatedEvent | OrderCreatedEvent |
| State Event | {Name}{Action}Event | OrderConfirmedEvent |
abstract class AggregateRoot
{
private array $events = [];
protected function recordEvent(DomainEvent $event): void
{
$this->events[] = $event;
}
public function releaseEvents(): array
{
$events = $this->events;
$this->events = [];
return $events;
}
}
final class {Name} extends AggregateRoot
{
private {Name}Status $status;
private function __construct(
private readonly {Name}Id $id,
{properties}
) {
$this->status = {Name}Status::Draft;
}
public static function create({Name}Id $id, {params}): self
{
$aggregate = new self($id, {args});
$aggregate->recordEvent(new {Name}CreatedEvent(...));
return $aggregate;
}
public function {behavior}({params}): void
{
$this->ensureValidState();
// Apply change
$this->recordEvent(new {Name}{Behavior}Event(...));
}
}
final readonly class {ChildName}
{
public function __construct(
public {PropertyType} $property1,
public {PropertyType} $property2
) {}
public function total(): Money
{
return $this->unitPrice->multiply($this->quantity);
}
}
| Rule | Good | Bad |
|---|---|---|
| Transaction Boundary | One aggregate per transaction | Multiple aggregates |
| Reference | By ID only | Full entity reference |
| Size | Small, focused | Large with many collections |
| Invariants | Always valid | Can be in invalid state |
| Events | Record all state changes | No event recording |
| Anti-pattern | Problem | Solution |
|---|---|---|
| Large Aggregate | Performance issues | Split into smaller aggregates |
| Entity References | Tight coupling | Use IDs only |
| Public Setters | No invariant protection | Use behavior methods |
| Missing Events | Can't track history | Record event for each change |
| No Root | Multiple entry points | Single root entity |
For complete PHP templates and examples, see:
references/templates.md — AggregateRoot, Entity, Child Entity, Test templatesreferences/examples.md — Order aggregate with OrderLine, events, and tests