Delegate independent tasks to specialized agents working concurrently with isolated context.
Aggregate Generator
acc-create-aggregate
Generates DDD Aggregates for PHP 8.5. Creates consistency boundaries with root entity, domain events, and invariant protection. Includes unit tests.
SKILL.md
Full skill instructions
Aggregate Generator
Generate DDD-compliant Aggregates with root, domain events, and tests.
Aggregate Characteristics
- Consistency boundary: All changes atomic
- Root entity: Single entry point
- Transactional consistency: Invariants always valid
- Domain events: Records what happened
- Encapsulation: Children accessed through root
- Identity: Referenced by root ID
Generation Process
Step 1: Generate Base AggregateRoot
Path: src/Domain/Shared/Aggregate/
AggregateRoot.php— Base class with event recording
Step 2: Generate Aggregate Root Entity
Path: src/Domain/{BoundedContext}/Entity/
{Name}.php— Main aggregate root
Step 3: Generate Child Entities (if needed)
Path: src/Domain/{BoundedContext}/Entity/
{ChildName}.php— Child entity inside aggregate
Step 4: Generate Domain Events
Path: src/Domain/{BoundedContext}/Event/
{Name}CreatedEvent.php{Name}{Action}Event.phpfor each behavior
Step 5: Generate Tests
Path: tests/Unit/Domain/{BoundedContext}/Entity/
File Placement
| 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/ |
Naming Conventions
| Component | Pattern | Example |
|---|---|---|
| Aggregate Root | {Name} | Order |
| Child Entity | {Parent}{Name} | OrderLine |
| Created Event | {Name}CreatedEvent | OrderCreatedEvent |
| State Event | {Name}{Action}Event | OrderConfirmedEvent |
Quick Template Reference
Base AggregateRoot
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;
}
}
Aggregate Root Entity
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(...));
}
}
Child Entity
final readonly class {ChildName}
{
public function __construct(
public {PropertyType} $property1,
public {PropertyType} $property2
) {}
public function total(): Money
{
return $this->unitPrice->multiply($this->quantity);
}
}
Design Rules
| 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-patterns to Avoid
| 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 |
References
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
More Other skills
brand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.
internal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).
Fundamental design principles for writing maintainable, testable Python code.
responsive-design
Modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first strategies.
Generate Playwright tests from scenarios using interactive browser exploration and validation.
Automated website exploration and test case generation using Playwright.
Modern React state management with Redux Toolkit, Zustand, Jotai, and React Query for every state category.
gdpr-data-handling
GDPR-compliant data handling with consent management, data subject rights, and privacy controls.
Python error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designing exception strategies, handling batch processing failures, or building robust APIs.
refactor-plan
Detailed multi-file refactor planning with safety checks and rollback guidance.
