Token导航 LogoToken导航TokenDH.com
开发权限需确认github未标认证来源可访问许可证需确认审计通过

domain-building-blocks域构建块

Agent Skill

domain-building-blocks 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

648

周安装

27

GitHub Stars

75

下载量

216
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/j5ik2o/okite-ai --skill domain-building-blocks

简介

domain-building-blocks 提供领域驱动设计的通用构建块原则,跨语言适用。

  • 适用于值对象、实体、聚合的设计与实现,强调不变性与自包含特性。
  • 包含错误处理、验证与领域事件的设计模式与实践示例。
  • 以 TypeScript 为例说明概念,可迁移至其他编程语言体系。
  • 建议结合实际业务规则与不变量要求设计合适的领域模型结构。

SKILL.md

ドメインモデルのビルディングブロック

このガイドは特定のプログラミング言語に依存せず、どの言語でも適用可能な原則を説明しています。コード例はTypeScriptで示していますが、概念は他の言語にも応用できます。

ドメイン駆動設計では、適切なドメインモデルのビルディングブロックを使うことが重要です。

値オブジェクトの活用

値オブジェクトは、以下の特性を持つオブジェクトです:

  • 識別子を持たない: 属性のみで同一性を判断
  • 不変: 一度作成したら変更できない
  • 自己完結的: 他のエンティティへの参照を持たない
import * as E from 'fp-ts/Either';

class IllegalArgumentError extends Error {
  constructor(message: string) {
    super(message);
    this.name = 'IllegalArgumentError';
  }
}

class ValidationError {
  private constructor(private readonly _message: string) {}

  static of(message: string): ValidationError {
    return new ValidationError(message);
  }

  get message(): string {
    return this._message;
  }
}

class MoneyAddError extends Error {
  constructor(message: string) {
    super(message);
    this.name = 'MoneyAddError';
  }
}

class MoneySubtractError extends Error {
  constructor(message: string) {
    super(message);
    this.name = 'MoneySubtractError';
  }
}

class AssertionError extends Error {
  constructor(message: string) {
    super(message);
    this.name = 'AssertionError';
  }
}

type MoneyProps = {
  amount: number;
  currency: string;
};

class Money {

  private constructor(
    private readonly _amount: number,
    private readonly _currency: string
  ) {
    if (this._amount < 0) {
      throw new IllegalArgumentError("金額は0以上である必要があります");
    }
    if (!["JPY", "USD", "EUR"].includes(this._currency)) {
      throw new IllegalArgumentError("サポートされていない通貨です");
    }
  }

  static of(props: MoneyProps): Money {
    return new Money(props.amount, props.currency);
  }

  static validate(props: MoneyProps): E.Either<ValidationError, Money> {
    try {
      return E.right(Money.of(props));
    } catch (e: unknown) {
      if (e instanceof IllegalArgumentError) {
        return E.left(ValidationError.of(e.message));
      }
      throw new AssertionError("不明なエラーが発生しました");
    }
  }

  private copy(props: Partial<MoneyProps>): Money {
    return Money.of({
      amount: props.amount ?? this._amount,
      currency: props.currency ?? this._currency
    });
  }

  add(other: Money): E.Either<MoneyAddError, Money> {
    if (this._currency !== other._currency) {
      return E.left(new MoneyAddError("通貨が異なる金額は加算できません"));
    }
    return E.right(this.copy({ amount: this._amount + other._amount }));
  }

  subtract(other: Money): E.Either<MoneySubtractError, Money> {
    if (this._currency !== other._currency) {
      return E.left(new MoneySubtractError("通貨が異なる金額は減算できません"));
    }
    if ((this._amount - other._amount) < 0) {
      return E.left(new MoneySubtractError("金額が負になるため減算できません"));
    }
    return E.right(this.copy({ amount: this._amount - other._amount }));
  }

  get breachEncapsulationOfAmount(): number {
    return this._amount;
  }

  get breachEncapsulationOfCurrency(): string {
    return this._currency;
  }

  equals(other: Money): boolean {
    return this._amount === other._amount && this._currency === other._currency;
  }

  toString(): string {
    return `${this._amount} ${this._currency}`;
  }
}

エンティティと集約

エンティティと集約は以下の原則に従って設計します:

  1. エンティティ:

- 識別子を持つ - ライフサイクルを持つ - その状態が時間とともに変化する

  1. 集約:

- トランザクション整合性の単位 - 1つの集約ルートと複数の子エンティティや値オブジェクトから構成 - 外部からは集約ルートを通じてのみアクセス可能

type OrderProps = {
  id: OrderId;
  orderItems: OrderItems;
  status: OrderStatus;
};

class Order {

  private constructor(
    private readonly _id: OrderId,
    private readonly _status: OrderStatus,
    private readonly _orderItems: OrderItems
  ) {}

  static create(props: Pick<OrderProps, "id"> & Partial<OrderProps>): Order {
    return new Order(
      props.id,
      props.status ?? OrderStatus.DRAFT,
      props.orderItems ?? OrderItems.empty()
    );
  }

  addOrderItem(props: { product: ProductId; quantity: Quantity; unitPrice: Money }): E.Either<AddOrderItemError, Order> {
    if (this._status !== OrderStatus.DRAFT) {
      return E.left(new AddOrderItemError("注文確定後は商品を追加できません"));
    }
    const orderItem = OrderItem.create(props.product, props.quantity, props.unitPrice);
    const newOrderItems = this._orderItems.add(orderItem);
    return E.right(this.copy({ orderItems: newOrderItems }));
  }

  confirm(): E.Either<OrderConfirmationError, Order> {
    if (this._orderItems.isEmpty()) {
      return E.left(new OrderConfirmationError("注文に商品が含まれていません"));
    }
    if (this._status !== OrderStatus.DRAFT) {
      return E.left(new OrderConfirmationError("すでに確定済みの注文です"));
    }
    return E.right(this.copy({ status: OrderStatus.CONFIRMED }));
  }

  equals(other: Order): boolean {
    return this._id.equals(other._id) &&
           this._status === other._status &&
           this._orderItems.equals(other._orderItems);
  }

  private copy(props: Partial<OrderProps>): Order {
    return new Order(
      props.id ?? this._id,
      props.status ?? this._status,
      props.orderItems ?? this._orderItems
    );
  }

  sameIdentityAs(other: Order): boolean {
    return this._id.equals(other._id);
  }

  get breachEncapsulationOfId(): OrderId {
    return this._id;
  }

  get breachEncapsulationOfStatus(): OrderStatus {
    return this._status;
  }

  get breachEncapsulationOfOrderItems(): OrderItems {
    return this._orderItems;
  }
}

ドメインサービス

複数のエンティティや値オブジェクトにまたがる操作はドメインサービスとして実装します:

// エンティティ例: 口座(入出金はエンティティの責務)
class BankAccount {
  private constructor(
    private readonly _id: BankAccountId,
    private readonly _balance: Money
  ) {}

  deposit(amount: Money): E.Either<BankAccountDepositError, BankAccount> {
    const result = this._balance.add(amount);
    if (E.isLeft(result)) {
      return E.left(new BankAccountDepositError(result.left.message));
    }
    return E.right(this.copy({ balance: result.right }));
  }

  withdraw(amount: Money): E.Either<BankAccountWithdrawalError, BankAccount> {
    const result = this._balance.subtract(amount);
    if (E.isLeft(result)) {
      return E.left(new BankAccountWithdrawalError(result.left.message));
    }
    return E.right(this.copy({ balance: result.right }));
  }

  private copy(props: { balance?: Money }): BankAccount {
    return new BankAccount(
      this._id,
      props.balance ?? this._balance
    );
  }
}

// ドメインサービスの例
// クラス名やメソッド名はユビキタス言語に対応すること
class BankAccountTransfer {
  static transfer(
    from: BankAccount,
    to: BankAccount,
    amount: Money
  ): E.Either<BankAccountTransferError, [BankAccount, BankAccount]> {
    const newFromResult = from.withdraw(amount);
    if (E.isLeft(newFromResult)) {
      return E.left(new BankAccountTransferError(
        `残高不足または出金元口座でのエラー: ${newFromResult.left.message}`
      ));
    }
    const newToResult = to.deposit(amount);
    if (E.isLeft(newToResult)) {
      return E.left(new BankAccountTransferError(
        `入金先口座でのエラー: ${newToResult.left.message}`
      ));
    }
    return E.right([newFromResult.right, newToResult.right]);
  }
}
// グローバル関数として定義してもよい
function bankAccountTransfer(
  from: BankAccount,
  to: BankAccount,
  amount: Money
): E.Either<BankAccountTransferError, [BankAccount, BankAccount]> {
  const newFromResult = from.withdraw(amount);
  if (E.isLeft(newFromResult)) {
    return E.left(new BankAccountTransferError(
      `残高不足または出金元口座でのエラー: ${newFromResult.left.message}`
    ));
  }
  const newToResult = to.deposit(amount);
  if (E.isLeft(newToResult)) {
    return E.left(new BankAccountTransferError(
      `入金先口座でのエラー: ${newToResult.left.message}`
    ));
  }
  return E.right([newFromResult.right, newToResult.right]);
}

関連スキル(併読推奨)

このスキルを使用する際は、以下のスキルも併せて参照すること:

  • aggregate-design: ビルディングブロックを束ねる集約の設計ルール
  • domain-model-first: テストファーストでビルディングブロックを実装する開発手順
  • parse-dont-validate: 値オブジェクトを型レベルで設計するパターン
  • domain-primitives-and-always-valid: ドメインプリミティブとスマートコンストラクタの設計

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33.64%
按下载量换算73

Claude

29.7%
按下载量换算64

Cursor

19.28%
按下载量换算42

Gemini CLI

8.44%
按下载量换算18

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

权限需确认

当前来源未能明确判断权限范围,默认进入异常复核队列。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills