create-aggregate

Generate DDD aggregates for PHP 8.4. Create consistency boundaries by defining aggregate roots, domain events, and invariants protection, and include unit tests.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "create-aggregate" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-11c3a72caeeb5610cb27ffb07e9d2d5fb0f55aee72d821a64702970183d9c465. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Generate DDD aggregates for PHP 8.4. Create consistency boundaries by defining aggregate roots, domain events, and invariants protection, and include unit tests.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Generates DDD Aggregates for PHP 8.4. Creates consistency boundaries with root entity, domain events, and invariant protection. Includes unit tests.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: create-aggregate
description: Generates DDD Aggregates for PHP 8.4. Creates consistency boundaries with root entity, domain events, and invariant protection. Includes unit tests.

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/

  1. AggregateRoot.php — Base class with event recording

Step 2: Generate Aggregate Root Entity

Path: src/Domain/{BoundedContext}/Entity/

  1. {Name}.php — Main aggregate root

Step 3: Generate Child Entities (if needed)

Path: src/Domain/{BoundedContext}/Entity/

  1. {ChildName}.php — Child entity inside aggregate

Step 4: Generate Domain Events

Path: src/Domain/{BoundedContext}/Event/

  1. {Name}CreatedEvent.php
  2. {Name}{Action}Event.php for 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 templates
  • references/examples.md — Order aggregate with OrderLine, events, and tests

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • 为 PHP 8.4 提供完整的 DDD 聚合生成方案,涵盖根实体、领域事件、不变性保护和单元测试
  • 适用于中大型 PHP 项目架构设计,具有明确的技术实用价值
Trigger Precision85/100

Highlights

  • 触发词精准覆盖 DDD、Aggregate、PHP 8.4、domain events 等核心概念
  • description 位置正确且内容完整,边界清晰
Structure and Standards90/100

Areas to improve

  • 缺少 When to Use 章节 Reported severity: Minor

    文档未明确说明适用场景和使用时机

    Recommendation: 建议添加 When to Use 章节,说明何时应使用此 Skill 生成聚合

Highlights

  • 结构完整,包含生成流程、文件路径、命名规范、模板参考、设计规则和反模式
  • 提供端到端代码示例和完整 frontmatter
Execution Reliability70/100

Areas to improve

  • 未说明实际调用方式和异常处理 Reported severity: Major

    文档提供了模板和规范,但未说明如何实际触发生成(如 CLI 命令或配置),也未覆盖常见异常(如路径不存在、命名冲突)

    Recommendation: 建议补充实际调用示例和异常处理机制,提升执行可靠性

Highlights

  • 提供了完整的 AggregateRoot 基类、实体、子实体、事件和测试模板
  • 涵盖主要设计规则和反模式,指导用户避免常见错误
Evidence Verifiability (mean of the first four)80/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.