create-aggregate

为 PHP 8.4 生成领域驱动设计(DDD)聚合。通过定义根实体、领域事件和不变性保护来创建一致性边界,并包含单元测试。

仓库最近推送
GitHub Stars
109
Forks
26
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-aggregate":https://skillpi.com/zh/skills/deepskill-11c3a72caeeb5610cb27ffb07e9d2d5fb0f55aee72d821a64702970183d9c465。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

为 PHP 8.4 生成领域驱动设计(DDD)聚合。通过定义根实体、领域事件和不变性保护来创建一致性边界,并包含单元测试。

0 下载

介绍来源: third_party · dykyi-roman · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
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

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值75/100

亮点

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

亮点

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

待提升项

  • 缺少 When to Use 章节 原报告严重程度:轻微

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

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

亮点

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

待提升项

  • 未说明实际调用方式和异常处理 原报告严重程度:重大

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

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

亮点

  • 提供了完整的 AggregateRoot 基类、实体、子实体、事件和测试模板
  • 涵盖主要设计规则和反模式,指导用户避免常见错误
证据可验 (前四项均值)80/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

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

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。