English version: English
When to Use
- Tactical modeling (Stage III) is complete, the model has passed validation (Stage IV), and it is ready to enter the development phase.
- The domain model needs to be converted into a structured engineering specification that can be executed by an AI Agent or developers.
- A "single source of truth" (Source of Truth) needs to be established between the business model and the code implementation.
Input Requirements
- Required:
- Problem space definition (from
ddd-scope) - Subdomain classification and core domain declaration (from
ddd-subdomains) - Context catalog and ADRs (from
ddd-contexts) - Context mapping and integration patterns (from
ddd-context-map) - Aggregate catalog and invariants (from
ddd-aggregates) - Domain interaction definitions: domain events, domain services, repository interfaces, factories (from
ddd-domain-interactions)
- Problem space definition (from
- Optional:
- Discovery phase event flows and boundary clues (from
ddd-discover) - Model validation report (from
ddd-model-review)
- Discovery phase event flows and boundary clues (from
- Execution Standards: The mapping logic must follow the standard definitions in ddd-openspec-mapping.md .
Process
- Initialize the OpenSpec change set: Under
openspec/changes/<change-id>/, create a directory and generate the.openspec.yamlfor this change. Note: this is different from the globalopenspec/config.yaml—the latter is maintained once by theddd-contextsstage and is used to declare the domain-bounded context mapping and architectural constraints. - Generate the Proposal (
proposal.md):- Map the problem statement of
ddd-scopeto Why. - Write the Capabilities involved in this change into What Changes; organize priorities according to the classification in
ddd-subdomains:Core subdomainmust be fully Scenario-ized,Generic subdomainmay reference existing specifications or external components. - In Impact, list the affected Capabilities and the aggregate change list; in Goals, define success criteria (SLO / acceptance metrics).
- Map the problem statement of
- Establish the Bounded-Context directory: According to the context catalog in
ddd-contexts, underspecs/<bounded-context>/<capability>/spec.md, establish a specification file for each capability.Using a flatspecs/domain-model/directory is prohibited—it would break the strategic alignment between bounded contexts and the domain catalog. - Write Requirements and Scenarios(strictly following the mapping direction of ddd-openspec-mapping.md §2.1 ):
- Requirement ←
ddd-domain-interactionscommands and domain services in ; one Requirement corresponds toone independently verifiable business capability, the number of Scenarios ≤ 5 and does not cross aggregate roots. - Scenario ←
ddd-aggregatesaggregate behaviors and invariants in , described as Given/When/Then; P0-level invariants must have corresponding Scenarios. - Domain eventsare written as side effects in the Then/And clauses of the Scenario (e.g., "And publish the OrderPlaced event").
- Business rules first: Scenarios only describe business rules and invariants, and must not leak technical details such as databases, HTTP, ORM, or caching.
- Requirement ←
- Ubiquitous language validation: Against the glossary in
ddd-contexts, ensure thatproposal.mdand all terms inspec.mdfall within the glossary; terms not included must first be written back to the glossary or replaced with synonyms. - Design the technical solution (
design.md): Integrateddd-context-mapintegration patterns withddd-domain-interactionscollaboration mechanisms; describe layered architecture mapping, cross-context translation (ACL), event publishing/consuming paradigms (Outbox pattern, idempotency keys, only one aggregate modified per transaction—see ddd-openspec-mapping.md Appendix A)。 - Break down development tasks (
tasks.md): break down tasks in Spec dependency order (Domain Model → Repository → Application Service → API/Integration), with each task linked to the corresponding Requirement or Scenario as acceptance criteria.
Output
| Artifact | Structural Requirements |
|---|---|
proposal.md |
Includes Why, What Changes, Impact (Capabilities / aggregate changes), Goals. |
design.md |
Includes architecture design, data model mapping, core data flows, interface protocol definitions. |
specs/ directory |
Subfolders organized by capability, containing spec.md(Requirement + Scenario format). |
tasks.md |
Includes task title, task description, linked Spec path, acceptance criteria. |
Validation Checklist
- The OpenSpec directory structure conforms to the specification (config, specs, changes);
specs/organized into directories by bounded context, with no flatdomain-model/。 - Requirement granularity meets the standard: each Requirement corresponds to one independently verifiable business capability, with ≤ 5 Scenarios and no crossing of aggregate roots.
- Scenarios maintain business-rule priority: no technical details such as databases, HTTP, ORM, or caching appear; all
ddd-aggregatesP0 invariants have been converted into Scenarios. - Terminology consistency:
proposal.mdand allspec.mdterminology can be found in theddd-contextsglossary;proposal.mdCapabilities are consistent withddd-contexts. - Event-driven paradigm implemented: cross-aggregate scenarios in
design.mdexplicitly follow the Outbox pattern, idempotency keys, and the "only one aggregate modified per transaction" constraint. - Iteration pace controllable (small steps, fast pace): the scale of this change set can complete the convergence of specification and code within a single Apply phase, without sliding into a mini-waterfall.
-
tasks.mdtasks are executable, and each task has an explicit Requirement / Scenario reference as acceptance criteria. - Chinese and English typography conforms to project standards (spaces between Chinese and English, backticks around proper nouns).
Backtracking Triggers
- When writing Scenarios, domain logic is found to be ambiguous or conflicting → backtrack to
ddd-aggregatesorddd-domain-interactions。 - A certain integration pattern cannot be clearly expressed under the OpenSpec structure → backtrack to
ddd-context-map。 - Technical details (database / HTTP / ORM, etc.) cannot be removed from Scenarios → violates the business-rule priority principle; first rewrite within this Skill, and if the semantics still cannot be purified, backtrack to
ddd-aggregatesto redefine aggregate behavior. - A single Requirement carries more than 5 Scenarios or spans multiple aggregate roots → violates the granularity convention, backtrack to
ddd-domain-interactionsto split commands and domain services. - Terminology is not included in the
ddd-contextsglossary → backtrack toddd-contextsto add or unify terminology.
Examples
@ddd-openspec-bridge
根据已完成的"会议室预订系统"建模产出,生成 OpenSpec 变更集规范:
- 聚合:Booking, RoomSchedule
- 关键流程:预订申请、冲突检测、签到、取消
- 上下文:Booking Context, Room Catalog Context
请输出 proposal.md, design.md 以及 specs/booking-context/booking/spec.md 的核心 Requirement 与 Scenario 片段。
For a complete demonstration of Requirement / Scenario writing, see ddd-openspec-mapping.md §5(an end-to-end minimal viable example using "user registration" as the example).