ddd-context

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Create a bounded context directory structure for the given context name.
Parse
$ARGUMENTS
as the context name (kebab-case). If empty, list existing contexts.
为给定的上下文名称创建限界上下文目录结构。
$ARGUMENTS
解析为上下文名称(kebab-case格式)。如果为空,则列出已有的上下文。

Steps

步骤

  1. Validate name: Ensure the context name is kebab-case and does not already exist under
    src/
    .
  2. Create directory structure:
    src/<context-name>/
      domain/
        entities/
        value-objects/
        events/
        services/
        repositories/
      application/
      infrastructure/
  3. Generate index files:
    • src/<context-name>/domain/entities/index.ts
      -- barrel export for entities
    • src/<context-name>/domain/value-objects/index.ts
      -- barrel export for value objects
    • src/<context-name>/domain/events/index.ts
      -- barrel export for domain events
    • src/<context-name>/domain/services/index.ts
      -- barrel export for domain services
    • src/<context-name>/domain/repositories/index.ts
      -- barrel export for repository interfaces
    • src/<context-name>/domain/index.ts
      -- re-export all domain submodules
    • src/<context-name>/application/index.ts
      -- barrel export for application services
    • src/<context-name>/infrastructure/index.ts
      -- barrel export for infrastructure implementations
    • src/<context-name>/index.ts
      -- public API of the bounded context (re-exports domain and application only, NOT infrastructure)
  4. Store in domain model graph:
    mcp__claude-flow__agentdb_hierarchical-store --parent "domain" --child "context:<context-name>" --relation "contains"
    mcp__claude-flow__memory_store --key "ddd-context-<context-name>" --value "Created bounded context" --namespace tasks
  5. Report: Confirm the context was created and list the generated files.
  1. 验证名称:确保上下文名称为kebab-case格式,且在
    src/
    目录下不存在。
  2. 创建目录结构:
    src/<context-name>/
      domain/
        entities/
        value-objects/
        events/
        services/
        repositories/
      application/
      infrastructure/
  3. 生成索引文件:
    • src/<context-name>/domain/entities/index.ts
      -- 实体的桶式导出文件
    • src/<context-name>/domain/value-objects/index.ts
      -- 值对象的桶式导出文件
    • src/<context-name>/domain/events/index.ts
      -- 领域事件的桶式导出文件
    • src/<context-name>/domain/services/index.ts
      -- 领域服务的桶式导出文件
    • src/<context-name>/domain/repositories/index.ts
      -- 仓库接口的桶式导出文件
    • src/<context-name>/domain/index.ts
      -- 重新导出所有领域子模块
    • src/<context-name>/application/index.ts
      -- 应用服务的桶式导出文件
    • src/<context-name>/infrastructure/index.ts
      -- 基础设施实现的桶式导出文件
    • src/<context-name>/index.ts
      -- 限界上下文的公开API(仅重新导出领域层和应用层,不包含基础设施层)
  4. 存储到领域模型图:
    mcp__claude-flow__agentdb_hierarchical-store --parent "domain" --child "context:<context-name>" --relation "contains"
    mcp__claude-flow__memory_store --key "ddd-context-<context-name>" --value "Created bounded context" --namespace tasks
  5. 报告:确认上下文已创建,并列出生成的文件。