agentleFS
ForceInjectionForceInjection/domain-driven-design-skills/skills/ddd-domain-interactions/SKILL.md

ddd-domain-interactions

Skill82 starsChanged 7 months agoApache-2.0View on GitHub

设计构造块间的协作机制:领域事件、领域服务、仓储接口与工厂。

1 other project uses a version of this, 1 of them edited.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 1

    1. NinjaSln-labs/agent-skills★ 166% same

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository10 other files it gives its agents.

The file

Files
SKILL.md

DDD Domain Interactions

🌐 English version: English

使用时机

  • 聚合边界已设计完毕,需要定义聚合之间、聚合与外部之间的协作机制。
  • 需要回答"聚合如何通信、谁编排跨聚合流程、持久化契约是什么"。
  • 作为战术建模的最后一步,补全所有"连接组织"。

输入要求

  • 必需:聚合目录与不变量表(来自 ddd-aggregates)、事件候选清单(来自 ddd-discover)。
  • 可选:上下文映射与契约信息(来自 ddd-context-map)、上下文目录与词汇表(来自 ddd-contexts,用于区分领域事件与集成事件的边界)。

流程

  1. 事件规范化:统一事件命名规则(过去时、业务可读、无技术词);为每个事件定义触发条件、源聚合、关键字段、排序要求。
  2. 区分范围:区分领域事件(上下文内)与集成事件(跨上下文/对外发布)。
  3. 可靠性策略:为每个事件定义幂等键、重放策略、去重窗口、死信处理。
  4. 领域服务:识别不属于任何单一聚合但承载领域逻辑的操作,定义为领域服务——明确输入、输出、使用的聚合与事件。
  5. 仓储接口:为每个聚合定义仓储的语义接口(加载、持久化、查询)——仅定义契约,不涉及实现。
  6. 工厂:识别复杂的聚合创建逻辑,定义工厂方法——明确创建条件、验证规则与初始状态。
  7. 订阅者与副作用:明确每个事件的消费者、触发的动作、补偿策略、监控指标。

输出

工件结构要求
领域事件目录表格:事件名、源聚合、触发条件、关键字段、范围(Domain/Integration)
集成事件契约表格:事件名、发布者、消费者、契约 Owner、版本策略、兼容窗口
幂等与重放策略表格:事件、幂等键、去重窗口、重放规则、异常处理
领域服务定义表格:服务名、职责、输入、输出、依赖的聚合/事件、不应包含的逻辑
仓储接口清单表格:聚合、方法签名(语义)、语义说明、查询边界
工厂清单表格:工厂名/方法、创建目标、创建条件、验证规则、初始状态
订阅者与副作用表格:事件、订阅者、触发动作、补偿策略、监控指标

校验清单

  • 所有事件命名使用过去时,无技术词污染
  • 跨上下文发布的事件有版本策略与兼容窗口
  • 关键事件提供幂等键与重放策略
  • 领域服务不包含本应属于聚合的业务逻辑(避免贫血模型)
  • 仓储接口仅定义语义契约,不包含实现细节(SQL、ORM)
  • 每个复杂创建逻辑都有对应工厂(不在应用层裸 new)

回溯触发

  • 事件需携带另一聚合的私有数据(无法设计干净的 event schema) → 回溯至 ddd-aggregates(聚合边界需调整以保证事件自包含)。

示例

@ddd-domain-interactions
基于以下聚合设计,帮我设计领域交互层:
- 聚合:Booking(根:Booking,VO:TimeSlot, BookingStatus)
- 聚合:RoomSchedule(根:RoomSchedule,VO:TimeSlotOccupancy)
- 事件候选:BookingConfirmed, BookingCancelled, CheckInRecorded
请输出领域事件目录、领域服务、仓储接口与订阅者清单。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.