Ddd Aggregates logo

Ddd Aggregates

Organization
ForceInjection
ddd-aggregates

从不变量出发设计聚合边界:聚合根、实体、值对象、事务边界与跨聚合一致性策略。

Overview

PublisherForceInjection
Repositorydomain-driven-design-skills
Skill nameddd-aggregates
Stars
99
Forks
16
Bundled files
1
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by ForceInjection on GitHub. Read the source before you install it.

Installation

Install the Ddd Aggregates AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/ForceInjection/domain-driven-design-skills/tree/main/skills/ddd-aggregates
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/ForceInjection/domain-driven-design-skills.git /tmp/domain-driven-design-skills
mkdir -p .claude/skills
cp -r /tmp/domain-driven-design-skills/skills/ddd-aggregates .claude/skills/ddd-aggregates
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ddd Aggregates in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Ddd Aggregates on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Ddd Aggregates is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

DDD Aggregates

🌐 English version: English

使用时机

  • 限界上下文与集成策略已就绪,需要设计上下文内部的构造块。
  • 需要回答"哪些对象必须一起变更以保持一致性"。
  • ddd-model-review 报告"不变量表达率 < 60%",或 ddd-domain-interactions 报告"事件需携带另一聚合私有数据"时,作为回溯目标重新执行。

输入要求

  • 必需:事件流与命令候选(来自 ddd-discover)、上下文目录与词汇表(来自 ddd-contexts)。
  • 可选:上下文映射与失败模式(来自 ddd-context-map)。

流程

  1. 提取不变量:从命令与事件中提取"必须始终为真"的业务规则(不变量)。
  2. 聚类对象:以不变量为纽带,将对象聚类为聚合候选;明确聚合根(唯一外部入口)。
  3. 识别构造块:区分聚合内的实体(有标识、有生命周期)与值对象(无标识、不可变、按值比较)。
  4. 定义边界规则:外部只持有聚合根引用;跨聚合引用使用 ID;每个聚合是一个事务边界。
    • 外部引用再审视:对模型中每一个"外部引用对象"(foreign reference),再问一遍——我们自己是否需要管理它的生命周期(创建、修改、终结)?若答案为是,它应被提升为 内部聚合,而不是仅保留 ID 引用。典型触发器:参考数据类对象(港口目录、日历、线路目录)若由我方维护,必须列为聚合。
    • Specification 模式识别:当某条业务规则以"给定 X,X 是否满足 Y"的谓词形式出现(如 isSatisfiedBy(Itinerary)),显式抽取为 Specification,而不是塞进工厂或服务内部的 if 分支。
  5. 命令边界:为每个聚合定义它处理的命令、前置验证、副作用。
  6. 跨聚合一致性:聚合内强一致;聚合间最终一致——定义事件驱动 / 补偿 / 重试策略。
  7. 仓储接口草案:为每个聚合产出仓储接口的语义定义(方法名 + 语义,不含代码实现)。

输出

工件结构要求
聚合目录表格:聚合名、聚合根、包含实体、包含值对象、关键不变量、关键命令
不变量表表格:不变量、触发命令、校验位置、违反时行为
实体与值对象清单表格:名称、类型(Entity/VO)、所属聚合、标识策略/相等性定义
事务边界说明列表:默认规则、例外条件、并发/锁策略
跨聚合一致性策略表格:场景、触发事件、补偿方式、幂等保障、重试策略
仓储接口草案表格:聚合、方法、语义说明、查询边界

校验清单

  • 每个聚合至少对应 1 条显式不变量
  • 聚合边界说明了事务边界;默认"1 个事务修改 1 个聚合"
  • 跨聚合一致性有事件与补偿策略
  • 无"以外键划聚合"的反模式(聚合不是 ORM 关系映射)
  • 实体与值对象的区分有明确理由(标识 vs 值语义)
  • 聚合大小合理:单个聚合不应包含 > 5 个实体(若超过需论证)
  • 每个外部引用都已回答过"其生命周期是否由我方管理";答案为是者已提升为内部聚合
  • 已扫描"谓词型业务规则"并评估 Specification 模式;入选者已列为一等构造块

回溯触发

  • 不变量跨越多个上下文 → 回溯至 ddd-contexts(一致性需求被边界割裂)。
  • 被 ddd-domain-interactions 触发:事件需携带另一聚合私有数据,说明聚合边界需调整。
  • 被 ddd-model-review 触发:不变量表达率 < 60%(聚合可能是数据容器而非行为边界)。

示例

text
@ddd-aggregates
基于以下上下文定义和事件流,帮我设计 Booking 上下文内的聚合:
- 上下文:Booking(预订全生命周期)
- 核心术语:Booking, TimeSlot, BookingPolicy, CheckIn
- 关键事件:BookingRequested, BookingConfirmed, BookingCancelled, CheckInRecorded
请输出聚合目录、不变量表、实体/值对象清单与事务边界说明。

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Ddd Aggregates AI skill do?

从不变量出发设计聚合边界:聚合根、实体、值对象、事务边界与跨聚合一致性策略。

Why use Ddd Aggregates on TypingMind?

Because you install it once and use it with any model. Ddd Aggregates is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Ddd Aggregates in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/ForceInjection/domain-driven-design-skills/tree/main/skills/ddd-aggregates. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Ddd Aggregates?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Ddd Aggregates?

As many as you like. As long as a model supports skills, you can use Ddd Aggregates with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Ddd Aggregates AI skill free?

Yes. It is published on GitHub by ForceInjection under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇