Token导航 LogoToken导航

Agent Skill · 研究检索

domain-driven-design(领域驱动设计)

用于辅助界面设计、视觉规范、排版、配色、布局和交互体验优化。它适合让 Agent 根据产品场景整理页面结构、生成 UI 方案、检查视觉一致性或改进组件层级。使用时需要结合现有品牌、设计系统和用户任务,不应只堆装饰元素;涉及真实页面改动时,应通过截图或浏览器预览检查文本溢出、对齐和响应式表现。

domain-driven-design 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证为 MIT,暂无第三方扫描结果,按安装量在研究检索类的 73,675 个 Skill 里排第 70,604。

总安装 210周安装 9GitHub Stars 265下载 73核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:domain-driven-design(领域驱动设计)
来源仓库:https://github.com/rsmdt/the-startup
仓库路径:skills/domain-driven-design
安装命令:
npx skills add https://github.com/rsmdt/the-startup --skill domain-driven-design
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/rsmdt/the-startup --skill domain-driven-design

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

domain-driven-design 提供领域驱动设计的模式集合,用于建模复杂业务系统。适用于定义有界上下文、实施不变量与规划一致性策略。涵盖战略模式如限界上下文、领域事件与集成机制设计。帮助建立统一语言(Ubiquitous Language)减少沟通歧义。建议结合具体项目复杂度选择合适的一致性边界与聚合设计。

来源仓库内路径:skills/domain-driven-design

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/rsmdt/the-startup --skill domain-driven-design;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

domain-driven-design 怎么安装?

在终端执行 npx skills add https://github.com/rsmdt/the-startup --skill domain-driven-design。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

domain-driven-design 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

domain-driven-design 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

domain-driven-design 是免费的吗?

来源标注的许可证是 MIT。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

domain-driven-design 用的人多吗?

公开数据是累计安装 210 次,近一周安装 9 次,下载 73 次,GitHub 265 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

domain-driven-design 安全吗?

没有查到第三方扫描结果,安全性无法从公开资料判断,安装前请自行审查源码、依赖和命令行为。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 3 个目录同时收录,说明这个 Skill 流传比较广。
  • 许可证明确为 MIT,商用和分发边界好判断。

先想清楚的地方

  • 没有第三方扫描结果,安全性只能靠自己读源码判断。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 要求有安全扫描结论才肯安装的团队。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
domain-driven-design

领域驱动设计 · 本页

210265需要联网MIT未收录

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Domain-Driven Design Patterns

Patterns for modeling complex business domains with clear boundaries, enforced invariants, and appropriate consistency strategies.

When to Activate

  • Modeling business domains and entities
  • Designing aggregate boundaries
  • Implementing complex business rules
  • Planning data consistency strategies
  • Establishing bounded contexts
  • Designing domain events and integration

Strategic Patterns

Bounded Context

A bounded context defines the boundary within which a domain model applies. The same term can mean different things in different contexts.

Example: "Customer" in different contexts

┌─────────────────┐  ┌─────────────────┐  ┌─────────────────┐
│    Sales        │  │    Support      │  │    Billing      │
│    Context      │  │    Context      │  │    Context      │
├─────────────────┤  ├─────────────────┤  ├─────────────────┤
│ Customer:       │  │ Customer:       │  │ Customer:       │
│ - Leads         │  │ - Tickets       │  │ - Invoices      │
│ - Opportunities │  │ - SLA           │  │ - Payment       │
│ - Proposals     │  │ - Satisfaction  │  │ - Credit Limit  │
└─────────────────┘  └─────────────────┘  └─────────────────┘
Context Identification

Ask these questions to find context boundaries:

  • Where does the ubiquitous language change?
  • Which teams own which concepts?
  • Where do integration points naturally occur?
  • What could be deployed independently?

Context Mapping

Define how bounded contexts integrate:

PatternDescriptionUse When
Shared KernelShared code between contextsClose collaboration, same team
Customer-SupplierUpstream/downstream relationshipClear dependency direction
ConformistDownstream adopts upstream modelNo negotiation power
Anti-Corruption LayerTranslation layer between modelsProtecting domain from external models
Open Host ServicePublished API for integrationMultiple consumers
Published LanguageShared interchange formatIndustry standards exist

Ubiquitous Language

The shared vocabulary between developers and domain experts:

Building Ubiquitous Language:

1. EXTRACT terms from domain expert conversations
2. DOCUMENT in a glossary with precise definitions
3. ENFORCE in code - class names, method names, variables
4. EVOLVE as understanding deepens

Example Glossary Entry:
┌─────────────────────────────────────────────────────────────┐
│ Term: Order                                                  │
│ Definition: A confirmed request from a customer to purchase │
│             one or more products at agreed prices.          │
│ NOT: A shopping cart (which is an Intent, not an Order)     │
│ Context: Sales                                              │
└─────────────────────────────────────────────────────────────┘

Tactical Patterns

Entities

Objects with identity that persists over time. Equality is based on identity, not attributes.

Characteristics:
- Has a unique identifier
- Mutable state
- Lifecycle (created, modified, archived)
- Equality by ID

Example:
┌─────────────────────────────────────────┐
│ Entity: Order                           │
├─────────────────────────────────────────┤
│ Identity: orderId (UUID)                │
│ State: status, items, total             │
│ Behavior: addItem(), submit(), cancel() │
└─────────────────────────────────────────┘

class Order {
  private readonly id: OrderId;      // Identity - immutable
  private status: OrderStatus;        // State - mutable
  private items: OrderItem[];         // State - mutable

  constructor(id: OrderId) {
    this.id = id;
    this.status = OrderStatus.Draft;
    this.items = [];
  }

  equals(other: Order): boolean {
    return this.id.equals(other.id);  // Equality by identity
  }
}

Value Objects

Objects without identity. Equality is based on attributes. Always immutable.

Characteristics:
- No unique identifier
- Immutable (all properties readonly)
- Equality by attributes
- Self-validating

Example:
┌─────────────────────────────────────────┐
│ Value Object: Money                     │
├─────────────────────────────────────────┤
│ Attributes: amount, currency            │
│ Behavior: add(), subtract(), format()   │
│ Invariant: amount >= 0                  │
└─────────────────────────────────────────┘

class Money {
  constructor(
    public readonly amount: number,
    public readonly currency: Currency
  ) {
    if (amount < 0) throw new Error('Amount cannot be negative');
  }

  add(other: Money): Money {
    if (!this.currency.equals(other.currency)) {
      throw new Error('Cannot add different currencies');
    }
    return new Money(this.amount + other.amount, this.currency);
  }

  equals(other: Money): boolean {
    return this.amount === other.amount &&
           this.currency.equals(other.currency);
  }
}
When to Use Value Objects
Use Value ObjectUse Entity
No need to track over timeNeed to track lifecycle
Interchangeable instancesUnique identity matters
Defined by attributesDefined by continuity
Examples: Money, Address, DateRangeExamples: User, Order, Account

Aggregates

A cluster of entities and value objects with a defined boundary. One entity is the aggregate root.

Aggregate Design Rules:

1. PROTECT invariants at aggregate boundary
2. REFERENCE other aggregates by identity only
3. UPDATE one aggregate per transaction
4. DESIGN small aggregates (prefer single entity)

Example:
┌─────────────────────────────────────────────────────────────┐
│ Aggregate: Order                                            │
│ Root: Order (entity)                                        │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────────┐                                        │
│  │ Order (Root)    │◄── Aggregate Root                      │
│  │ - orderId       │                                        │
│  │ - customerId ───┼──► Reference by ID only                │
│  │ - status        │                                        │
│  └────────┬────────┘                                        │
│           │                                                 │
│  ┌────────▼────────┐                                        │
│  │ OrderItem       │◄── Inside aggregate                    │
│  │ - productId ────┼──► Reference by ID only                │
│  │ - quantity      │                                        │
│  │ - price (Money) │◄── Value Object                        │
│  └─────────────────┘                                        │
└─────────────────────────────────────────────────────────────┘
Aggregate Sizing
Start Small:
- Begin with single-entity aggregates
- Expand only when invariants require it

Signs of Too-Large Aggregate:
- Frequent optimistic lock conflicts
- Loading too much data for simple operations
- Multiple users editing simultaneously
- Transactional failures across unrelated data

Signs of Too-Small Aggregate:
- Invariants not protected
- Business rules scattered across services
- Eventual consistency where immediate is required

Domain Events

Represent something that happened in the domain. Immutable facts about the past.

Event Structure:
┌─────────────────────────────────────────┐
│ Event: OrderPlaced                      │
├─────────────────────────────────────────┤
│ eventId: UUID                           │
│ occurredAt: DateTime                    │
│ aggregateId: orderId                    │
│ payload:                                │
│   - customerId                          │
│   - items                               │
│   - totalAmount                         │
└─────────────────────────────────────────┘

Naming Convention:
- Past tense (OrderPlaced, not PlaceOrder)
- Domain language (not technical)
- Include all relevant data (event is immutable)

class OrderPlaced implements DomainEvent {
  readonly eventId = uuid();
  readonly occurredAt = new Date();

  constructor(
    readonly orderId: OrderId,
    readonly customerId: CustomerId,
    readonly items: OrderItemData[],
    readonly totalAmount: Money
  ) {}
}
Event Patterns
PatternDescriptionUse Case
Event NotificationMinimal data, query for detailsLoose coupling
Event-Carried StateFull data in eventPerformance, offline
Event SourcingEvents as source of truthAudit, temporal queries

Repositories

Abstract persistence, providing collection-like access to aggregates.

Repository Principles:
- One repository per aggregate
- Returns aggregate roots only
- Hides persistence mechanism
- Supports aggregate reconstitution

interface OrderRepository {
  findById(id: OrderId): Promise<Order | null>;
  findByCustomer(customerId: CustomerId): Promise<Order[]>;
  save(order: Order): Promise<void>;
  delete(order: Order): Promise<void>;
}

// Implementation hides persistence details
class PostgresOrderRepository implements OrderRepository {
  async findById(id: OrderId): Promise<Order | null> {
    const row = await this.db.query('SELECT * FROM orders WHERE id = $1', [id]);
    return row ? this.reconstitute(row) : null;
  }

  private reconstitute(row: OrderRow): Order {
    // Rebuild aggregate from persistence
  }
}

Consistency Strategies

Transactional Consistency (ACID)

Use for invariants within an aggregate:

Rule: One aggregate per transaction

// Good: Single aggregate updated
async function addItemToOrder(orderId: OrderId, item: OrderItem) {
  const order = await orderRepo.findById(orderId);
  order.addItem(item);  // Business rules enforced
  await orderRepo.save(order);
}

// Bad: Multiple aggregates in one transaction
async function createOrderWithInventory() {
  await db.transaction(async (tx) => {
    await orderRepo.save(order, tx);
    await inventoryRepo.decrement(productId, quantity, tx);  // Don't do this
  });
}

Eventual Consistency

Use for consistency across aggregates:

Pattern: Domain Events + Handlers

// Order aggregate publishes event
class Order {
  submit(): void {
    this.status = OrderStatus.Placed;
    this.addEvent(new OrderPlaced(this.id, this.customerId, this.items));
  }
}

// Separate handler updates inventory (eventually)
class InventoryHandler {
  async handle(event: OrderPlaced): Promise<void> {
    for (const item of event.items) {
      await this.inventoryService.reserve(item.productId, item.quantity);
    }
  }
}

Saga Pattern

Coordinate multiple aggregates with compensation:

Saga: Order Fulfillment

┌─────────┐     ┌─────────────┐     ┌─────────────┐     ┌─────────┐
│ Create  │────►│ Reserve     │────►│ Charge      │────►│ Ship    │
│ Order   │     │ Inventory   │     │ Payment     │     │ Order   │
└────┬────┘     └──────┬──────┘     └──────┬──────┘     └─────────┘
     │                 │                   │
     │ Compensate:     │ Compensate:       │ Compensate:
     │ Cancel Order    │ Release Inventory │ Refund Payment
     ▼                 ▼                   ▼

On failure at any step, execute compensation in reverse order.

Choosing Consistency

ScenarioStrategy
Within single aggregateTransactional (ACID)
Across aggregates, same serviceEventual (domain events)
Across servicesSaga with compensation
Read model updatesEventual (projection)

Anti-Patterns

Anemic Domain Model

// Anti-pattern: Logic outside domain objects
class Order {
  id: string;
  items: Item[];
  status: string;
}

class OrderService {
  calculateTotal(order: Order): number { ... }
  validate(order: Order): boolean { ... }
  submit(order: Order): void { ... }
}

// Better: Logic inside domain objects
class Order {
  private items: OrderItem[];
  private status: OrderStatus;

  get total(): Money {
    return this.items.reduce((sum, item) => sum.add(item.subtotal), Money.zero());
  }

  submit(): void {
    this.validate();
    this.status = OrderStatus.Submitted;
  }
}

Large Aggregates

// Anti-pattern: Everything in one aggregate
class Customer {
  orders: Order[];           // Could be thousands
  addresses: Address[];
  paymentMethods: PaymentMethod[];
  preferences: Preferences;
  activityLog: Activity[];   // Could be millions
}

// Better: Separate aggregates referenced by ID
class Customer {
  id: CustomerId;
  defaultAddressId: AddressId;
  defaultPaymentMethodId: PaymentMethodId;
}

class Order {
  customerId: CustomerId;    // Reference by ID
}

Primitive Obsession

// Anti-pattern: Primitive types for domain concepts
function createOrder(
  customerId: string,
  productId: string,
  quantity: number,
  price: number,
  currency: string
) { ... }

// Better: Value objects
function createOrder(
  customerId: CustomerId,
  productId: ProductId,
  quantity: Quantity,
  price: Money
) { ... }

Implementation Checklist

Aggregate Design

  • Single entity can be aggregate root
  • Invariants are protected at boundary
  • Other aggregates referenced by ID only
  • Fits in memory comfortably
  • One transaction per aggregate

Entity Implementation

  • Has unique identifier
  • Equality based on ID
  • Encapsulates business rules
  • State changes through methods

Value Object Implementation

  • All properties immutable
  • Equality based on attributes
  • Self-validating
  • Operations return new instances

Repository Implementation

  • One per aggregate
  • Returns aggregate roots only
  • Hides persistence details
  • Supports queries needed by domain

References

平台分布

Claude Code

27.6%
按下载量换算20

windsurf

23.33%
按下载量换算17

OpenCode

17.79%
按下载量换算13

Codex

10.84%
按下载量换算8

Gemini CLI

6.31%
按下载量换算5

trae

3.02%
按下载量换算2

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

继续浏览同类 Skills